我尝试使用以下链接以编程方式创建订单:http://pastebin.com/8cft4d8v#。问题是:在我保存我的报价后,如何重定向到结帐/页面/保存顺序?我尝试重定向,但它显示‘访问网页被拒绝’;
下面是我的代码:
$productid = Mage::app()->getRequest()->getParam('value');
$payment = Mage::app()->getRequest()->getParam('payment');
$session = Mage::getSingleton('customer/session');
if(!$session->isLoggedIn())
{
//login
$username = Mage::app()->getRequest()->getParam('username');
$password = Mage::app()->getRequest()->getParam('password');
try
{
$result = $session->login($username,$password);
}
catch(Mage_Core_Exception $e)
{
$response['status'] = 0;
$response['message'] = $e->getMessage();
echo Zend_Json::encode($response);
return false;
}
$session->setCustomerAsLoggedIn($session->getCustomer());
}
$cust_id = $session->getId();
$customer = Mage::getModel('customer/customer')->load($cust_id);
$quote = Mage::getModel('sales/quote')
->setStoreId(Mage::app()->getStore('default')->getId());
$quote->assignCustomer($customer);
// add product(s)
$product = Mage::getModel('catalog/product')->load($productid);
$buyInfo = array(
'qty' => 1,
);
$quote->addProduct($product, new Varien_Object($buyInfo));
$billing = $customer->getDefaultBillingAddress();
$addressData = array(
'firstname' => $billing->getFirstname(),
'lastname' => $billing->getLastname(),
'street' => $billing->getStreet(),
'city' => $billing->getCity(),
'postcode' => $billing->getPostcode(),
'telephone' => $billing->getTelephone(),
'country_id' => $billing->getCountryId(),
'region_id' => $billing->getRegionId());
$billingAddress = $quote->getBillingAddress()->addData($addressData);
$quote->getPayment()->importData(array('method' => $payment));
$quote->collectTotals()->save();
$response['status'] = 1;
echo Zend_Json::encode($response);发布于 2013-09-19 18:47:02
以编程方式创建订单后,您可以重定向至订单成功页面。为什么要转到订单保存页面。您可以在保存报价后保存订单。使用$this->_redirect进行重定向
https://stackoverflow.com/questions/18886433
复制相似问题