Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

[BUG] Condition value is always package weight and never subtotal (except if package has no weight) #28

Open
paul-stolk-webdiensten opened this issue Dec 6, 2021 · 4 comments

Comments

@paul-stolk-webdiensten
Copy link

To Reproduce
Steps to reproduce the behavior:

  1. Go to the admin, set condition = "Prices vs. Destination" and use table rates for handling fees calculation, with (for example) two prices: 3.95 euro for subtotal 0 and above, 0 euro for subtotal 32.2314 (ex VAT, which is 39 incl VAT) and above
  2. Add one or more products with weight (for example a weight of 1) to the cart, resulting in a subtotal of 32.2314+ (which should trigger the free shipping)

Expected result
The shipping costs is 0

Actual result
The shipping costs is 3.95

Workaround
Change \TIG\GLS\Model\ResourceModel\Carrier\bindings, line 152:
Old: $bindings[':condition_value'] = $request->getPackageWeight();
New: $bindings[':condition_value'] = $this->getConditionValue($request->getAllItems());

Note:
Because of the following line: if ($bindings[':condition_name'] == null && $bindings[':condition_value'] == 0.0)
It does seem to work when no weight is set for the product.

Screenshots
Shipping rates:
image

Settings:
image

  • Magento version: 2.3.7-p1
  • PHP version: 7.4.23
  • TIG GLS version: 1.4.0
@paul-stolk-webdiensten
Copy link
Author

The following patch can be used to quick-fix this:

https://github.com/tig-nl/gls-magento2/issues/28
===================================================================
diff --git a/vendor/tig/gls-magento2/Model/ResourceModel/Carrier/GLS.php b/vendor/tig/gls-magento2/Model/ResourceModel/Carrier/GLS.php
--- a/vendor/tig/gls-magento2/Model/ResourceModel/Carrier/GLS.php
+++ b/vendor/tig/gls-magento2/Model/ResourceModel/Carrier/GLS.php	(date 1638787288081)
@@ -149,7 +149,7 @@

         $rateQuery->prepareSelect($select);
         $bindings = $rateQuery->getBindings();
-        $bindings[':condition_value'] = $request->getPackageWeight();
+        $bindings[':condition_value'] = $bindings[':condition_value'] = $this->getConditionValue($request->getAllItems());

         // If quote is lost these values are empty, causing table rates to return the wrong shipping rate.
         if ($bindings[':condition_name'] == null && $bindings[':condition_value'] == 0.0) {

Add it to Composer:

        "patches": {
            "tig/gls-magento2": {
                "ISSUE-28: Condition value is always package weight and never subtotal": "patches/composer/GLS-28-incorrect-condition-value.patch"
            }
        }

@tig-jeffreybranderhorst
Copy link

tig-jeffreybranderhorst commented Dec 6, 2021

Hi @paul-stolk-webdiensten,

Thank you for submitting this fix, we will investigate this further and make adjustments where needed. My colleague looked at your fix and said the following, a small adjustment you can make is:
$bindings[':condition_value'] = $bindings[':condition_value'] = $this->getConditionValue($request->getAllItems());
Change it to
$bindings[':condition_value'] = $this->getConditionValue($request->getAllItems());

Thank you again for bringing this to our attention we will investigate the issue!

Have a great day,
Jeffrey

@vandijkstef
Copy link

Same issue on Mage 2.4.3-p1. Fix worked wonders, thanks!

@tig-jeffreybranderhorst

Hi @vandijkstef,

Thank you for your confirmation!

Have a great day,
Jeffrey

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants