1

When viewing a shipment in Magento 2.4.2, the "Creating Shipping Label..." button opens the "Create Packages" dialog as expected.

However, the "Add Products to Package" button, which should display a grid that allows items from within the shipment to be added to the package, does nothing. There are no console or log errors, it simply fails silently.

Has anyone else encountered this issue, and is there a fix for it?

1

After digging into the JS and template files, then tracing back to the PHP code, I discovered there is a bug in the core Magento Shipping module (vendor/magento/module-shipping).

In this file:

vendor/magento/module-shipping/view/adminhtml/templates/order/packaging/grid.phtml

On line 63, we have:

<?php $id = $item->getId() ?? $item->getOrderItemId(); ?>

But the $item in question is the order, not the shipment item. Because of this, the frontend can't get a handle on the item and so the process silently fails. I have a suspicion that the programmer doesn't understand how to use the null coalescing operator properly.

To remedy this, simple change the line to:

<?php $id = $item->getOrderItemId(); ?>

Of course, it's not best practice to edit core files directly; you should copy the file to a custom module and override it there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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