Hi to all!
First, excuse me if my question not in the correct forum group, but let me ask!
As payment module developer, I am curious about the following case:
a customer add an item into the Cart and go to the checkout page. Select a provider and click on the "pay" button. But in same moment someone else get the last item. Do Magento system care for this case, for example preserve some minimal item quantity or the the payment plugin must care?
If non care it happens the client go to some redirect payment page and pay, then return to the shop site and see the message like "Your item is no more available". At the end the money are gone and an Order is not made, but Cart is active.
If my plugin must made last check for item quantity, what is the best approach to do it? Checking quantity for a simple product is not a problem, but when I tried to check the quantity of variable product (by color) I failed.
Thanks!
Hello @mpstoevgmaea24
To handle the scenario where a customer's payment is processed, but the item they purchased is no longer available in Magento 2, please follow the steps below:
php $order = $observer->getEvent()->getOrder(); $comment = "Your item is no longer available."; $order->addStatusHistoryComment($comment)->setIsCustomerNotified(false); $order->save();
php $emailTemplate = $this->_transportBuilder ->setTemplateIdentifier('custom_email_template') ->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId]) ->setTemplateVars(['order' => $order]) ->setFrom($sender) ->addTo($customerEmail) ->getTransport(); $emailTemplate->sendMessage();
If you find our reply helpful, please give us kudos.
A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.
WebDesk Solution Support Team
Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Thank You,
WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Location: 150 King St. W. Toronto, ON M5H 1J9
Hi!
Thanks for the advice, but this observers fires too late. I need this check to be done after I click on pay button, but before submit the checkout form.
After the order is saved is too late to check if the product is available, because the money are gone
If someone else can recommend the me the best Magento method to check for product quantity I have a place to call it.
Regards!
It is always a good practice to check the item quantity before making a payment to avoid any discrepancies or overcharges. This is especially important when dealing with top cyber security companies in Dubai, as they may have complex pricing structures or offer additional services that could impact the final amount due. By double-checking the number of items being purchased, you can ensure that you are paying the correct amount and avoid any potential billing issues. Additionally, it is recommended to review the invoice or receipt provided by the company to confirm that all charges are accurate and accounted for.