WPprodigy / woocommerce-product-fees

Add additional fees at checkout based on products that are in the cart.
https://wordpress.org/plugins/woocommerce-product-fees/
Other
26 stars 19 forks source link

0,00 numbers not working #46

Closed kleinermann closed 4 years ago

kleinermann commented 5 years ago

Numbers like 0,13 don't show up in the cart. A fix for this has been posted here: https://wordpress.org/support/topic/not-work-with-0000xxx-product-fees/ Any chance to add this fix to the project?

Majklas commented 5 years ago

Found in another forum:

This solution seem working.

file class-woocommerce-product-fees.php

line 52 must be: if ( ” !== $fee_name && ” !== $fee_amount && $fee_amount >= 0 ) {

difference is “the greater than or equal to” comparison operator. Original one was only the major.

WPprodigy commented 4 years ago

Related https://github.com/WPprodigy/woocommerce-product-fees/issues/39

The "proper" fix is actually switching out the decimal separator: $fee_amount = str_replace( wc_get_price_decimal_separator(), '.', get_post_meta( $id, 'product-fee-amount', true ) );.

The only reason it currently works is because of PHP's type switching 🙃


'1,5' > 0  //true
'0,5' > 0 // false

'1.5' > 0 // true
'0.5' > 0 // true
WPprodigy commented 4 years ago

Fixed in https://github.com/WPprodigy/woocommerce-product-fees/commit/5b1c364a27126397587b662354cd277888387ab1