3

I am using Tablerates as my shipping method and the condition is set to Price vs Destination.

Use case One

Free Shipping over $200

Use case Two

If zip code falls under Zone 1 i.e. 28682-28685, `$20` flat rate shipping fee

Use case Three

If zip code falls under Zone 2 i.e. 28360-28365, `$50` flat rate shipping fee

Below is how my CSV looks like

 Country  Region/State Zip/Postal Code Order Subtotal(and above) Shipping Price                                                                                 
 USA      NC           28682           0                         20
 USA      NC           28682           201                       0                                  
 USA      NC           28360           0                         50
 USA      NC           28360           201                       0

Upload works, as is reflected in the table shipping_tablerate as seen in below image

shipping-table

But when user check shipping price on cart page for zip code whose shipping price should be $20, it always takes $50. It can be seen in below image. Currently the user is logged in

cart-estimate

Although when Subtotal goes beyond $200, it shows shipping price $0 which is correct as per tablerates. Moreover on checkout page, it shows correct shipping price based on zip code selected. It happens only on cart page.

Estimate Shipping and Tax also shows correct shipping price based on zip code entered. But when I click on selected price it throws below exception

/rest/default/V1/carts/mine/totals-information 500 (Internal Server Error)

Below is the response I get

{"messages":{"error":[{"code":500,"message":"Fatal Error: 'Uncaught TypeError: Argument 1 passed to Magento\\Quote\\Model\\Cart\\Totals::setExtensionAttributes() 
must be an instance of Magento\\Quote\\Api\\Data\\TotalsExtensionInterface, instance of Magento\\Quote\\Api\\Data\\AddressExtension given, called in \/home\/storeq\/public_html\/vendor\/magento\/framework\/Api\/DataObjectHelper.php on line 125 and defined in \/home\/storeq\/public_html\/vendor\/magento\/module-quote\/Model\/Cart\/Totals.php:592\n
Stack trace:\n#0 \/home\/storeq\/public_html\/vendor\/magento\/framework\/Api\/DataObjectHelper.php(125): 
Magento\\Quote\\Model\\Cart\\Totals->setExtensionAttributes(Object(Magento\\Quote\\Api\\Data\\AddressExtension))\n#1 \/home\/storeq\/public_html\/vendor\/magento\/framework\/Api\/DataObjectHelper.php(85): 
Magento\\Framework\\Api\\DataObjectHelper->_setDataValues(Object(Magento\\Quote\\Model\\Cart\\Totals), Array, 'Magento\\\\Quote\\\\A...')\n#2 \/home\/storeq\/public_html\/vendor\/magento\/module-quote\/Model\/Cart\/CartTotalRepository.php(103):
Magento\\Framework\\Api\\DataObjectHelper->populateWithArray(Object(Magento\\Quote\\Model\\Cart\\Tota' in '\/home\/storeq\/public_html\/vendor\/magento\/module-quote\/Model\/Cart\/Totals.php' on line 592","trace":"Trace is not available."}]}}

When user is not logged in, it does not show shipping charges, but when user is logged in it always shows in correct shipping price i.e. $50

  • How do I resolve this and display correct shipping price on cart page?

2 Answers 2

1
+25

Take note of Free shipping is one of the most effective promotions you can offer. It can be based on a minimum purchase, or set up as a cart price rule that is applied when a set of conditions is met. If both apply to the same order, the configuration setting takes precedence over the cart rule.

With the above in mind, you could also leverage price rules as a means of conditioning if the table rate options aren't meeting requirements.

But judging from your request it should all be possible without any custom coding or 3rd party modules.

2
  • 1
    You mean this should work - magento.stackexchange.com/questions/218862/… ? Mar 19, 2018 at 13:38
  • Sort the data by Region/State so the specific locations are at the top of the list, and the wildcard locations at the bottom. This will process the rules with the absolute values first, and the wildcard values later. Also double check how the shipping configuration settings are configured. Also note that zipcode is only for each specific zipcode and not a range.
    – B00MER
    Mar 19, 2018 at 13:53
0

Oh I know that error! I've had the Magento\Quote\Model\Cart\Totals::setExtensionAttributes() it's a magento bug I don't remember where I found it but here is the fix:

// open file /vendor/magento/module-quote/Model/Cart/CartTotalRepository.php
// at line 97 add:
unset($addressTotalsData[\Magento\Framework\Api\ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);

try this and let me know.

Magento issue record: https://github.com/magento/magento2/issues/9646

Fix: https://github.com/ekuusela/magento2/commit/aa535ea5d4bf78915bddd4387a9d3c4b39943eea

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.