In my Drupal 7 site I have inserted an extra page in the checkout process (using a custom module), after the review page, where the customer can choose between 2 custom payment methods. My problem is that if the customer decides to leave the checkout process after reaching the custom payment page, all line items are cleared from the cart.

If he/she only goes one step back to the review page the cart is still intact. Also if he/she leaves the checkout process from the review page, the cart is not emptied, even after going back from the custom payment page. So it does not seem as though the cart is emptied when clicking Continue on the review page, after all.

Now, I need to change this behaviour so that the cart is not cleared if the visitor leaves the checkout process when on my custom payment page.

What do I need to do?


Turns out I needed to update the order state on the new checkout page. Since the user is supposed to choose a payment method on this custom page it suffised to create a simple Rule that fires on that event.

In case anyone else have the same problem (as described in the question), here it is:

{ "rules_keep_order_state" : {
    "LABEL" : "Keep order state",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "commerce_order", "commerce_payment" ],
    "ON" : { "commerce_payment_methods" : [] },
    "DO" : [
      { "commerce_order_update_state" : { "commerce_order" : [ "commerce_order" ], "order_state" : "checkout" } }

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.