Support » Plugin: WooCommerce » Display 'Add to Cart' button on product without price

  • Dear support,

    Some of the products in my store are priceless, and I would like to keep it that way. The only problem is that the ‘Add to Cart’ button doesn’t show up on a pricesless product, while I would like it to show. Giving the product a price of €0,- is not an option for me unfortunately. I googled the heck out of it cause it seemed like a pretty basic request. But the only thing turning up unfortunately is how to remove the ‘Add to Cart’ button :P.

    Kind regards,

Viewing 4 replies - 1 through 4 (of 4 total)
  • To specify it further, this is only needed for the .single_add_to_cart_button, not for variable products etcetera (hope this makes it easier).

    Kind regards,

    what exactly do you want; by using “priceless product” and “product price of $0.0 is not an option” in the same description?!?!

    Do you want to offer some “FREE” products? As a gift or some discount option?!?
    Or what do you expect from customers to do with such a product, just adding it into the cart, but not buying it?

    in the file “class-wc-shortcodes.php” (it’s in the includes folder)
    change the line 491 “‘show_price’ => ‘true'”
    from “true” to “false”

    Hi @ormagon, i bet you want to show “Add to Cart” button although the price of product is 0 or empty, right.

    You can put this in your theme’s functions.php:

    function custom_woocommerce_is_purchasable( $purchasable, $product ){
        if( $product->get_price() == 0 ||  $product->get_price() == '')
            $purchasable = true;
        return $purchasable;
    add_filter( 'woocommerce_is_purchasable', 'custom_woocommerce_is_purchasable', 10, 2 );

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display 'Add to Cart' button on product without price’ is closed to new replies.