php - How can order place for multiple product from custom page after select multiple qty in magento? -
i created custom page, displaying product qty button. here can choose multiple products. after want order place of selected products. how can place order multiple product? plugin available in magento?
i in need of same functionality, ended using own script instead of plugin. below complete code of placing order programatically. hope helps.
<?php $transaction = mage::getmodel('core/resource_transaction'); $increment_ids = array(); if ($orderdata) { try { $reservedorderid = mage::getsingleton('eav/config')->getentitytype('order')->fetchnewincrementid($store_id); $order = mage::getmodel('sales/order') ->setincrementid($reservedorderid) ->setstoreid($store_id) ->setquoteid(0) ->setglobal_currency_code('usd') ->setbase_currency_code('usd') ->setstore_currency_code('usd') ->setorder_currency_code('usd'); //saving customer $order->setcustomer_email($orderdata['email']) ->setcustomerfirstname($orderdata['firstname']) ->setcustomerlastname($orderdata['lastname']) ->setcustomergroupid(1) ->setcustomer_is_guest(1); $regionmodel = mage::getmodel('directory/region')->loadbycode("ca", 'us'); $shippingaddress = mage::getmodel('sales/order_address') ->setstoreid($storeid) ->setaddresstype(mage_sales_model_quote_address::type_shipping) ->setfirstname($orderdata['firstname']) ->setlastname($orderdata['lastname']) ->setstreet($orderdata['shipping']['line']) ->setcity($orderdata['shipping']['city']) ->setregion($orderdata['shipping']['region']) ->setregionid($regionmodel->getid()) ->setcountry_id('us') ->setpostcode($orderdata['shipping']['postcode']) ->settelephone($orderdata['shipping']['telephone']); $order->setshippingaddress($shippingaddress) ->setshipping_method($orderdata['shipping_method']) ->setshippingdescription($orderdata['shipping_description']); //get region code $regionmodel = mage::getmodel('directory/region')->loadbycode($orderdata['billing']['region'], 'us'); // set billing address $billingaddress = mage::getmodel('sales/order_address') ->setstoreid($storeid) ->setaddresstype(mage_sales_model_quote_address::type_shipping) ->setfirstname($orderdata['firstname']) ->setlastname($orderdata['lastname']) ->setstreet($orderdata['billing']['line']) ->setcity($orderdata['billing']['city']) ->setregion($regionmodel->getname()) ->setregionid($regionmodel->getid()) ->setcountry_id('us') ->setpostcode($orderdata['billing']['postcode']) ->settelephone($orderdata['billing']['telephone']); $order->setbillingaddress($billingaddress); //save products $subtotal = 0; $productprice=0; $qtytotal=0; foreach ($orderdata['items'] $key=>$product) { $_product = mage::getmodel('catalog/product')->load($key); $rowtotal = $_product->getprice() * $product; $orderitem = mage::getmodel('sales/order_item') ->setstoreid($storeid) ->setquoteitemid(0) ->setquoteparentitemid(null) ->setproductid($key) ->setproducttype($_product->gettypeid()) ->setqtybackordered(null) ->settotalqtyordered($product) ->setqtyordered($product) ->setname($_product->getname()) ->setsku($_product->getsku()) ->setprice(($_product->getprice())) ->setbaseprice($_product->getprice()) ->setoriginalprice($_product->getprice()) ->setrowtotal($rowtotal) ->setbaserowtotal($rowtotal); $qtytotal += $product; $subtotal += $rowtotal; $order->additem($orderitem); } $grandtotal = ($subtotal+$orderdata['shipping_charge'])-$orderdata['discount']; $orderpayment = mage::getmodel('sales/order_payment') ->setstoreid($store_id) ->setcustomerpaymentid(0) ->setmethod('purchaseorder') ->setpo_number($reservedorderid); $order->setpayment($orderpayment); //date_default_timezone_set('america/los_angeles'); $order->setsubtotal($subtotal) ->setstate('processing') ->setstatus('processing') ->setcouponcode($orderdata['coupon']) ->setbasediscountamount($orderdata['discount']) ->setbasegrandtotal($grandtotal) ->setbasesubtotal($subtotal) ->setbasetotalinvoiced($grandtotal) ->setbasetotalqtyordered($qtytotal) ->setdiscountamount($orderdata['discount']) ->setgrandtotal($grandtotal) ->setsubtotal($subtotal) ->settotalqtyordered($qtytotal) ->setbasetotaldue($grandtotal) //->setcreatedat(date('y-m-d')) //->setupdatedat(date('y-m-d')) ->settotalitemcount($order_detail['qty']) ->setshippingamount($orderdata['shipping_charge']) ->setbaseshippingamount($orderdata['shipping_charge']); $transaction->addobject($order); $transaction->addcommitcallback(array($order, 'place')); $transaction->addcommitcallback(array($order, 'save')); $transaction->save(); $order_data = $order->getdata(); $order_id = $order_data['increment_id']; $order->sendneworderemail(); } catch (exception $e) { $finalresult=array('exception',$e->getmessage()); } }
Comments
Post a Comment