1

Checkout with Multiple Addresses and Onepage. Both save at sales_order table in database. But I don't know what function it call to save at sales_order table. Who can help me?

This is my di.xml

<config>
    <type name="Magento\Multishipping\Model\Checkout\Type\Multishipping">
        <plugin name="logging-checkout-multi" type="TTV\OrderLog\Plugin\Log" sortOrder="1"/>
    </type>
    <type name="Magento\Checkout\Model\PaymentInformationManagement">
        <plugin name="logging-checkout" type="TTV\OrderLog\Plugin\Log" sortOrder="2"/>
    </type>
</config>

function in TTV\OrderLog\Plugin|Log

    public function beforeSavePaymentInformationAndPlaceOrder()
    {
        $this->_log->pushHandler(new \Monolog\Handler\StreamHandler('var/log/information.log'));
        $productList = $this->_sessionCheckout->getQuote()->getAllVisibleItems();
        foreach ($productList as $product) {
            $productName = $product->getName();
            $productQty = $product->getQty();
            $productPrice = $product->getPrice();
            $this->_log->info("Product Name: " . $productName . " - " . "Product Quantity: " . $productQty . " - " . "Product Price: " . $productPrice);
        }
    }
1

1 Answer 1

1

1) For the multishipping:

vendor/magento/module-multishipping/Controller/Checkout/OverviewPost.php

 public function execute()
{
    ......
    $this->_getCheckout()->createOrders();
    ......
}

2) For the onepage checkout, Magento uses API: /V1/carts/mine/payment-information

vendor/magento/module-checkout/Model/PaymentInformationManagement.php

public function savePaymentInformationAndPlaceOrder(
        $cartId,
        \Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
        \Magento\Quote\Api\Data\AddressInterface $billingAddress = null
    ) {
        $this->savePaymentInformation($cartId, $paymentMethod, $billingAddress);
        return $this->cartManagement->placeOrder($cartId);
}
11
  • i know but i think it call at 1 function (exam call API). Because i want create a plugin for both Jan 11, 2017 at 3:14
  • Which is your purpose, you can explain more. I think we can use Observer. Jan 11, 2017 at 3:21
  • i must use plugin. And if follow your answer. I will create two plugin. But i just want create one. Please help me. Jan 11, 2017 at 3:31
  • You can explain more, I think I can give you the solution. But, I need to know more about your purpose. Please update your question with more details. Jan 11, 2017 at 3:34
  • this function savePaymentInformationAndPlaceOrder <- it call at Magento\Checkout\Model\PaymentInformationManagement ???? Jan 11, 2017 at 3:55

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.