Created
July 3, 2024 06:04
-
-
Save AnanthFlycart/1e77eea692cc7063b963805c76bf5c69 to your computer and use it in GitHub Desktop.
UpsellWP: Show fixed discount price without trimming zeros
This file contains hidden or 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
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