Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1063373

    Dear team,
    I am setting up a new site with Enfold – which I appreciate more & more for the theme’s flexibility & options to tweak.
    Right now though I am getting quite frustrated with the difficulties we are experiencing making woocommerce work the way we need it to…. Not sure, but it seems that this issue might require a different approach when using Enfold? None of the solutions I found on the net (i.e. ” add remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); to functions.php) worked .
    We would like to
    HIDE ‘add to cart’ on the categorie page
    HIDE ‘add to cart’ on the shop page
    SHOW ‘add to cart’ on the product page
    What am I missing?
    Thanks for your support.

    #1063440

    Hey Maike,
    Please try going to Enfold Theme Options > Shop > Product layout on overview pages and choose “Default without buttons” or “Minimal (no borders or buttons)” both of these options hide the “add to cart” buttons except on the product pages.
    2019-02-05-211846

    Best regards,
    Mike

    #1063567

    Hi Mike,
    thanks – yes, you’re right – that should fix it… and does, if I dump the changes I made to display the size info on the shop page (which is a request from the client).
    To be able to show size info (=variations) of the product on the shop & category page as well as the product page I have set up content-product.php in a child them folder with the following code (which works great for displaying the variations on all pages, but is obviously responsible for my inability to hide the “add to cart” button on the achive / category pages mentioned before):

    <?php
    /**
     * The template for displaying product content within loops
     *
     * This template can be overridden by copying it to yourtheme/woocommerce/content-product.php.
     *
     * HOWEVER, on occasion WooCommerce will need to update template files and you
     * (the theme developer) will need to copy the new files to your theme to
     * maintain compatibility. We try to do this as little as possible, but it does
     * happen. When this occurs the version of the template file will be bumped and
     * the readme will list any important changes.
     *
     * @see     https://docs.woocommerce.com/document/template-structure/
     * @package WooCommerce/Templates
     * @version 3.4.0
     */
    
    defined( 'ABSPATH' ) || exit;
    
    global $product;
    
    // Ensure visibility.
    if ( empty( $product ) || ! $product->is_visible() ) {
    	return;
    }
    ?>
    <li <?php wc_product_class(); ?>>
    	<?php
    	/**
    	 * Hook: woocommerce_before_shop_loop_item.
    	 *
    	 * @hooked woocommerce_template_loop_product_link_open - 10
    	 */
    	do_action( 'woocommerce_before_shop_loop_item' );
    
    	/**
    	 * Hook: woocommerce_before_shop_loop_item_title.
    	 *
    	 * @hooked woocommerce_show_product_loop_sale_flash - 10
    	 * @hooked woocommerce_template_loop_product_thumbnail - 10
    	 */
    	do_action( 'woocommerce_before_shop_loop_item_title' );
    
    	/**
    	 * Hook: woocommerce_shop_loop_item_title.
    	 *
    	 * @hooked woocommerce_template_loop_product_title - 10
    	 */
    	do_action( 'woocommerce_shop_loop_item_title' );
    
    	/**
    	 * Hook: woocommerce_after_shop_loop_item_title.
    	 *
    	 * @hooked woocommerce_template_loop_rating - 5
    	 * @hooked woocommerce_template_loop_price - 10
    	 */
    	do_action( 'woocommerce_after_shop_loop_item_title' ); 
    
    	/**
    	 * Hook: woocommerce_after_shop_loop_item.
    	 *
    	 * @hooked woocommerce_template_loop_product_link_close - 5
    	 * @hooked woocommerce_template_loop_add_to_cart - 10
    	 */
    	remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
    do_action( 'woocommerce_single_product_summary' );
    	?>
    </li>
    

    Questions: Would there be a better way to do this?
    Or: Can I keep on using this tweak, but get rid of a part of the code?

    #1063614

    Hi,
    In this case, please try this code in the General Styling > Quick CSS field or in the WordPress > Customize > Additional CSS field:

    #top.archive button.single_add_to_cart_button {
    display: none !important;
    }

    Best regards,
    Mike

    #1063673

    YES! Works. Thanks a lot, Mike.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Disable 'Add to Cart' Button on Shop & Category Pages, Display on Product Page’ is closed to new replies.