FosterCommerce / shipstation-connect

A plugin for Craft Commerce 2 that integrates with ShipStation.
https://plugins.craftcms.com/shipstationconnect
Other
7 stars 10 forks source link

Orders recalculated after Shipstation update? #48

Closed iamkeir closed 10 months ago

iamkeir commented 1 year ago

We have noticed that when we mark an order as shipped in Shipstation and it syncs back to Commerce, if any products in the order are no longer "available for purchase", Commerce removes these products from the order, shows "products unavailable" order notices, and marks the order as "overpaid". The order in Shipstation however still has the correct order contents.

I am not 100% it is the plugin, but it aligns with the action described above - the order is fine before that. The above can only happen if the order is recalculated rather than just updated. Could the plugin be doing this?

We will keep digging and update with more information as we have it.

screenshot_460
iamkeir commented 1 year ago

Some more info - it only seems to happen with orders that have a status of "paid". If the order is "unpaid" or "partial", no recalculation happens.

iamkeir commented 1 year ago

We are using the code to send custom data to Shipstation but can't see how this could be related - but posting anyway:

Event::on(
        Xml::class,
        Xml::ORDER_FIELD_EVENT,
        function (OrderFieldEvent $e) {
            $order = $e->order;
            $shipping_address = $order->getShippingAddress();

            if ($e->field === OrderFieldEvent::FIELD_CUSTOMER_NOTES && $shipping_address->notes) {
              $e->value = $shipping_address->notes;
            }

            if ($e->field === OrderFieldEvent::FIELD_GIFT_MESSAGE && $order->orderGiftNote) {
              $e->value = $order->orderGiftNote;
            }
        }
    );
peteeveleigh commented 1 year ago

Hey @iamkeir Apologies for not responding to this sooner.

We'll get it into the system and take a look to see how this can be resolved.

peteeveleigh commented 1 year ago

@iamkeir I have been looking into this today and have been unable to reproduce the problem you are seeing.

These are the steps I took on my test store.

  1. Create an order in Commerce with 3 different line items
  2. Pay for the order, so it is then marked as Completed and Paid
  3. Order shows up in Shipstation
  4. Back in Commerce, I made one of the lineitem products no longer available for purchase by turning the "Available for purchase" switch off.
  5. Back in Shipstation I marked the order as Shipped
  6. The order updates in Commerce with the tracking number and is marked as shipped. No changes were made to the line items and no messages shown.

I was using Commerce 4. Can you confirm which version you are using? And which Plugin version? There shouldn't be any differences between the 3 and 4 plugins in this area but it will be worth checking ou.

iamkeir commented 1 year ago

@fantasticmachine thanks for following up. We are Craft 3 with Commerce 3.4.19 and ShipStation Connect 1.3.7. It could be an issue with Commerce, that has been addressed in C4 perhaps? Let us know if you are able to recreate in C3 environment.

peteeveleigh commented 1 year ago

@iamkeir It could be something restricted to Commerce 3, yes. I'll get a Craft 3 test set up asap and see if I can reproduce the problem.

peteeveleigh commented 1 year ago

@iamkeir I've now been able to test using a Craft 3/Commerce 3 store and I'm still unable to reproduce the problem you are seeing.

Are you able to do a test without your custom Event Listener?

iamkeir commented 1 year ago

@fantasticmachine thanks for trying - I am away this week but I will endeavour to see if I can recreate next week. Fingers crossed I can't, and perhaps it has been squished as part of recent updates in Craft.

peteeveleigh commented 1 year ago

@iamkeir No worries. If it's something I can test with a copy of your DB (cleaned), project config, and composer file then send them over to pete@fostercommerce.com and I'll see what else I can figure out

johnnynotsolucky commented 10 months ago

@iamkeir was the issue you were having resolved with updates to Craft/Commerce?

iamkeir commented 10 months ago

@johnnynotsolucky unsure but the client stopped paying us to support their site, so we were unable to investigate this further. They did not mention it again. I will close for now! Thanks for the support thus far.