Skip to content

Instantly share code, notes, and snippets.

@shubhw12
Last active July 29, 2023 13:20
Show Gist options
  • Select an option

  • Save shubhw12/76d901d5cc18e304f737cf7b4c83a0f7 to your computer and use it in GitHub Desktop.

Select an option

Save shubhw12/76d901d5cc18e304f737cf7b4c83a0f7 to your computer and use it in GitHub Desktop.
Remove add to cart button in astra theme.
//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;
}
@ranjan967

Copy link
Copy Markdown

thanks working fine

@mle1989972

Copy link
Copy Markdown

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