• Resolved chuwen

    (@chuwen)


    Hi @algoritmika @anbinde,

    I have tried to install and test the plugin on my site. It works fine by displaying ‘Call for Price’ for the product with no price. However, it still show ‘Add to Cart’ function for the product with no price at the same time. It should be disable ‘Add to Cart’ function especially for the product with no price.

    FYI it was displayed ‘Add to Cart’ function on the product page (not single product page).

    Kindly help me to solve it if you have any solutions.

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @chuwen,

    By default in WooCommerce (i.e. even without installing our plugin) – if product has no price, then add to cart button is hidden on single product page and on archives it’s replaced with “Read more” button (i.e. instead of “Add to cart” button). So if you still have “Add to cart” on archives, I’m thinking it’s either some other plugin or your theme. By the way what happens when you click that “Add to cart” button – I suppose it then goes to single product page, or is it adding product to the cart with zero price (in this case I would suggest re-checking if you have set empty and not zero price). Also which product types are you testing with (i.e. is it simple product or variable product)?

    Hi again @chuwen,

    I’ve just realized that we already have option in plugin that may help you. Please try enabling “Hide button” option in “WooCommerce > Settings > Call for Price > General > Button Options”. It should hide “Read more” button for “Call for Price” products on archives, so hopefully it will also hide “Add to cart” button in your case.

    Hope that helps.

    immi2

    (@immi2)

    https://gist.github.com/nickburne/192609fedc540654fd9b#file-gistfile1-txt

    how to remove add to cart kick to westbasket WTF!!

    now i used how to kick off add to cart.
    good luck lady.

    Replace add to cart button with button to product page – WooCommerce

    gistfile1.txt
    /*PUT THIS IN YOUR CHILD THEME FUNCTIONS FILE*/

    /*STEP 1 – REMOVE ADD TO CART BUTTON ON PRODUCT ARCHIVE (SHOP) */

    function remove_loop_button(){
    remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 10 );
    }
    add_action(‘init’,’remove_loop_button’);

    /*STEP 2 -ADD NEW BUTTON THAT LINKS TO PRODUCT PAGE FOR EACH PRODUCT */

    add_action(‘woocommerce_after_shop_loop_item’,’replace_add_to_cart’);
    function replace_add_to_cart() {
    global $product;
    $link = $product->get_permalink();
    echo do_shortcode(‘<br>[button link=”‘ . esc_attr($link) . ‘”]Read more[/button]’);
    }

    komal-maru

    (@komal-maru)

    Hi @immi2,

    Thank you for sharing the solution with us.

    The provided code will replace the ‘Add to Cart’ button with the ‘Read more’ button when the price is set to blank for the product on the shop page.

    Currently, this is the default functionality in WooCommerce for products on archives.

    Please let me know if I misunderstood your requirement which you want to achieve.

    Regards,
    Komal Maru

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to Remove Add to Cart Function’ is closed to new replies.