Skip to main content
orderRepository = $orderRepository;}public function aroundSavePaymentInformationAndPlaceOrder(\Magento\Checkout\Model\PaymentInformationManagement $subject,\Closure $proceed,$cartId,\Magento\Quote\Api\Data\PaymentInterface $paymentMethod,\Magento\Quote\Api\Data\AddressInterface $billingAddress = null){$result = $proceed($cartId, $paymentMethod, $billingAddress);if($result){$orderComment =$paymentMethod->getExtensionAttributes();if($orderComment->getComment())$comment = trim($orderComment->getComment());else$comment = '';$history = $order->addStatusHistoryComment($comment);$history->save();$order->setCustomerNote($comment);}return $result;}}Note:- if the field in payment step need to save in quote table then use beofore plugin for same function and follow as did in ShippingInformationManagementPlugin
<?php namespace Sugarcode\Deliverydate\Plugin\Checkout; /** * One page checkout processing model */ class PaymentInformationManagementPlugin { protected $orderRepository; public function __construct( \Magento\Sales\Api\OrderRepositoryInterface $orderRepository ) { $this->orderRepository = $orderRepository; } public function aroundSavePaymentInformationAndPlaceOrder( \Magento\Checkout\Model\PaymentInformationManagement $subject, \Closure $proceed, $cartId, \Magento\Quote\Api\Data\PaymentInterface $paymentMethod, \Magento\Quote\Api\Data\AddressInterface $billingAddress = null ) { $result = $proceed($cartId, $paymentMethod, $billingAddress); if($result){ $orderComment =$paymentMethod->getExtensionAttributes(); if ($orderComment->getComment()) $comment = trim($orderComment->getComment()); else $comment = ''; $history = $order->addStatusHistoryComment($comment); $history->save(); $order->setCustomerNote($comment); } return $result; } } 

Note :- if the field in payment step need to save in quote table then use beofore plugin for same function and follow as did in ShippingInformationManagementPlugin

orderRepository = $orderRepository;}public function aroundSavePaymentInformationAndPlaceOrder(\Magento\Checkout\Model\PaymentInformationManagement $subject,\Closure $proceed,$cartId,\Magento\Quote\Api\Data\PaymentInterface $paymentMethod,\Magento\Quote\Api\Data\AddressInterface $billingAddress = null){$result = $proceed($cartId, $paymentMethod, $billingAddress);if($result){$orderComment =$paymentMethod->getExtensionAttributes();if($orderComment->getComment())$comment = trim($orderComment->getComment());else$comment = '';$history = $order->addStatusHistoryComment($comment);$history->save();$order->setCustomerNote($comment);}return $result;}}Note:- if the field in payment step need to save in quote table then use beofore plugin for same function and follow as did in ShippingInformationManagementPlugin
<?php namespace Sugarcode\Deliverydate\Plugin\Checkout; /** * One page checkout processing model */ class PaymentInformationManagementPlugin { protected $orderRepository; public function __construct( \Magento\Sales\Api\OrderRepositoryInterface $orderRepository ) { $this->orderRepository = $orderRepository; } public function aroundSavePaymentInformationAndPlaceOrder( \Magento\Checkout\Model\PaymentInformationManagement $subject, \Closure $proceed, $cartId, \Magento\Quote\Api\Data\PaymentInterface $paymentMethod, \Magento\Quote\Api\Data\AddressInterface $billingAddress = null ) { $result = $proceed($cartId, $paymentMethod, $billingAddress); if($result){ $orderComment =$paymentMethod->getExtensionAttributes(); if ($orderComment->getComment()) $comment = trim($orderComment->getComment()); else $comment = ''; $history = $order->addStatusHistoryComment($comment); $history->save(); $order->setCustomerNote($comment); } return $result; } } 

Note :- if the field in payment step need to save in quote table then use beofore plugin for same function and follow as did in ShippingInformationManagementPlugin

<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Checkout\Block\Checkout\LayoutProcessor"> <plugin name="add-delivery-date-field" type="Sugarcode\Deliverydate\Model\Checkout\LayoutProcessorPlugin"type="Sugarcode\Deliverydate\Plugin\Checkout\LayoutProcessorPlugin" sortOrder="10"/> </type> </config> 
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Checkout\Block\Checkout\LayoutProcessor"> <plugin name="add-delivery-date-field" type="Sugarcode\Deliverydate\Model\Checkout\LayoutProcessorPlugin" sortOrder="10"/> </type> </config> 
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Checkout\Block\Checkout\LayoutProcessor"> <plugin name="add-delivery-date-field" type="Sugarcode\Deliverydate\Plugin\Checkout\LayoutProcessorPlugin" sortOrder="10"/> </type> </config> 
<type name="Magento\Checkout\Model\ShippingInformationManagement"> <plugin name="save-in-quote" type="Sugarcode\Deliverydate\Model\Checkout\ShippingInformationManagementPlugin"type="Sugarcode\Deliverydate\Plugin\Checkout\ShippingInformationManagementPlugin" sortOrder="10"/> </type> 
<type name="Magento\Checkout\Model\ShippingInformationManagement"> <plugin name="save-in-quote" type="Sugarcode\Deliverydate\Model\Checkout\ShippingInformationManagementPlugin" sortOrder="10"/> </type> 
<type name="Magento\Checkout\Model\ShippingInformationManagement"> <plugin name="save-in-quote" type="Sugarcode\Deliverydate\Plugin\Checkout\ShippingInformationManagementPlugin" sortOrder="10"/> </type> 
by using mixins
Source Link
Pradeep Kumar
  • 8.7k
  • 12
  • 64
  • 86
Loading
added 712 characters in body
Source Link
Pradeep Kumar
  • 8.7k
  • 12
  • 64
  • 86
Loading
Source Link
Pradeep Kumar
  • 8.7k
  • 12
  • 64
  • 86
Loading