我使用以下代码创建订单,但获取异常为"请指定送货方式".还有付款方式,代码说无效.请告诉我在哪里可以查看这些运费和付款方式.请详细解释. magento初学者
<?php
include 'connect.php';
$db=mysqli_select_db($conn,'onceaga9_aw');
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
umask(0);
Mage::app();
extract($_POST);
$productids = array(983);
$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')
->setWebsiteId($websiteId)
->loadByEmail($email);
if ($customer->getId() == "") {
$customer = Mage::getModel('customer/customer');
$customer->setWebsiteId($websiteId)
->setStore($store)
->setFirstname('Jhon')
->setLastname('Deo')
->setEmail($email)
->setPassword("password");
$customer->save();
}
// Assign Customer To Sales Order Quote
$quote->assignCustomer($customer);
// Configure Notification
$quote->setSendCconfirmation(1);
foreach ($productids as $id)
{
$product = Mage::getModel('catalog/product')->load($id);
$quote->addProduct($product, new Varien_Object(array('qty' => 1)));
}
// Set Sales Order Billing Address
$billingAddress = $quote->getBillingAddress()->addData(array(
'customer_address_id' => '',
'prefix' => '',
'firstname' => 'john',
'middlename' => '',
'lastname' => 'Deo',
'suffix' => '',
'company' => '',
'street' => array(
'0' => 'Noida',
'1' => 'Sector 64'
),
'city' => 'Noida',
'country_id' => 'IN',
'region' => 'UP',
'postcode' => '201301',
'telephone' => '78676789',
'fax' => 'gghlhu',
'vat_id' => '',
'save_in_address_book' => 1
));
// Set Sales Order Shipping Address
$shippingAddress = $quote->getShippingAddress()->addData(array(
'customer_address_id' => '',
'prefix' => '',
'firstname' => 'john',
'middlename' => '',
'lastname' => 'Deo',
'suffix' => '',
'company' => '',
'street' => array(
'0' => 'Noida',
'1' => 'Sector 64'
),
'city' => 'Noida',
'country_id' => 'IN',
'region' => 'UP',
'postcode' => '201301',
'telephone' => '78676789',
'fax' => 'gghlhu',
'vat_id' => '',
'save_in_address_book' => 1
));
if ($shipprice == 0) {
$shipmethod = 'freeshipping_freeshipping';
}
// Collect Rates and Set Shipping & Payment Method
$shippingAddress->setCollectShippingRates(true)
->collectShippingRates()
->setShippingMethod('flatrate_flatrate')
->setPaymentMethod('checkmo');
// Set Sales Order Payment
//$quote->getPayment()->importData(array('method' => 'checkmo'));
$quote->setShippingMethod('flatrate_flatrate');
// Collect Totals & Save Quote
$quote->collectTotals()->save();
try {
// Create Order From Quote
$service = Mage::getModel('sales/service_quote', $quote);
$service->submitAll();
$increment_id = $service->getOrder()->getRealOrderId();
}
catch (Exception $ex) {
echo $ex->getMessage();
}
catch (Mage_Core_Exception $e) {
echo $e->getMessage();
}
// Resource Clean-Up
$quote = $customer = $service = null;
// Finished
return $increment_id;
?>
最新回答
- 2019-12-51 #
- 2019-12-52 #
代表不会让我发表评论.但是在尝试这个时我收到了一个错误.在1.9
无效方法Mage_Customer_Model_Address :: collectShippingRates(Array())
相关问题
- magento 1.9:以正确的方式创建报价地址magento1.9magentoshippingmagentoshippingmethodsmagentoquotemagentoshippingaddress2019-12-05 21:45
- magento2:运营商/ shipping_code(默认/运营商/ shipping_code /类型)下的类型含义是什么?magento2magentocheckoutmagentoshippingmagentoshippingmethodsmagento2.02019-12-05 21:40
- checkout:当格兰特为零时,Magento 19跳过付款方法步骤magento1.9magentocheckoutmagentoordersmagentopaymentmethodsmagentograndtotal2019-12-05 21:44
- magento 1.9:选择默认送货方式magento1.9magentoshippingmethods2019-12-05 21:42
- magento 1.9:无法结帐错误在下订单之前,请同意所有条款和条件magento1.9magentocheckoutmagentotemplatemagentoprogrammingmagentotermsandconditions2019-12-05 21:42
更改以下代码:
为:
在上面的代码中,您使用送货方式统一费率,确保启用统一费率。
使用以下代码的付款方式相同,您使用支票汇票,确保启用