-1

if short: i have product with 0 price and i don't want it to be added to the cart.

if longer: i'm creating composite product (i can't use 'grouped product' option, because one of my items is variative). Every item of this product should be sold separately. But i have to set regular price for product in order to display it. And this regular price, of course, adds to the cart. So i decided to set price to 0 and now i have normal total price in the cart and one needless position..

I think it could be resolved by adding some simple condition for price before loop in cart function, but i'm almost zero in php :(

1 Answers1

2

Possible solution:

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