Last active
July 7, 2020 07:48
-
-
Save Balakrishnan-flycart/9d612da50fce407802f2daa4237c684f to your computer and use it in GitHub Desktop.
Discount Rules V2: Sale badge compatible with sober theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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