我试着测试一个脚本来创建magento order。在最后一行“$service->getOrder()”上,代码似乎失败了;使用的货币是EUR,而客户ID是2(已经存在),我认为问题在于发送method.but不确定是否感谢任何帮助。
<?php
require_once 'app/Mage.php';
umask(0);
$websiteId = Mage::app() -> getWebsite() -> getId();
$store = Mage::app() -> getStore();
// Start New Sales Order Quote
$quote = Mage::getModel('sales/quote') -> setStoreId($store -> getId());
// Set Sales Order Quote Currency
//$quote -> setCurrency($order -> AdjustmentAmount -> currencyID);
$customer = Mage::getModel('customer/customer');
$customer -> load(2);
//customer already exist
// Assign Customer To Sales Order Quote
$quote -> assignCustomer($customer);
// Configure Notification
$quote -> setSendCconfirmation(1);
$product = Mage::getModel('catalog/product') -> load(92);
//product already exist
$quote -> addProduct($product, new Varien_Object( array('qty' => 1)));
$addressData = array('firstname' => 'Test', 'lastname' => 'Test', 'street' => 'Sample Street 10', 'city' => 'Somewhere', 'postcode' => '123456', 'telephone' => '123456', 'country_id' => 'FR', 'region_id' => 182, // id from directory_country_region table
);
$billingAddress = $quote -> getBillingAddress() -> addData($addressData);
$shippingAddress = $quote -> getShippingAddress() -> addData($addressData);
$shippingAddress -> setCollectShippingRates(true) -> collectShippingRates() -> setShippingMethod('freeshipping_freeshipping') -> setPaymentMethod('checkmo');
$quote -> getPayment() -> importData(array('method' => 'checkmo'));
$quote -> collectTotals();
$quote -> reserveOrderId();
$quote -> save();
$service = Mage::getModel('sales/service_quote', $quote);
$service -> submitAll();
$order = $service -> getOrder();
printf("Created order %s\n", $orderObj -> getIncrementId());
?>发布于 2016-03-11 10:06:55
您的问题很可能与当前地址验证的传送方法不可用:https://gyazo.com/13c1e692b92a8413594a75ababeba16d有关。
这样的结果,我可以在我的商店设置中看到免费送货(该地址不可用),如果我替换了我通常的地址,这是免费的,验证是成功的,并且您的代码完全工作,没有任何改变:https://gyazo.com/2496d809d2e16bcab6a0fb3f63270ed2。
https://stackoverflow.com/questions/35921867
复制相似问题