更新时间:2023-11-30 08:17:10
我以前使用自己创建的一种送货方式解决了这个问题.
I solves this times ago by using a shipping method i created myself.
创建订单的代码也从后端单例更改为前端方法",如下所示:
The code to create the order also changed from the backend singleton a 'frontend method' like this:
// Get the Quote to save the order
$quote = Mage::getModel('sales/quote')->setStoreId($storeId);
// Set the customer
$quote->setCustomer($customer);
// Add the product with the product options
$quote->addProduct($product, new Varien_Object($productOptions));
// Add the address data to the billing address
$billingAddress = $quote->getBillingAddress()->addData($addressData);
// Add the adress data to the shipping address
$shippingAddress = $quote->getShippingAddress()->addData($addressData);
// Collect the shipping rates
$shippingAddress->setCollectShippingRates(true)->collectShippingRates();
// Set the shipping method /////////// Here i set my own shipping method
$shippingAddress->setShippingMethod($shippingMethod);
// Set the payment method
$shippingAddress->setPaymentMethod($paymentMethod);
// Set the payment method
$quote->getPayment()->importData(array('method' => $paymentMethod));
// Collect the prices
$quote->collectTotals()->save();
// Get the service to submit the order
$service = Mage::getModel('sales/service_quote', $quote);
// Submit the order
$service->submitAll();
// Get the new order
$newOrder = $service->getOrder();
// Get payment instance
$payment = $newOrder->getPayment();
// Set the buyer data
$this->_importPaymentInformation($payment, $order);
// Set the transaction data
$payment->setData('last_trans_id', $order['transNrPurchaseForReceiver']);
// Save the payment changes
$payment->save();
// Set the order state and save the order
$newOrder->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $comment)->save();