verbb / postie

A Craft Commerce shipping calculator plugin.
Other
12 stars 18 forks source link

Attempting to complete an order by payment returns error and clears out shipping method & addresses #85

Open michaelrog opened 2 years ago

michaelrog commented 2 years ago

Everything works as expected on the front-end... but when we attempt to complete an order by payment in the admin CP, we run into a weird glitch: The request comes back with an error from Commerce:

Something changed with the order before payment

Notably, the previously-saved shipping method and shipping/billing addresses are then cleared out.

Have yall seen anything like this before?

Additional info

engram-design commented 2 years ago

Looks like I can replicate this event earlier in the process, when creating and order in the control panel although I can't quite nail down what's causing it. But something is stripping the shipping address from the order, causing Postie to log:

2022-01-26 00:09:48 [-][1][-][info][postie] Post: No shipping address for order.
2022-01-26 00:09:48 [-][1][-][info][postie] Post: No shipping address for order.
2022-01-26 00:09:48 [-][1][-][info][postie] Post: No shipping address for order.
2022-01-26 00:09:48 [-][1][-][info][postie] Post: No shipping address for order.
2022-01-26 00:09:48 [-][1][-][info][postie] Post: No shipping address for order.
2022-01-26 00:09:48 [-][1][-][info][postie] Post: No shipping address for order.

Multiple times, as you can see. I can replicate this by creating an order in the control panel, and selecting an Postie-provided shipping method, and saving the order. That seems to work all fine, but then selecting another shipping method (also from Postie), and then hitting save again defaults back to a Commerce-based shipping method ("Free Shipping" in my case), due to the above multiple order update call.

I'll have to do some more investigating here, but I'd assume that this is the same issue as when getting to payment. To be clear, is this an order that's been completed? That does have some bearing on how we handle things.

michaelrog commented 2 years ago

No, the order hasn't yet been completed. It's being completed, by way of a Payment, when we encounter the error.

engram-design commented 2 years ago

Yep, just thought to check as you can technically have a completed, unpaid order. What I mean is, is there a "Mark as Complete" button in the control panel when editing the order?

michaelrog commented 2 years ago

...as you can technically have a completed, unpaid order. What I mean is, is there a "Mark as Complete" button in the control panel when editing the order?

Yes, I am dealing with an incomplete unpaid order — i.e. completed is false and the control panel UI includes a "Mark as Completed" button.

jakedohm commented 2 years ago

@engram-design hi Josh! This issue is from something Michael is working with our team at Steadfast on. I wanted to follow up to see if you had made any progress on this, or if you needed any more data from us to dig into this?

engram-design commented 2 years ago

@jakedohm Haven't had oodles of time to jump into this, but I was chatting with the Commerce team about it, and what's supposed to be happening, without much headway. I'll take another stab at it soon.

engram-design commented 2 years ago

I've made some improvements in https://github.com/verbb/postie/commit/5a16e35d8f143929734aa5542208d357e22f6e39 that should have some benefit here. In my testing, this doesn't seems to be happening anymore, but worth confirming on your end?

michaelrog commented 2 years ago

Unfortunately, even roping in 5a16e35 via craft-3-dev, this issue persists in our setup:

When completing an order via Transaction in the CP, we see a payment error:

There are errors on the order

  • The total price of the order changed.
  • The total number of order adjustments changed.

Additionally, we see a new Customer Notice registered:

Customer Notices

  • The previously-selected shipping method is no longer available.

Finally — and most destructively — the Shipping Address, Billing Address, and Shipping Method are all cleared out.

(To confirm, this order has been updated/saved to commit any extant changes, before attempting to complete the order with via a payment Transaction. Prior to attempting payment, the order does show its Postie-provided shipping method and cost.)

(Craft CMS 3.7.37, Commerce 3.4.12)

engram-design commented 2 years ago

So I really can't replicate this on my end, and I've tried all sorts of different gateways, updating orders and different stages.

Is there anything on your end that might modify the order on its complete event, payment event, or otherwise?

Would it be too much to ask for a video of the issue, just in case I'm doing something different to you? Here's a recording of me going through the process. https://d.pr/v/vHHyiG

RitterKnightCreative commented 2 months ago

Having the same issue here on Commerce 4.x.

I noticed if you start in the CP, like in your recording Josh @engram-design, I don't have any issues.

However, if you start an order on the front end, fill up your cart, pick a shipping method, once you hit the back end to complete it, it breaks.

I'll get to the point on the front end where I'm going to take payment, I'll hop back to the control panel, jump into Active Carts, and then try to mark as complete from there (for example, for testing purposes).

Seems Commerce doesn't want to play ball at this point.

FWIW I'm using UPS plugin and PayPal gateway.

Not sure if that helps...

engram-design commented 2 months ago

Is it the same error, or something else? And it still clears out the shipping method and addresses?

RitterKnightCreative commented 1 month ago

Had a chance to do a little more digging. I think this might be more of Commerce bug than Postie. Client has a multisite with products in both. If I try completing the order on the primary site, everything works just fine. However, if I try to complete it on the secondary site, the whole order gets nulled. It's almost like Commerce is only using the primary site on the CP and when the products on the secondary site don't "exist", everything goes haywire.

engram-design commented 1 month ago

Ah, now that's good to know. I wonder if that might be different with multi-store in Commerce 5? I'll play around with it.

RitterKnightCreative commented 1 month ago

Yeh I was wondering the same thing about 5... hopefully they've made some improvements with it.