cancel
Showing results for 
Search instead for 
Did you mean: 

There was an error processing your order. Please contact us or try again later.

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

There was an error processing your order. Please contact us or try again later.

magento 1.9.3.7

<?php
//https://magento.stackexchange.com/questions/223220/creating-order-programatically-showing-wrong-grand-total

	error_reporting(E_ALL);
	require 'app/Mage.php';
	Mage::init();
	Mage::app('default');
	$storeId = Mage::app()->getStore()->getId();
  $Quote = Mage::getModel('sales/quote')->setStoreId($storeId);
  $Customer = Mage::getModel('customer/customer')->load(410); // insert customer ID  
	$_product = Mage::getModel('catalog/product')->load(168789);
	
	
   // Assign Customer To Sales Order Quote
    $Quote->assignCustomer($Customer);
    $address =  $Customer->getDefaultBillingAddress();
    $Quote->getBillingAddress()->importCustomerAddress($address);
    $Quote->getShippingAddress()->importCustomerAddress($address);
    $Quote->setSendCconfirmation(0);

    // Loop to add order. $Item contains the Sku, Qty, Price
    try 
    {
      $Quote->addProduct($_product, new Varien_Object(array('qty' => 1)));
      $Quote->save();
      $QuoteItem = $Quote->getItemByProduct($_product);
      $QuoteItem->setOriginalCustomPrice(49);
      $QuoteItem->setCustomPrice(49);
      $QuoteItem->setIsSuperMode(true);
      $QuoteItem->save();
    }
    catch (Exception $e) 
    {
      echo 'Caught exception: ',  $e->getMessage(), "<br>";
      print "Product ID: " . $_product->getId() . "<br>\n";
      print "Product Sku: " . $_product->getSku() . " - " . $_product->getName() . "<hr>\n";
    }

		//saving order
    try 
    {
        $Quote->collectTotals()->save();
        $Quote->getShippingAddress()
            ->setCollectShippingRates(true)
            ->collectShippingRates()
            ->setShippingMethod('flatrate_flatrate');
        $Quote->getPayment()->setMethod('paypal_express');
        // Create Order From Quote
         $service = Mage::getModel('sales/service_quote', $Quote);
         $service->submitAll();
         $increment_id = $service->getOrder()->getRealOrderId();
    }
    catch (Exception $e) { echo $e->getTraceAsString(); }
  	catch (Mage_Core_Exception $e) { echo $e->getMessage();	} 
 
?>

ytryertn.jpg

 

any idea what I do wrong?

2 REPLIES 2

Re: There was an error processing your order. Please contact us or try again later.

exception.log shows this:
Exception: PayPal response hasn't required fields.

 

now, what field am I missing?

Re: There was an error processing your order. Please contact us or try again later.

my goal is:

 

I'm having 15000 orders created in cubecart, that I want imported. Most orders are complete, but nice to have for historic data. About 100 orders are pending....

 

As a worse case we can maybe use the old system to process old orders.