@shellbeezy
This issue is not only related to discounts. We don’t use any discounts but got this issue. The reason is the weak ability of PHP in storing float values. Here is a real-life example:
I got this error when tried to buy products at 69.60$. I investigated logs and found that your plugin sends the wrong final amount – 6959 cents. Your plugin has a function for converting dollars to cents(Money_Utility::amount_to_cents). And there we have an error. (int) conversion sometimes(depends on the price) cuts off part of the price. You can debug this with the next line: sprintf(‘%.40F’, ( ( 10 ** 2 * 69.60 ) ) – there will be a float number with huge about of digits after the comma. And (int) conversion cuts them off, so the result is 6959.
The workaround for this issue is to add “round” function before converting to int so this function should look like this:
wp-content/plugins/woocommerce-square/includes/Utilities/Money_Utility.php
public static function amount_to_cents( $amount, $currency = '' ) {
if ( ! $currency ) {
$currency = get_woocommerce_currency();
}
return (int) ( round( ( 10 ** self::get_currency_decimals( $currency ) ) * $amount ) );
}