Skip to content

Instantly share code, notes, and snippets.

@kreamweb
Created May 22, 2017 10:30
Show Gist options
  • Select an option

  • Save kreamweb/e000817c857d2704497637257a9fc9f1 to your computer and use it in GitHub Desktop.

Select an option

Save kreamweb/e000817c857d2704497637257a9fc9f1 to your computer and use it in GitHub Desktop.
This code removes all products that are on sale at the moment of creation of coupon.
<?php
add_filter('ywrac_coupon_args','ywrac_coupon_args');
function ywrac_coupon_args( $args ){
$product_on_sale = wc_get_product_ids_on_sale();
if( is_array( $product_on_sale) && !empty( $product_on_sale ) ){
$args['exclude_product_ids'] = implode( ',', $product_on_sale );
}
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment