{"id":174609,"date":"2024-02-20T16:10:26","date_gmt":"2024-02-20T10:40:26","guid":{"rendered":"https:\/\/git-staging.wpastra.com\/?post_type=docs&#038;p=174609"},"modified":"2024-02-20T16:16:53","modified_gmt":"2024-02-20T10:46:53","slug":"change-add-to-cart-text-strings","status":"publish","type":"docs","link":"https:\/\/git-staging.wpastra.com\/es\/docs\/change-add-to-cart-text-strings\/","title":{"rendered":"C\u00f3mo cambiar las cadenas de texto de \"A\u00f1adir al carrito"},"content":{"rendered":"<p>Puede cambiar las cadenas de texto predeterminadas \"A\u00f1adir al carrito\" por \"Comprar ahora\" en su p\u00e1gina de producto \u00fanico de WooCommerce y en la p\u00e1gina de archivo de productos (colecci\u00f3n). Para ello, puede utilizar los filtros adjuntos en este documento.<\/p>\n\n\n\n<p>Para saber m\u00e1s sobre c\u00f3mo utilizar estos filtros, consulte las secciones siguientes de este documento.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-174609-_v6wjwluwkvrr\"><\/a>C\u00f3mo cambiar las cadenas de WooCommerce a la fuerza<\/h3>\n\n\n\n<p>Puede seguir los siguientes pasos para cambiar las cadenas de texto predeterminadas \"A\u00f1adir al carrito\" a \"Comprar ahora\" en su p\u00e1gina de producto \u00fanico de WooCommerce y en las p\u00e1ginas de archivo de productos (colecci\u00f3n). <\/p>\n\n\n\n<p>Antes de realizar cualquier personalizaci\u00f3n, es recomendable crear un archivo\u00a0<a href=\"https:\/\/git-staging.wpastra.com\/es\/docs\/install-astra-child-theme\/\">tema hijo para evitar que afecte al tema principal<\/a>. Si ya dispone de un tema hijo, puede omitir este paso.<\/p>\n\n\n\n<p><strong>Paso 1: Acceda a su panel de control de WordPress<\/strong><\/p>\n\n\n\n<p>Inicie sesi\u00f3n en el panel de administraci\u00f3n de WordPress. Aqu\u00ed es donde realizar\u00e1s los cambios necesarios en las p\u00e1ginas de categor\u00edas de WooCommerce.<\/p>\n\n\n\n<p><strong>Paso 2: Abra el<a href=\"https:\/\/git-staging.wpastra.com\/es\/docs\/install-astra-child-theme\/\">&nbsp;Tema infantil<\/a>&nbsp;Archivo functions.php<\/strong><\/p>\n\n\n\n<p>Vaya a \"Apariencia\" en el panel de WordPress y seleccione \"Editor de temas\". En el Editor de temas, busque y haga clic en el archivo \"functions.php\". Este archivo contiene el c\u00f3digo que controla varios aspectos de tu tema de WordPress.<\/p>\n\n\n\n<p><strong>Paso 3: Introducir el c\u00f3digo<\/strong><\/p>\n\n\n\n<p>Una vez que est\u00e9s en el archivo \"functions.php\", tendr\u00e1s que insertar el siguiente fragmento de c\u00f3digo:<\/p>\n\n\n\n<pre class=\"wp-block-code\" data-no-translation=\"\" data-no-auto-translation=\"\"><code>\/\/ To change add to cart text on single product page\r\nadd_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' ); \r\nfunction woocommerce_custom_single_add_to_cart_text() {\r\n    return __( 'Buy Now', 'woocommerce' ); \r\n}\r\n \r\n\/\/ To change add to cart text on product archives (collection) page\r\nadd_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text' );  \r\nfunction woocommerce_custom_product_add_to_cart_text() {\r\n    return __( 'Buy Now', 'woocommerce' );\r\n}\r\n<\/code><\/pre>\n\n\n\n<p>En el fragmento de c\u00f3digo anterior, estamos utilizando dos filtros de WooCommerce para modificar el texto de a\u00f1adir al carrito. La funci\u00f3n `add_filter` se utiliza para enganchar en ganchos de filtro espec\u00edficos proporcionados por WooCommerce.<\/p>\n\n\n\n<p>El filtro `woocommerce_product_single_add_to_cart_text` se utiliza para modificar el texto de a\u00f1adir al carrito en la p\u00e1gina de producto \u00fanico. La funci\u00f3n personalizada `woocommerce_custom_single_add_to_cart_text` es responsable de devolver el texto deseado. En este caso, devolvemos \"Comprar ahora\".<\/p>\n\n\n\n<p>El filtro `woocommerce_product_add_to_cart_text` se utiliza para modificar el texto de a\u00f1adir al carrito en la p\u00e1gina de archivo de productos (colecci\u00f3n). Del mismo modo, la funci\u00f3n personalizada `woocommerce_custom_product_add_to_cart_text` devuelve el texto deseado \"Comprar ahora\".<\/p>\n\n\n\n<p><strong>Paso 4: Guarde los cambios<\/strong><\/p>\n\n\n\n<p>Despu\u00e9s de insertar el c\u00f3digo, aseg\u00farese de guardar los cambios haciendo clic en el bot\u00f3n \"Actualizar archivo\". De este modo, las modificaciones surtir\u00e1n efecto en su sitio web.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2024\/02\/add-to-cart-string-1024x511.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"511\" src=\"https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2024\/02\/add-to-cart-string-1024x511.png\" alt=\"\" class=\"wp-image-174614\" srcset=\"https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2024\/02\/add-to-cart-string-1024x511.png 1024w, https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2024\/02\/add-to-cart-string-300x150.png 300w, https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2024\/02\/add-to-cart-string-768x383.png 768w, https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2024\/02\/add-to-cart-string-1536x767.png 1536w, https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2024\/02\/add-to-cart-string-18x9.png 18w, https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2024\/02\/add-to-cart-string.png 1667w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Siguiendo estos pasos, las cadenas de texto \"A\u00f1adir al carrito\" se cambiar\u00e1n forzosamente a \"Comprar ahora\" en su p\u00e1gina de producto \u00fanico de WooCommerce y en la p\u00e1gina de archivo de productos (colecci\u00f3n).<\/p>\n\n\n\n<p>Esperamos que este documento le haya sido \u00fatil. No dude en dejarnos un comentario a continuaci\u00f3n si tiene alguna duda.<\/p>","protected":false},"excerpt":{"rendered":"<p>You can change the default text strings \u201cAdd to Cart\u201d to \u201cBuy Now\u201d on your WooCommerce single product page and product archive (collection) page. To do so, you can use the filters attached in this document. To know more about how to use these filter, go through the below sections of this document. How to [\u2026]<\/p>","protected":false},"author":89,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"docs_category":[2112],"docs_tag":[],"class_list":{"0":"post-174609","1":"docs","2":"type-docs","3":"status-publish","5":"docs_category-woocommerce-filters"},"spectra_custom_meta":{"_edit_lock":["1708600351:89"],"rank_math_internal_links_processed":["1"],"_uag_custom_page_level_css":[""],"ast-site-content-layout":["default"],"theme-transparent-header-meta":[""],"adv-header-id-meta":[""],"stick-header-meta":[""],"astra-migrate-meta-layouts":["set"],"rank_math_seo_score":["14"],"_edit_last":["89"],"tap_disable_autolinker":["no"],"tap_autolink_inside_heading":["global"],"tap_autolink_random_placement":["global"],"tap_post_autolinker_limit":["0"],"views":["6757"],"helpful":["4"],"unhelpful":["3"],"redirects":["0"],"rank_math_primary_docs_category":["2112"],"_trp_automatically_translated_slug_es_ES":["como-cambiar-las-cadenas-de-texto-de-anadir-al-carrito"],"_wp_old_slug":["how-to-change-add-to-cart-text-strings"],"rank_math_og_content_image":["a:2:{s:5:\"check\";s:32:\"daec5ed1f051f34c4f58f45cb07b60ea\";s:6:\"images\";a:1:{i:0;i:174614;}}"],"pfd_related_docs":[""],"_uag_page_assets":["a:9:{s:3:\"css\";s:2495:\".wp-block-uagb-container.uagb-block-debf2792 .uagb-container__shape-top svg{width: calc( 100% + 1.3px );}.wp-block-uagb-container.uagb-block-debf2792 .uagb-container__shape.uagb-container__shape-top .uagb-container__shape-fill{fill: rgba(51,51,51,1);}.wp-block-uagb-container.uagb-block-debf2792 .uagb-container__shape-bottom svg{width: calc( 100% + 1.3px );}.wp-block-uagb-container.uagb-block-debf2792 .uagb-container__shape.uagb-container__shape-bottom .uagb-container__shape-fill{fill: rgba(51,51,51,1);}.wp-block-uagb-container.uagb-block-debf2792 .uagb-container__video-wrap video{opacity: 1;}.wp-block-uagb-container.uagb-is-root-container .uagb-block-debf2792{max-width: 100%;width: 100%;}.wp-block-uagb-container.uagb-is-root-container.alignfull.uagb-block-debf2792 > .uagb-container-inner-blocks-wrap{--inner-content-custom-width: min( 100%, 1200px);max-width: var(--inner-content-custom-width);width: 100%;flex-direction: column;align-items: center;justify-content: center;flex-wrap: nowrap;row-gap: 0px;column-gap: 0px;}.wp-block-uagb-container.uagb-block-debf2792{box-shadow: 0px 0px   #00000070 ;padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;margin-top: 0px !important;margin-bottom: 0px !important;margin-left: 0px;margin-right: 0px;overflow: visible;border-color: inherit;row-gap: 0px;column-gap: 0px;}@media only screen and (max-width: 976px) {.wp-block-uagb-container.uagb-is-root-container .uagb-block-debf2792{width: 100%;}.wp-block-uagb-container.uagb-is-root-container.alignfull.uagb-block-debf2792 > .uagb-container-inner-blocks-wrap{--inner-content-custom-width: min( 100%, 1024px);max-width: var(--inner-content-custom-width);width: 100%;}.wp-block-uagb-container.uagb-block-debf2792{padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;margin-top: 0px !important;margin-bottom: 0px !important;margin-left: 0px;margin-right: 0px;}}@media only screen and (max-width: 767px) {.wp-block-uagb-container.uagb-is-root-container .uagb-block-debf2792{max-width: 100%;width: 100%;}.wp-block-uagb-container.uagb-is-root-container.alignfull.uagb-block-debf2792 > .uagb-container-inner-blocks-wrap{--inner-content-custom-width: min( 100%, 767px);max-width: var(--inner-content-custom-width);width: 100%;flex-wrap: wrap;}.wp-block-uagb-container.uagb-block-debf2792{padding-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;margin-top: 0px !important;margin-bottom: 0px !important;margin-left: 0px;margin-right: 0px;}}\";s:2:\"js\";s:0:\"\";s:18:\"current_block_list\";a:6:{i:0;s:14:\"core\/paragraph\";i:1;s:12:\"core\/heading\";i:2;s:9:\"core\/code\";i:3;s:10:\"core\/image\";i:4;s:14:\"uagb\/container\";i:5;s:14:\"core\/shortcode\";}s:8:\"uag_flag\";b:1;s:11:\"uag_version\";s:10:\"1776537195\";s:6:\"gfonts\";a:0:{}s:10:\"gfonts_url\";s:0:\"\";s:12:\"gfonts_files\";a:0:{}s:14:\"uag_faq_layout\";b:0;}"]},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"trp-custom-language-flag":false},"uagb_author_info":{"display_name":"mounikak","author_link":"https:\/\/git-staging.wpastra.com\/es\/author\/mounikak\/"},"uagb_comment_info":0,"uagb_excerpt":"You can change the default text strings &#8220;Add to Cart&#8221; to &#8220;Buy Now&#8221; on your WooCommerce single product page and product archive (collection) page. To do so, you can use the filters attached in this document. To know more about how to use these filter, go through the below sections of this document. How to&hellip;","_links":{"self":[{"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/docs\/174609"}],"collection":[{"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/users\/89"}],"replies":[{"embeddable":true,"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/comments?post=174609"}],"version-history":[{"count":0,"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/docs\/174609\/revisions"}],"wp:attachment":[{"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/media?parent=174609"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/docs_category?post=174609"},{"taxonomy":"docs_tag","embeddable":true,"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/docs_tag?post=174609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}