Skip to main content

Forums

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #262289
    alexanderbiscajin
    Participant

    Hide add to cart from shop page. You can add this code in woocommerce.php (located wp-content/plugins/woocommerce):

    `function WpBlog() {

    remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’);

    remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’);

    return WooCommerce::instance();

    }`

    And for the specific product pages add the code in functions.php

    `add_filter(‘woocommerce_is_purchasable’, ‘wpblog_specific_product’);

    function wpblog_specific_product($purchaseable_product_wpblog, $product)
    {
    return ($product->id == specific_product_id (512) ? false : $purchaseable_product_wpblog);

    }`

    Reference : https://www.wpblog.com/add-to-cart-button-in-woocommerce-store/

    #287003
    iThemesforests
    Participant

    So, to remove add to cart button from product detail page and shop page i.e. product listing page all we need to do is to add these two hooks.

    remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’);
    remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 30 );
    We can place this code in any place where it should be appropriate.

    This could also be done with CSS by targeting the relevant classes:

    .cart{display:none;}

    Another example is:

    .woocommerce .products .shop-column.product-hover-style-2 .product-content
    .product-add-to-cart-btn{
    display:none !important;
    }

    Reference : https://www.ithemesforests.com/how-to-hide-or-remove-add-to-cart-button-in-woocommerce/

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.