shipperhq / module-shipper

Base ShipperHQ Repo
Open Software License 3.0
21 stars 21 forks source link

ShipperHQ sets Order to pending #75

Closed beyondmediadev closed 5 months ago

beyondmediadev commented 4 years ago

Hi there,

we are working with PayOne in one of our shops. PayOne assigns the state processing when the amount has been paid. Somehow randomly (3 days later) the order is set to pending with following notice: "ShipperHQ Notice: No detailed shipping information recorded"

Why is that? We have shipperHq Autocomplete Extension installed but don't use the m2 integration.

Expected Behavior

With shipperHQ Extension being disabled in Admin, no action will be taken by shipperHQ

Current Behavior

Orders get updated to status pending randomly. Order was previously in state processing

wsajason commented 4 years ago

Hi, The module is not able to affect the order status as it is designed only to be used with shipping rate calculations; post-order is left to built-in functionality. On the order the module checks whether the order number is present in the advanced order details tables (which stores details such as dimensional shipping boxes, dates, origins, etc). If details are present they will be displayed on the order. If not present an order comment is added (which is not sent to the customer) stating that no detailed shipping information was recorded. This flag denotes to the module that it should not check for order details unique to ShipperHQ (I.e.: dimensional shipping boxes, dates, origins, etc).

In short, the order comment is for reference only; no changes are made to the order itself.

lbajsarowicz commented 1 year ago

@wsajason Unfortunately, you're mistaken.

Let me explain:

After the Order is placed, your extension executes a 100+ lines method that does everything (\ShipperHQ\Shipper\Observer\AbstractRecordOrder::recordOrder). It receives an Order object and processes it. At the same time, other extensions, like Payment Methods are updating the Order and Transaction data (for example, after the Payment is Captured, change the status from Pending to Processing).

But!

Your extension does not care about the up-to-date state of the Order, as it already have the Order received from Observer, which is outdated. ShipperHQ decided that instead of executing save on a single attribute they change... they are going to re-save the whole order with:

https://github.com/shipperhq/module-shipper/blob/17f9d5cfefad2f3ce9ef31a1107349e1858c121c/src/Observer/AbstractRecordOrder.php#L272

Et voila! Recipe for a disaster.

image

This would be enough if you just changed $order->save() with \Magento\Sales\Model\ResourceModel\EntityAbstract::saveAttribute updating only the attributes you have touched.

It is worth to mention that you not only affect the Order Status, but also other Order-specific details provided asynchronously by 3rd party extensions, even if they are saving their attributes correctly.

WSAlewis commented 1 year ago

Hello @lbajsarowicz,

Thank you for the detailed response.

I'll be raising this to our development team to assess further. We'll reach out once we have more information to share.

If you have any further questions or concerns let us know.

wsajosh commented 5 months ago

Thanks for raising this, we believe it's been addressed in the latest version!