Using the following code, you can create an order including custom options programmatically.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
$quote = Mage::getModel('sales/quote')->setStoreId(Mage::app()->getStore('default')->getId()); $quote->setCustomerEmail($mail); $product = Mage::getModel('catalog/product')->load($productId); $buyInfo = array( 'qty' => 1, 'options' => array($optionId => $optionValue) ); $quote->addProduct($product, new Varien_Object($buyInfo)); $addressData = array( 'firstname' => $firstName, 'lastname' => $lastName, 'street' => $street, 'city' => $city, 'postcode' => $postCode, 'telephone' => '-', 'country_id' => $country, 'region_id' => $regionId, ); $billingAddress = $quote->getBillingAddress()->addData($addressData); $shippingAddress = $quote->getShippingAddress()->addData($addressData); $shippingAddress->setCollectShippingRates(true)->collectShippingRates() ->setShippingMethod('flatrate_flatrate') ->setPaymentMethod('bankpayment'); $quote->getPayment()->importData(array('method' => 'bankpayment')); $quote->collectTotals()->save(); $service = Mage::getModel('sales/service_quote', $quote); $service->submitAll(); $order = $service->getOrder(); // ... |
Creating order including custom options programmatically
You want or need help implementing this solution? Maybe you did not find what you were looking for? Contact me and I will assist you with whatever Magento problem troubles you!