Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WOOCOMMERCE: Remove “Add to cart” Button from product page?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #42604
    asiek
    Participant

    I opened up these files to try and edit out the Add to cart button//
    add-to-cart.php and content-product.php
    But I am clueless on how to remove the php function so the button is no longer displayed on the main products page.
    I’d only like the button there when a customer is on the product’s single page…

    Can anyone help me find the correct file to remove the button?
    Please!

    #262288
    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);

    }`

    #262501
    alexanderbiscajin
    Participant

    For reference you can view the details here : https://www.wpblog.com/add-to-cart-button-in-woocommerce-store/

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.