Hello Ali,
Thank you very much for your great plugin. There is some issue with how WC 8 handles decimal values, so your Plugin doesnt work if the cost of flat rate shipping is for example 9,99 and it would change this value to 9,00.
Here is the fix I applied, for you to look into updating the plugin but also for users having this exact issue:
]]>## Changes to improve decimal handling in shipping discounts
File:wp-content/plugins/shipping-discount/includes/classes/class-shippingdiscount.php
In theoverride_shipping_price
method:
1. Replace all instances of manual price formatting withwc_format_decimal()
:
-$shipping_before_discount = wc_format_decimal($rate->cost, wc_get_price_decimals());
-$coupon_amount = wc_format_decimal($coupon->get_amount(), wc_get_price_decimals());
-$max_amount = wc_format_decimal($coupon->get_meta('shipping_discount_max_amount'), wc_get_price_decimals());
2. Update the check for minimum max_amount:
- From:if (!is_numeric($max_amount) || $max_amount < 1)
- To:if (!is_numeric($max_amount) || $max_amount < 0.01)
3. Usewc_format_decimal()
for the final cost:
-$rate->cost = wc_format_decimal($cost, wc_get_price_decimals());
4. Remove any custom price parsing or formatting methods (if they exist):
- Deleteparse_price()
method
- Deleteformat_price()
method
These changes ensure that the plugin uses WooCommerce's built-in decimal handling functions, which respect the store's currency settings and provide consistent formatting across different currency configurations.
Hello
Any tips for hiding or blocking the most expensive delivery method (or all the most expensive ones), leaving only the cheapest one marked that had the discount applied on the coupon by default?
Hi!
I have a problem with the VAT. It seems like the plugin is not calculating the old shipping cost with the VAT? Since when I apply the coupon it changes the originally shipping cost.
Hello, thank you for offering this plugin completely free of charge. I would like to know if this plugin captures the value of the delivery method chosen by the customer and applies the discount, maintaining the delivery time?
]]>