Currently the order will be placed until it reaches complete step on checkout, how to freeze the order on payment step?

For example PayPal Express Checkout (offsite), after the page is redirected to PayPal the order should be frozen (not a 'cart' order any more) to avoid updating the order, e.g. add a product to cart or update quantity of an item in cart.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

edwardaa created an issue. See original summary.

edaa’s picture

Status: Active » Needs review
FileSize
2.69 KB
edaa’s picture

PR https://github.com/drupalcommerce/commerce/pull/785 created.

Any thoughts on this case?

edaa’s picture

Issue summary: View changes
MegaChriz’s picture

What if payment fails? Can you still choose an other payment method in that case?

edaa’s picture

You are right, I can't. Need to find another way to freeze the order.

edaa’s picture

Maybe just invoke finalizeCart on payment step, the order is still 'draft' and 'order refresh' will run on it.

edaa’s picture

Title: Be able to choose a checkout step to place the order » How to freeze a cart order on payment step?
Category: Feature request » Support request
Issue summary: View changes
Status: Needs review » Active
bojanz’s picture

Title: How to freeze a cart order on payment step? » Provide a way to explicitly lock the order
Component: Checkout » Order
Category: Support request » Feature request

We planned this, but never implemented it.

We need a "locked" boolean on the order, and we need lock() / unlock() / isLocked() methods on OrderInterface.
We need CartProvider to filter out locked orders after they're loaded.
We need PaymentProcess to lock the order before rendering the offsite-form, and we need to make sure placing an order unlocks it.
We also need to figure out the admin UX for locked orders. My current idea is to return access denied, causing the edit tab to not be available, and have an unlock form for breaking the lock.

bojanz’s picture

Assigned: Unassigned » bojanz

Wrapping this up.

bojanz’s picture

Status: Active » Needs review
FileSize
18.7 KB

Current progress. There's a single test fail, OrderUserTest, which I haven't tracked down yet.

  • bojanz committed 819a3fd on 8.x-2.x
    Issue #2906563 by edwardaa, bojanz, MegaChriz: Provide a way to...
bojanz’s picture

Status: Needs review » Fixed

Fixed the bug that was failing the test, and made sure that clicking "Go back" in the checkout payment page (iframe gateways) unlocks the order.

Still feels like we need more test coverage, but what we added here is a good start.

edaa’s picture

Wow, thanks, it works pretty well.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.