首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重定向至结帐保存订单页面

重定向至结帐保存订单页面
EN

Stack Overflow用户
提问于 2013-09-19 12:54:33
回答 1查看 646关注 0票数 0

我尝试使用以下链接以编程方式创建订单:http://pastebin.com/8cft4d8v#。问题是:在我保存我的报价后,如何重定向到结帐/页面/保存顺序?我尝试重定向,但它显示‘访问网页被拒绝’;

下面是我的代码:

代码语言:javascript
复制
$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);
EN

回答 1

Stack Overflow用户

发布于 2013-09-19 18:47:02

以编程方式创建订单后,您可以重定向至订单成功页面。为什么要转到订单保存页面。您可以在保存报价后保存订单。使用$this->_redirect进行重定向

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18886433

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档