Guest User

create order

a guest
Dec 9th, 2019
158
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. require_once 'app/Mage.php';
  3.  
  4. Mage::app();
  5.  
  6. $quote = Mage::getModel('sales/quote')
  7.         ->setStoreId(Mage::app()->getStore('default')->getId());
  8.  
  9. $product = Mage::getSingleton('checkout/cart')->getItems(); /* Get Items From Cart?? */
  10. //$product = Mage::getModel('catalog/product')->load(87561); /* 6 => Some product ID */
  11. $buyInfo = array('qty' => 1);
  12. $quote->addProduct($product, new Varien_Object($buyInfo));
  13.  
  14. $billingAddress = array(
  15.     'firstname' => 'My',
  16.     'lastname' => 'Name',
  17.     'company' => 'None',
  18.     'email' =>  'asdf@asdf.com',
  19.     'street' => array(
  20.         'Sample Street Line_1',
  21.         'Sample Street Line_2'
  22.     ),
  23.     'city' => 'City',
  24.     'region_id' => '',
  25.     'region' => 'State/Province',
  26.     'postcode' => '12345',
  27.     'country_id' => 'DE',
  28.     'telephone' =>  '1234567890',
  29.     'fax' => '123456987',
  30.     'customer_password' => '',
  31.     'confirm_password' =>  '',
  32.     'save_in_address_book' => '0',
  33.     'use_for_shipping' => '1',
  34. );
  35. $quote->getBillingAddress()
  36.         ->addData($billingAddress);
  37. $quote->getShippingAddress()
  38.         ->addData($billingAddress)
  39.         ->setShippingMethod('solutioo')
  40.         ->setPaymentMethod('cashondelivery')
  41.         ->setCollectShippingRates(true)
  42.         ->collectTotals();
  43. $quote->setCheckoutMethod('guest')
  44.             ->setCustomerId(null)
  45.             ->setCustomerEmail($quote->getBillingAddress()->getEmail())
  46.             ->setCustomerIsGuest(true)
  47.             ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
  48. $quote->getPayment()->importData( array('method' => 'cashondelivery'));
  49. $quote->save();
  50. $service = Mage::getModel('sales/service_quote', $quote);
  51. $service->submitAll();
  52. //$order = $service->getOrder();
RAW Paste Data