Currently I make php script to generate order not logged in customer but i want to use this script for logged in customer dynamically for logged in customer my code is


$quote = Mage::getModel('sales/quote')


// for guest orders only:
// add product(s)
$product = Mage::getModel('catalog/product')->load(1307,1305);
$buyInfo = array(
'qty' => 1,
// custom option id => value id
// or
// configurable attribute id => value id
$quote->addProduct($product, new Varien_Object($buyInfo));
//$quote->addProduct($product2, new Varien_Object($buyInfo));
$addressData = array(
'firstname' => 'Test',
'lastname' => 'Test',
'street' => 'Sample Street 10',
'city' => 'Somewhere',
'postcode' => '123456',
'telephone' => '123456',
'country_id' => 'US',
'region_id' => 12, // id from directory_country_region table
$billingAddress = $quote->getBillingAddress()->addData($addressData);
$shippingAddress = $quote->getShippingAddress()->addData($addressData);
$quote->getPayment()->importData(array('method' => 'checkmo'));
echo "quote save";
$service = Mage::getModel('sales/service_quote', $quote);
echo "order save";
$order = $service->getOrder();
printf("Created order %s\n", $order->getIncrementId());
}catch(Exception $e){


this script is create order programaticaly for not loggedin customer

  • Is this the script exactly as you use it because it's not actually valid at the moment? For instance, there is a try catch without the opening try, and loading of the product is wrong - you can't pass 2 ids, only an id and a column to load() – Jonathan Hussey Nov 24 '15 at 9:32

Add bellow code in your file

// for login customer orders only:
$email = "customer@email.com";

$customer = Mage::getModel('customer/customer');


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.