Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save AnanthFlycart/b79649dca0f6466fb8425d422d6b6d18 to your computer and use it in GitHub Desktop.

Select an option

Save AnanthFlycart/b79649dca0f6466fb8425d422d6b6d18 to your computer and use it in GitHub Desktop.
CUW: Remove offer quantity when product is digital
add_filter('cuw_offer_template_product_quantity', function ($html, $offer) {
if (!empty($offer['id']) && !empty($offer['product']['id']) && function_exists('wc_get_product')) {
$product = wc_get_product($offer['product']['id']);
if (!empty($product) && ($product->is_virtual() || $product->is_downloadable())) {
$html = '<input type="hidden" name="quantity" value="1"/>';
}
}
return $html;
}, 100, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment