Last active
July 29, 2023 13:20
-
-
Save shubhw12/76d901d5cc18e304f737cf7b4c83a0f7 to your computer and use it in GitHub Desktop.
Remove add to cart button in astra theme.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Remove add to cart from shop page. | |
| add_filter('astra_woo_shop_product_structure' , 'call_back_add_to_cart_shop'); | |
| //Remove add to cart from single product page. | |
| add_filter( 'astra_woo_single_product_structure' , 'call_back_add_to_cart' ); | |
| function call_back_add_to_cart_shop(){ | |
| $structure = astra_get_option( 'shop-product-structure' ); | |
| $add_to_cart_key = array_search('add_cart', $structure); | |
| unset($structure[$add_to_cart_key]); | |
| return $structure; | |
| } | |
| function call_back_add_to_cart(){ | |
| $structure = astra_get_option( 'single-product-structure' ); | |
| $add_to_cart_key = array_search('add_cart', $structure); | |
| unset($structure[$add_to_cart_key]); | |
| return $structure; | |
| } |
Hi,
Your code works very well however, how to remove only the add to cart block in the product page only to certain products and not to all, while using the Astra theme and Woocommerce.
Thanks for your reply.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks working fine