{"id":170146,"date":"2023-12-25T15:51:24","date_gmt":"2023-12-25T10:21:24","guid":{"rendered":"https:\/\/git-staging.wpastra.com\/?post_type=docs&#038;p=170146"},"modified":"2023-12-25T16:12:07","modified_gmt":"2023-12-25T10:42:07","slug":"hide-price-and-add-to-cart","status":"publish","type":"docs","link":"https:\/\/git-staging.wpastra.com\/es\/docs\/hide-price-and-add-to-cart\/","title":{"rendered":"C\u00f3mo ocultar el precio y a\u00f1adir a la cesta para los usuarios desconectados en Astra Theme"},"content":{"rendered":"<p>Esta gu\u00eda proporciona instrucciones paso a paso sobre c\u00f3mo ocultar los \"Precios de los productos\" y el bot\u00f3n \"A\u00f1adir al carro\" para los usuarios que no han iniciado sesi\u00f3n en un sitio WordPress que utiliza el tema Astra.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2023\/12\/word-image-170146-1.png\"><img decoding=\"async\" src=\"https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2023\/12\/word-image-170146-1.png\" alt=\"How to Hide Price &amp; Add to Cart for Logged Out Users in Astra Theme\"\/><\/a><\/figure>\n\n\n\n<p>Para ello, a\u00f1ada un fragmento de c\u00f3digo personalizado a la p\u00e1gina del tema hijo <strong>funciones.php<\/strong> o utilizando <a href=\"https:\/\/git-staging.wpastra.com\/es\/docs\/custom-layout-hooks\/\">Astra Pro Ganchos de dise\u00f1o personalizados<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-170146-_vm4jw6ronlcc\"><\/a><strong>C\u00f3mo ocultar el precio y a\u00f1adir a la cesta para los usuarios desconectados en Astra Theme<\/strong><\/h3>\n\n\n\n<p>Antes de continuar, aseg\u00farese de que se cumplen los siguientes requisitos:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>WordPress est\u00e1 instalado y activado.<\/li>\n\n\n\n<li>El tema Astra est\u00e1 instalado y activado.<\/li>\n\n\n\n<li>Se configura un tema hijo (recomendado para realizar personalizaciones de c\u00f3digo).<\/li>\n<\/ul>\n\n\n\n<p>Este es el fragmento de c\u00f3digo que se utilizar\u00e1 para ocultar los precios y el <strong>A\u00f1adir a la cesta<\/strong> para usuarios desconectados:<\/p>\n\n\n\n<pre class=\"wp-block-code\" data-no-translation=\"\" data-no-auto-translation=\"\"><code>add_filter( 'woocommerce_get_price_html', 'astra_hide_price_addcart_not_logged_in', 9999, 2 );\n\nfunction astra_hide_price_addcart_not_logged_in( $price, $product ) {\n   if ( ! is_user_logged_in() ) { \n      $price = '&lt;div&gt;&lt;a href=\"' . get_permalink( wc_get_page_id( 'myaccount' ) ) . '\"&gt;' . __( 'Login to see prices', 'astra' ) . '&lt;\/a&gt;&lt;\/div&gt;';\n      remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );\n      remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );\n      add_filter( 'woocommerce_is_purchasable', '__return_false' );\n   }\n   return $price;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-170146-_g0noluhrw1pl\"><\/a><strong>M\u00e9todos de aplicaci\u00f3n<\/strong><\/h3>\n\n\n\n<p>Siga los siguientes pasos para implementar el fragmento de c\u00f3digo:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><a id=\"post-170146-_bgzjeh1gbk4m\"><\/a><strong>M\u00e9todo 1: Uso de Child Theme Functions.php<\/strong><\/h4>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Abra el sistema de archivos de su sitio WordPress.<\/li>\n\n\n\n<li>Vaya al directorio wp-content\/themes\/your-child-theme\/.<\/li>\n\n\n\n<li>Localice y edite el archivo functions.php utilizando un editor de texto.<\/li>\n\n\n\n<li>Copie y pegue el fragmento de c\u00f3digo proporcionado al final del archivo.<\/li>\n\n\n\n<li>Guarde el archivo pulsando el bot\u00f3n \"Actualizar archivo\".<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"449\" src=\"https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2023\/12\/astra-child-1-1024x449.png\" alt=\"How to Hide Price &amp; Add to Cart for Logged Out Users in Astra Theme\" class=\"wp-image-170156\" srcset=\"https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2023\/12\/astra-child-1-1024x449.png 1024w, https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2023\/12\/astra-child-1-300x132.png 300w, https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2023\/12\/astra-child-1-768x337.png 768w, https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2023\/12\/astra-child-1-1536x674.png 1536w, https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2023\/12\/astra-child-1-18x8.png 18w, https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2023\/12\/astra-child-1.png 1896w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><a id=\"post-170146-_b6klsglj9p6l\"><\/a><strong>M\u00e9todo 2: Utilizar ganchos de dise\u00f1o personalizados Astra Pro<\/strong><\/h4>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Vaya a su panel de administraci\u00f3n de WordPress.<\/li>\n\n\n\n<li>Vaya a <strong>Astra <\/strong>&gt; <strong>Constructor del sitio<\/strong>.<\/li>\n\n\n\n<li>Seleccione la ubicaci\u00f3n adecuada en la que desea aplicar la personalizaci\u00f3n (por ejemplo, Producto \u00fanico, P\u00e1gina de la tienda).<\/li>\n\n\n\n<li>Haga clic en <strong>A\u00f1adir nuevo dise\u00f1o<\/strong> o editar uno ya existente.<\/li>\n\n\n\n<li>Cambiar a la <strong>Ganchos <\/strong>ficha.<\/li>\n\n\n\n<li>Pegue el fragmento de c\u00f3digo en el campo <strong>Antes del contenido<\/strong> o <strong>Despu\u00e9s del contenido<\/strong> campo.<\/li>\n\n\n\n<li>Guarda los cambios.<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-uagb-inline-notice uagb-inline_notice__align-left uagb-block-6cadcf48\"><button class=\"uagb-notice-close-button\" type=\"button\" aria-label=\"Cerrar\"><\/button><h4 class=\"uagb-notice-title\">Nota:<\/h4><div class=\"uagb-notice-text\">Aqu\u00ed est\u00e1 el documento para saber m\u00e1s sobre el m\u00f3dulo Hooks: <a href=\"https:\/\/git-staging.wpastra.com\/es\/docs\/custom-layout-hooks\/\">Astra Pro Ganchos de dise\u00f1o personalizados<\/a>.<\/div><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Para asegurarse de que la personalizaci\u00f3n funciona seg\u00fan lo previsto, cierre la sesi\u00f3n de su sitio de WordPress y vaya a una p\u00e1gina de producto o a la p\u00e1gina de la tienda. Compruebe que los precios est\u00e1n ocultos y que el bot\u00f3n A\u00f1adir a la cesta no est\u00e1 visible. Haga clic en el enlace proporcionado, que deber\u00eda redirigirle a la p\u00e1gina de inicio de sesi\u00f3n. <\/p>\n\n\n\n<p>Si un usuario no est\u00e1 conectado, aparecer\u00e1 un nuevo mensaje pidi\u00e9ndole que se conecte para ver los precios. Este proceso ayuda a confirmar que los cambios implementados funcionan como se esperaba.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2023\/12\/word-image-170146-1.png\"><img decoding=\"async\" width=\"965\" height=\"675\" src=\"https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2023\/12\/word-image-170146-1.png\" alt=\"How to Hide Price &amp; Add to Cart for Logged Out Users in Astra Theme\" class=\"wp-image-170148\" srcset=\"https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2023\/12\/word-image-170146-1.png 965w, https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2023\/12\/word-image-170146-1-300x210.png 300w, https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2023\/12\/word-image-170146-1-768x537.png 768w, https:\/\/git-staging.wpastra.com\/wp-content\/uploads\/2023\/12\/word-image-170146-1-18x12.png 18w\" sizes=\"(max-width: 965px) 100vw, 965px\" \/><\/a><\/figure>\n\n\n\n<p>Esperamos que este documento le haya sido \u00fatil. Si tiene alguna duda, no dude en dejarnos un comentario a continuaci\u00f3n.<\/p>","protected":false},"excerpt":{"rendered":"<p>Esta gu\u00eda proporciona instrucciones paso a paso sobre c\u00f3mo ocultar los \"Precios de los productos\" y el bot\u00f3n \"A\u00f1adir al carrito\" para los usuarios que no han iniciado sesi\u00f3n en un sitio WordPress que utiliza el tema Astra. Puede conseguirlo a\u00f1adiendo un fragmento de c\u00f3digo personalizado al archivo functions.php del tema hijo o utilizando los ganchos de dise\u00f1o personalizados de Astra Pro. [...]<\/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-170146","1":"docs","2":"type-docs","3":"status-publish","5":"docs_category-woocommerce-filters"},"spectra_custom_meta":{"_edit_lock":["1703566081:89"],"rank_math_primary_docs_category":["2112"],"rank_math_seo_score":["19"],"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"],"_edit_last":["89"],"tap_disable_autolinker":["no"],"tap_autolink_inside_heading":["global"],"tap_autolink_random_placement":["global"],"tap_post_autolinker_limit":["0"],"_trp_automatically_translated_slug_es_ES":["ocultar-el-precio-de-anadir-a-la-cesta-para-los-usuarios-desconectados"],"views":["7034"],"rank_math_og_content_image":["a:2:{s:5:\"check\";s:32:\"707e30ca4000db9e924c93253aa6b5b9\";s:6:\"images\";a:1:{i:0;i:170148;}}"],"_wp_old_slug":["hide-price-add-to-cart-for-logged-out-users","hide-price-add-to-cart"],"pfd_related_docs":[""],"helpful":["0"],"unhelpful":["0"],"redirects":["1"],"_uag_page_assets":["a:9:{s:3:\"css\";s:3704:\" .uagb-block-6cadcf48.wp-block-uagb-inline-notice .uagb-notice-title{padding-left: 15px;padding-right: 15px;padding-top: 15px;padding-bottom: 15px;} .uagb-block-6cadcf48 .uagb-notice-text{padding-left: 15px;padding-right: 15px;padding-top: 15px;padding-bottom: 15px;border: 2px solid #FFD54F;border-bottom-left-radius: 3px;border-bottom-right-radius: 3px;} .uagb-block-6cadcf48.uagb-dismissable button[type=\"button\"] svg{width: 16px;height: 16px;} .uagb-block-6cadcf48.uagb-dismissable > svg{width: 16px;height: 16px;} .uagb-block-6cadcf48 .uagb-notice-title{background-color: #FFD54F;border-top-right-radius: 3px;border-top-left-radius: 3px;}@media only screen and (max-width: 976px) { .uagb-block-6cadcf48 .uagb-notice-text{padding-left: 15px;padding-right: 15px;padding-top: 15px;padding-bottom: 15px;} .uagb-block-6cadcf48 .uagb-notice-title{padding-left: 15px;padding-right: 15px;padding-top: 15px;padding-bottom: 15px;}}@media only screen and (max-width: 767px) { .uagb-block-6cadcf48 .uagb-notice-text{padding-left: 15px;padding-right: 15px;padding-top: 15px;padding-bottom: 15px;} .uagb-block-6cadcf48 .uagb-notice-title{padding-left: 15px;padding-right: 15px;padding-top: 15px;padding-bottom: 15px;}}.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:271:\"document.addEventListener(\"DOMContentLoaded\", function(){ window.addEventListener( 'DOMContentLoaded', function() {\n\tUAGBInlineNotice.init( {\"c_id\":null,\"cookies\":false,\"close_cookie_days\":1,\"noticeDismiss\":\"\",\"icon\":\"rectangle-xmark\"}, '.uagb-block-6cadcf48' );\n});\n });\";s:18:\"current_block_list\";a:9:{i:0;s:14:\"core\/paragraph\";i:1;s:10:\"core\/image\";i:2;s:12:\"core\/heading\";i:3;s:9:\"core\/list\";i:4;s:14:\"core\/list-item\";i:5;s:9:\"core\/code\";i:6;s:18:\"uagb\/inline-notice\";i:7;s:14:\"uagb\/container\";i:8;s:14:\"core\/shortcode\";}s:8:\"uag_flag\";b:1;s:11:\"uag_version\";s:10:\"1776561882\";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":"This guide provides step-by-step instructions on how to hide \u201cProduct Prices\u201d and the \u201cAdd to Cart\u201d button for users who are not logged in on a WordPress site using the Astra theme. You can accomplish this by adding a custom code snippet to the child theme&#8217;s functions.php file or using Astra Pro Custom Layouts Hooks.&hellip;","_links":{"self":[{"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/docs\/170146"}],"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=170146"}],"version-history":[{"count":0,"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/docs\/170146\/revisions"}],"wp:attachment":[{"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/media?parent=170146"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/docs_category?post=170146"},{"taxonomy":"docs_tag","embeddable":true,"href":"https:\/\/git-staging.wpastra.com\/es\/wp-json\/wp\/v2\/docs_tag?post=170146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}