Skip to content

[Backport] Fixed comparison with 0 bug for TableRate shipping carrier#17089

Merged
magento-engcom-team merged 1 commit intomagento:2.1-developfrom
mageprince:2.1-develop-PR-port-13831
Jul 26, 2018
Merged

[Backport] Fixed comparison with 0 bug for TableRate shipping carrier#17089
magento-engcom-team merged 1 commit intomagento:2.1-developfrom
mageprince:2.1-develop-PR-port-13831

Conversation

@mageprince
Copy link
Copy Markdown
Contributor

Original Pull Request

#13831

Description

In free shipping flow sometimes you can get such query to DB:

SQL: SELECT `shipping_tablerate`.* FROM `shipping_tablerate` WHERE ...
BIND: array (
':website_id' => 1,
':country_id' => 'US',
':region_id' => 12,
':postcode' => '68138',
':condition_name' => 'package_value',
':condition_value' => -3.5527136788005009E-15,
)
AFF: 0

It leads to disabled TabelRate shipping method. Such value is calculated in Magento\OfflineShipping\Model\Carrier\Tablerate::collectRates(). Smth like:

29.95 - 10 - 19 - .95 = -3.5527136788005009E-15

and normally should be rounded before comparison. See http://php.net/manual/en/language.types.float.php

Manual testing scenarios

  1. Setup free shipping rule with Subtotal >= 25.
  2. Setup TableRate shippign method.
  3. Add products to cart.
  4. Apply free shipping coupon.
  5. TableRate shippign method disappears.

In free shipping flow sometimes you ca get such query to DB:
SQL: SELECT `shipping_tablerate`.* FROM `shipping_tablerate` WHERE ...
BIND: array (
':website_id' => 1,
':country_id' => 'US',
':region_id' => 12,
':postcode' => '68138',
':condition_name' => 'package_value',
':condition_value' => -3.5527136788005009E-15,
)
AFF: 0

It leads to disabled TabelRate shipping method. Such value is calculated in Magento\OfflineShipping\Model\Carrier\Tablerate::collectRates(). Smth like:
  29.95 - 10 - 19 - .95 = -3.5527136788005009E-15
and normally should be rounded before comparison. See http://php.net/manual/en/language.types.float.php
@magento-engcom-team
Copy link
Copy Markdown
Contributor

Hi @mageprince. Thank you for your contribution.
We will aim to release these changes as part of 2.1.15.
Please check the release notes for final confirmation.

@mageprince mageprince deleted the 2.1-develop-PR-port-13831 branch July 26, 2018 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants