Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid package types on Bring - and no results from Bring request #125

Open
nitech opened this issue Mar 18, 2024 · 4 comments
Open

Invalid package types on Bring - and no results from Bring request #125

nitech opened this issue Mar 18, 2024 · 4 comments

Comments

@nitech
Copy link

nitech commented Mar 18, 2024

Describe the bug

Seems you're requesting some package types that don't exist on Bring anymore:

image

When I turn off these and just request the rest of the package types, I get only:

image

... and as you see, no available package types.

When I go back and into freight selection again, I get this error:

"Bring: Sending payload: {"consignments":[{"id":"1","fromCountryCode":"NO","fromPostalCode":"6230","toCountryCode":"NO","toPostalCode":"6230","packages":[{"grossWeight":2300,"id":"1"}],"products":[{"id":"SERVICEPAKKE"},{"id":"PA_DOREN"},{"id":"BPAKKE_DOR-DOR"}]}],"postingAtPostoffice":false}."
An Error occurred while handling another error:
yii\web\HeadersAlreadySentException: Headers already sent in /var/www/html/vendor/symfony/var-dumper/Dumper/AbstractDumper.php on line 171. in /var/www/html/vendor/yiisoft/yii2/web/Response.php:369
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/web/Response.php(342): yii\web\Response->sendHeaders()
#1 /var/www/html/vendor/yiisoft/yii2/web/ErrorHandler.php(136): yii\web\Response->send()
#2 /var/www/html/vendor/craftcms/cms/src/web/ErrorHandler.php(192): yii\web\ErrorHandler->renderException(Object(yii\web\HeadersAlreadySentException))
#3 /var/www/html/vendor/yiisoft/yii2/base/ErrorHandler.php(152): craft\web\ErrorHandler->renderException(Object(yii\web\HeadersAlreadySentException))
#4 /var/www/html/vendor/craftcms/cms/src/web/ErrorHandler.php(66): yii\base\ErrorHandler->handleException(Object(yii\web\HeadersAlreadySentException))
#5 [internal function]: craft\web\ErrorHandler->handleException(Object(yii\web\HeadersAlreadySentException))
#6 {main}
Previous exception:
yii\web\HeadersAlreadySentException: Headers already sent in /var/www/html/vendor/symfony/var-dumper/Dumper/AbstractDumper.php on line 171. in /var/www/html/vendor/yiisoft/yii2/web/Response.php:369
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/web/Response.php(342): yii\web\Response->sendHeaders()
#1 /var/www/html/vendor/yiisoft/yii2/base/Application.php(390): yii\web\Response->send()
#2 /var/www/html/web/index.php(21): yii\base\Application->run()
#3 {main}

Steps to reproduce

Craft CMS version

Latest

Plugin version

Latest

Multi-site?

Yes

Additional context

No response

@nitech
Copy link
Author

nitech commented Mar 18, 2024

The HeadersAlreadySentException seems to be triggered by postie config's displayDebug or displayErrors.

@engram-design
Copy link
Member

Some of these are valid products, but may not be available for your cart or Bring account.

For example

  • MINIPAKKE is Valid only after special agreement between Bring and customer.
  • COURIER_6H can not be sent from country NORWAY to country NORWAY
  • COURIER_1H can not be sent between the given postal codes / countries

So these are still valid products, but don't always return a rate - and that's fine. Having said that, it looks like they've deprecated the handles for a number of products, and are going with numerical ones now. As such, we need to update our services list.

Updated for the next release. To get this early, run composer require verbb/postie:"dev-craft-4 as 3.1.6".

But yes, we have plans to provide better error/debug feedback that's not going to mess with the page output. That's coming in Postie v4.

@nitech
Copy link
Author

nitech commented Mar 21, 2024

Thanks for the update. I still don't get any package options back from Bring.

When I debug the ShippingMethods.php-file, I see getMatchingShippingMethods is called multiple times. The first time it returns a list of shipping methods from the Bring API:

image

Second time too:

image

Third time too:
image

The fourth time it's gone:

image

When I inspect the $order-object, I see the the _lineItems is empty, which is probably the reason no shipping methods are returned:

image

Which I also can see int he postie log file:

2024-03-21 10:17:29 [INFO] Bring: No line items for order.

(btw, here is a dump of rate errors):

$_POST = []
2024-03-21 10:19:36 [INFO] Bring: Sending payload: `{"consignments":[{"id":"1","fromCountryCode":"NO","fromPostalCode":"6230","toCountryCode":"NO","toPostalCode":"6230","packages":[{"grossWeight":4600,"id":"1"}],"products":[{"id":"0330"},{"id":"0331"},{"id":"0332"},{"id":"0333"},{"id":"0334"},{"id":"0335"},{"id":"0336"},{"id":"0339"},{"id":"0340"},{"id":"0341"},{"id":"0342"},{"id":"0343"},{"id":"0345"},{"id":"0348"},{"id":"0349"},{"id":"1000"},{"id":"1002"},{"id":"1020"},{"id":"1202"},{"id":"1206"},{"id":"1312"},{"id":"1736"},{"id":"1885"},{"id":"1988"},{"id":"3110"},{"id":"3570"},{"id":"3584"},{"id":"4850"},{"id":"5000"},{"id":"5100"},{"id":"5300"},{"id":"5400"},{"id":"5600"},{"id":"5800"},{"id":"9000"},{"id":"9100"},{"id":"9300"},{"id":"9600"},{"id":"MAIL"},{"id":"VIP25"}]}],"postingAtPostoffice":false}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"0330","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 0330 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"0331","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 0331 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"0332","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 0332 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"0333","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 0333 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"0334","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 0334 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"0335","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 0335 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"0336","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 0336 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"0339","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 0339 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"0340","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 0340 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"0341","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 0341 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"0342","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 0342 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"0343","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 0343 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"0345","productionCode":"0345","errors":[{"code":"INVALID_ARGUMENT","description":"Customer not applicable for product 0345"}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"0348","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 0348 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"0349","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 0349 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"1000","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 1000 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"1002","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 1002 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"1020","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 1020 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"1202","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 1202 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"1206","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 1206 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"1312","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 1312 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"1736","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 1736 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"1885","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 1885 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"1988","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 1988 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"3110","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product 3110 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"5100","productionCode":"5100","errors":[{"code":"INVALID_MEASUREMENTS","description":"Weight and either of volume or dimensions(length, width, height) or pallets or load meter is required for product 5100, packageId : 1"}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"5300","productionCode":"5300","errors":[{"code":"INVALID_MEASUREMENTS","description":"Weight and either of volume or dimensions(length, width, height) or pallets or load meter is required for product 5300, packageId : 1"}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"5400","productionCode":"5400","errors":[{"code":"INVALID_MEASUREMENTS","description":"Weight and dimensions(length, width, height) are required for product 5400, packageId : 1"}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"9100","productionCode":"9100","errors":[{"code":"INVALID_MEASUREMENTS","description":"Weight and either of volume or dimensions(length, width, height) or pallets or load meter is required for product 9100, packageId : 1"}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"MAIL","productionCode":"MAIL","errors":[{"code":"INVALID_MEASUREMENTS","description":"Package 1 exceed maximum measurements for product MAIL"}]}`.
2024-03-21 10:19:36 [ERROR] Bring: Error fetching rate: `{"id":"VIP25","errors":[{"code":"INVALID_ARGUMENT","description":"Unknown product ID or product VIP25 not applicable for given EDI flag."}]}`.
2024-03-21 10:19:36 [INFO] Request context:
$_GET = []

So anyway. Do you know why this happens - and is it related to Postie, or is it a Commerce bug?

@engram-design
Copy link
Member

getMatchingShippingMethods will be called multiple times, which is just a mechanism of Commerce I'm afraid. That's why we employ caching by default (when we're not debugging).

That seems extremely strange that line items are suddenly going missing. Certainly not happening on my end:

image

This is what appears for me with the debug addresses un-commented.

The log file also looks reasonable, as a lot of services aren't applicable. I've just added missing dimensions to packages which is showing an error for some products.

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

No branches or pull requests

2 participants