Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AnanthFlycart/1e77eea692cc7063b963805c76bf5c69 to your computer and use it in GitHub Desktop.
Save AnanthFlycart/1e77eea692cc7063b963805c76bf5c69 to your computer and use it in GitHub Desktop.
UpsellWP: Show fixed discount price without trimming zeros
add_filter('cuw_discount_text', function ($text, $product, $discount, $display_in) {
if (!empty($discount['type']) && $discount['type'] == 'fixed_price' && is_numeric($discount['value'])) {
if (method_exists('\CUW\App\Helpers\WC', 'getPriceToDisplay') && method_exists('\CUW\App\Helpers\WC', 'formatPriceRaw')) {
$price = apply_filters('cuw_convert_price', $discount['value'], 'fixed_price');
$price = \CUW\App\Helpers\WC::getPriceToDisplay($product, $price, 1, $display_in);
$text = html_entity_decode(\CUW\App\Helpers\WC::formatPriceRaw($price));
}
}
return $text;
}, 100, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment