Disable "Add to basket" button for price zero


/ Published in: PHP
Save to your folder(s)

Disable "Add to basket" button for price zero


Copy this code and paste it in your HTML
  1. // Disable Add to basket button for prise zero.
  2. function custom_woocommerce_is_purchasable( $purchasable, $product ){
  3. if( $product->get_price() == 0 || $product->get_price() == '')
  4. $purchasable = false;
  5. return $purchasable;
  6. }
  7. add_filter( 'woocommerce_is_purchasable', 'custom_woocommerce_is_purchasable', 10, 2 );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.