Skip to content

Instantly share code, notes, and snippets.

@geekwho-eth
Forked from brankoajzele/gist:2781404
Created June 18, 2014 17:44
Show Gist options
  • Save geekwho-eth/b596e20d6e0431515637 to your computer and use it in GitHub Desktop.
Save geekwho-eth/b596e20d6e0431515637 to your computer and use it in GitHub Desktop.
<?php
require_once 'app/Mage.php';
Mage::app();
$quote = Mage::getModel('sales/quote')
->setStoreId(Mage::app()->getStore('default')->getId());
$product = Mage::getModel('catalog/product')->load(6); /* 6 => Some product ID */
$buyInfo = array('qty' => 1);
$quote->addProduct($product, new Varien_Object($buyInfo));
$billingAddress = array(
'firstname' => 'Branko',
'lastname' => 'Ajzele',
'company' => 'Inchoo',
'email' => 'branko@inchoo.net',
'street' => array(
'Sample Street Line_1',
'Sample Street Line_2'
),
'city' => 'City',
'region_id' => '',
'region' => 'State/Province',
'postcode' => '12345',
'country_id' => 'NL',
'telephone' => '1234567890',
'fax' => '123456987',
'customer_password' => '',
'confirm_password' => '',
'save_in_address_book' => '0',
'use_for_shipping' => '1',
);
$quote->getBillingAddress()
->addData($billingAddress);
$quote->getShippingAddress()
->addData($billingAddress)
->setShippingMethod('tablerate_bestway')
->setPaymentMethod('checkmo')
->setCollectShippingRates(true)
->collectTotals();
$quote->setCheckoutMethod('guest')
->setCustomerId(null)
->setCustomerEmail($quote->getBillingAddress()->getEmail())
->setCustomerIsGuest(true)
->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
$quote->getPayment()->importData( array('method' => 'checkmo'));
$quote->save();
$service = Mage::getModel('sales/service_quote', $quote);
$service->submitAll();
//$order = $service->getOrder();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment