Shopware 6: UX Fuckup and an Unavailable Shipping Method

It’s always, ALWAYS!! the small thinks – ok it is not, but today it was. I searched over an hour for the problem, why our shipment method was not available.

The error message comes from \Shopware\Core\Checkout\Shipping\Cart\Error\ShippingMethodBlockedError

And after digging down to vendor/shopware/storefront/Resources/views/storefront/page/checkout/confirm/index.html.twig

I learned about {% if page.cart.errors.blockResubmit %} and especially page.cart.errors. If you dump this template variable you get:

Screenshot of the Symfony dump() output of page.cart.errors

Okay, let’s have a look into the line 124:

        // Fetch default price if no rule matched
        if ($costs === null) {
            /** @var ShippingMethodPriceCollection $shippingPrices */
            $shippingPrices = $shippingMethod->getPrices()->filterByProperty('ruleId', null);
            $costs = $this->getMatchingPriceOfRule($delivery, $context, $shippingPrices);
        }

        if (!$costs) {
            $cart->addErrors(
Line 124:       new ShippingMethodBlockedError((string) $shippingMethod->getTranslation('name'))
            );

            return;
        }

Hmm, looks like Shopware doesn’t find the price for the shipping method, especially not a default one. That kind of make sense in our case, because all price matrices have a rule attached to them, although from my point of view the rule should match and therefore the price be used. But we dig deeper and add a default price without rule:

Screenshot of default price matrix for our shipping method - no rule, price is 0
Default price rule for our shipping method

But the error was still the same… Then it dawned on me… The price rule is for 1…∞ but I just created it, shouldn’t it work? And then the second penny dropped. Shopware has a bad UX “bug”. I assume the price matrix has a default value of 1, because I assume again, the matrix was first implemented for products and there it made sense to have a count of 1…∞, but that is not the case for weight.

And as you can imagine, the produce looked like this:

Screenshot of the Measures & packaging of a shopware produce - everything empty
Screenshot of the Measures & packaging of a shopware produce – everything empty

And a produce with a weight of 0, doesn’t match the pricing matrix and therefore there is no price for the shipping method and therefore it is unavailable.

So be careful with your price rules.

I opened a github issue for it, if you want to fix it!

Leave a Reply

Discover more from Winkelwagen

Subscribe now to keep reading and get access to the full archive.

Continue reading