Async Order a module which enable a feature that you can process the order asynchronously which marks the order as “received” and order goes into the queue and all the processes of orders run from the queue on a first-in-first-out basis. AsyncOrder feature is disabled by default.
You can enable Async Order fearture using the command-line interface:
bin/magento setup:config:set --checkout-async 1
or you can set command writes the following to the app/etc/env.php file:
... 'checkout' => [ 'async' => 1 ]
Let understand the flow of Asynchronously Order.
For example, a customer adds a product to their shopping cart and selects Proceed to Checkout. They fill out the Shipping Address form, select their preferred Shipping Method, select a payment method, and place the order.
The shopping cart is cleared, the order is marked as Received, but the Product quantity is not adjusted yet, nor is a sales email sent to the customer.
The order is received, but the order details are not yet available because the order has not been fully processed.
It remains in the queue until the placeOrderProcess consumer begins, verifies the order with the inventory check feature (enabled by default), and updates the order as follows:
- Product available—the order status changes to Pending, the product quantity is adjusted, an email with order details is sent to the customer, and the successful order details become available for viewing in the Orders and Returns list with actionable options, such as reorder.
- Product out of stock or low supply—the order status changes to Rejected, the Product quantity is not adjusted, an email with order details about the issue is sent to the customer, and the rejected order details become available in the Orders and Returns list with no actionable options.
Cron should be working then it queue will be process otherwise all the process will be in Pending status and order will never process.
Once all the order process has been done so order will be show at the admin end and customer get the order confirmation mail.
Let understand the code flow.
When the customer placed a order so customer gets the order as ‘received‘ status and customer can’t perform any action.
All the order related data comes into the sales_order table and where only few data are present like quote_id, store_id, customer_id etc as compared to normal order. (Shipping and payment info are not saved into it yet.)
When queue runs so MagentoAsyncOrderModelConsumer calls it’s process() function where get the order related data like payment, shipping method and address from the queue_message table.
and then proceed for order management and MagentoCheckoutModelPaymentInformationManagement calls it’s function savePaymentInformationAndPlaceOrder() and it’s saves payment Information, shipping Address and then it placed an order.
AsyncOrder compatibility
Category | Supported Feature |
Checkout types | OnePage Checkout Standard Checkout B2B Negotiable Quote |
Payment methods | Check/Money Order Cash on Delivery Braintree PayPal PayFlow Pro |
Shipping methods | All shipping methods are supported. |
Excluding payment methods
Developers can explicitly exclude certain payments methods from Asynchronous Order placement by adding them to the MagentoAsyncOrderModelOrderManagement::paymentMethods
array. Orders that use excluded payment methods are processed synchronously.
Example..
<type name="MagentoAsyncOrderModelOrderManagement"> <arguments> <argument name="paymentMethods" xsi:type="array"> <item name="hosted_pro" xsi:type="string">hosted_pro</item> <item name="payflow_advanced" xsi:type="string">payflow_advanced</item> <item name="payflow_link" xsi:type="string">payflow_link</item> </argument> </arguments> </type>
Source link
Leave a Reply