AI in Development
Clusterify.AI
© 2025 All Rights Reserved, Clusterify Solutions FZCO
AI-Driven Sales: The New Playbook to Maximize Ecommerce ROI
Secure MCP Server with Python and NextJS
Guide to Securing MCP AI Servers 2of2
Guide to Securing MCP AI Servers 1of2
NEW Conditional Logic in CSS: From Classic CSS Techniques to the New if() Function
GraphQL May Expose Promo Codes in Magento 2.4.8
March 24, 2025
AI in Development
I found it interesting! I asked multiple AI models about what is the best way to implement an after plugin in Magento 2 that runs when order has been placed.
I got different answers, but very interesting. What do you think, please let me know what you would choose.
The best class to implement an after plugin for place order in Magento 2 depends on your specific use case, but here’s a comparison:
✅ Best for:
✅ When to use:
🔹 Example Use Cases:
🔹 Plugin Method:
public function afterSavePaymentInformationAndPlaceOrder( \Magento\Checkout\Model\PaymentInformationManagement $subject, $orderId, $cartId, \Magento\Quote\Api\Data\PaymentInterface $paymentMethod, \Magento\Quote\Api\Data\AddressInterface $billingAddress = null ) { // Your logic here return $orderId; }
✅ Best for:
✅ When to use:
🔹 Example Use Cases:
🔹 Plugin Method:
public function afterSubmit( \Magento\Quote\Model\QuoteManagement $subject, $order, \Magento\Quote\Model\Quote $quote, $orderData = [] ) { // Your logic here return $order; }
For most cases, PaymentInformationManagement is the better choice because it ensures the order is already successfully placed before your plugin runs.