Arnold Oosterom
Arnold Oosterom

Reputation: 127

Text as a price in Woocommerce

I have a recent Woocommerce installation and i'm trying to create a way when there is no price in the backend, Woocommerce automatically makes the price "Prijs op aanvraag" But when using the following code in my function.php:

add_filter('woocommerce_empty_price_html', 'custom_call_for_price');

function custom_call_for_price() {
 return 'Prijs op aanvraag';
}     

But now i can't add it to my cart anymore? Can anyone give me a idea or plugin how to make this work?

Thanks!

Upvotes: 1

Views: 585

Answers (1)

Rohil_PHPBeginner
Rohil_PHPBeginner

Reputation: 6080

Try following:

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

Above code will add Add to cart button.

NOTE : It will consider 0.00 as a price.

Upvotes: 1

Related Questions