Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Balakrishnan-flycart/9d612da50fce407802f2daa4237c684f to your computer and use it in GitHub Desktop.
Save Balakrishnan-flycart/9d612da50fce407802f2daa4237c684f to your computer and use it in GitHub Desktop.
Discount Rules V2: Sale badge compatible with sober theme
if (!function_exists('woo_discount_rules_sober_product_ribbons')) {
function woo_discount_rules_sober_product_ribbons($output, $product){
if(empty($output['onsale'])){
if ( $product->is_on_sale() ) {
$output['onsale'] = '<span class="onsale ribbon">Special Sale</span>';
}
} else {
$product_id = $product->get_id();
if(class_exists('\Wdr\App\Controllers\ManageDiscount')){
$isProductOnSale = Wdr\App\Controllers\ManageDiscount::isProductOnSale($product_id);
if($isProductOnSale){
$output['onsale'] = '<span class="onsale ribbon">Special Sale</span>';
}
}
}
return $output;
}
}
add_filter('sober_product_ribbons', 'woo_discount_rules_sober_product_ribbons', 100, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment