Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AshlinRejo/c8863a8a302cec68abc2118f3a2ef0f0 to your computer and use it in GitHub Desktop.
Save AshlinRejo/c8863a8a302cec68abc2118f3a2ef0f0 to your computer and use it in GitHub Desktop.
Discount rules v2: Change priority of variable strikeout and display only minimum price
add_action('advanced_woo_discount_rules_after_initialize', function() {
if(class_exists('\Wdr\App\Router')){
remove_filter('woocommerce_variable_price_html', array(\Wdr\App\Router::$manage_discount, 'getVariablePriceHtml'), 100);
add_filter('woocommerce_variable_price_html', array(\Wdr\App\Router::$manage_discount, 'getVariablePriceHtml'), 10000, 2);
}
});
add_filter('advanced_woo_discount_rules_strikeout_price_html', function($html, $original_price, $discounted_price, $is_variable_product){
if($is_variable_product){
return "Fr: " .str_replace("<br>", '&nbsp;', $html);
} else {
return $html;
}
}, 10, 4);
add_filter('advanced_woo_discount_rules_format_sale_price_range', function($html, $min_price, $max_price, $original_html){
return wc_price($min_price);
}, 10, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment