0

I am doing an Offsite redirection payment with Drupal Commerce. I have a custom payment workflow defined in my_module.workflow.yml as follows:

order_linktypeplus_validation:
  id: order_linktypeplus_validation
  group: commerce_order
  label: 'linktypeplus order workflow'
  states:
    draft:
      label: Draft
    pending:
      label: Pending
    completed:
      label: Completed
    canceled:
      label: Canceled
  transitions:
    place:
      label: 'Place order'
      from: [draft]
      to: pending
    fulfill:
      label: 'Fulfill order'
      from: [draft, pending]
      to: completed
    cancel:
      label: 'Cancel order'
      from: [draft, pending]
      to: canceled

So as per this when the order is placed, First order will be moved to the Pending state (which is working fine). And for some orders, I need to get it completed without the pending state (ie. from draft to completed)

I was doing this in my controller after offsite payment had been successfully done and returned to the site:

 $order->unlock();
 $order->setData($paymentGateway, $data);
 if ($order->getState()->getId() != 'completed') {
      $order->getState()->applyTransitionById('fulfill');
  }
 $order->save();

When I checked in the cart tab next to orders, the item was still in the cart. but its status says Order moved from Draft to Completed by the Fulfill order transition. But the order is not created. enter image description here

Any idea on how to resolve this issue?

1 Answer 1

0

But the order is not created.

What do you mean by that? The order in your screenshot has the completed state?

1
  • The screenshot is of the Cart tab. The order tab is not showing this. The Completed state is showing is for payments(i guess)
    – KTM
    Oct 20, 2023 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.