0

I need to create an order programmatically where both the payment method and shipping method will not be coming from the list provided for in Magento. Is this actually possible?

    $quote->getBillingAddress()->addData($address);
    $quote->getShippingAddress()->addData($shippingAddress);

    $shippingAddress = $quote->getShippingAddress();

    $shippingAddress->setCollectShippingRates(true)
                    ->collectShippingRates()
                    ->setShippingMethod('freeshipping_freeshipping'); //shipping method
    $quote->setPaymentMethod('checkmo');
    $quote->setInventoryProcessed(true);
    $quote->save();

    $quote->getPayment()->importData(['method' => 'checkmo']);

    $quote->collectTotals()->save();

I am tasked with having to create a plugin that "imports" the orders from a non Magento website (just like eBay) and then saving them as Magento orders. Since the non magento website have their own payment method and the fact that the orders has already been paid for in the other site, I just need to reflect on the Magento order the payment of the details and how much the shippment amount is, instead of recomputing them. Is this actually possible?

1 Answer 1

0

Ok I finally fixed this issue by manually inserting order data into the following tables:

m_sales_order
m_sales_order_grid
m_sales_order_address
m_sales_order_item
m_sales_order_payment
m_sales_order_status_history

Seems to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.