我目前正在创建我的第一个自定义结帐页面在Magento。我有一个代码,它可以创建一个未支付的订单,所以下一步是根据所选的支付方法将客户重定向到第三方支付站点。
经过一些研究后,似乎有一个叫做redirectUrl的参数,我应该可以得到,但我真的不知道怎么得到。
如果我完全错了,请把我引向正轨!提前谢谢你。
<?php
require_once 'app/Mage.php';
Mage::app();
$quote = Mage::getModel('sales/quote')->setStoreId(Mage::app()->getStore('default')->getId());
// guest order
$quote->setCustomerEmail('customer@example.com');
// add sample product
$product = Mage::getModel('catalog/product')->load(8);
$buyInfo = array(
'qty' => 1,
);
$quote->addProduct($product, new Varien_Object($buyInfo));
$addressData = array(
'firstname' => 'Test',
'lastname' => 'Test',
'street' => 'Sample Street 10',
'city' => 'Somewhere',
'postcode' => '123456',
'telephone' => '123456',
'country_id' => 'SE'
);
$billingAddress = $quote->getBillingAddress()->addData($addressData);
$shippingAddress = $quote->getShippingAddress()->addData($addressData);
$shippingAddress->setCollectShippingRates(true)->collectShippingRates()->setShippingMethod('flatrate_flatrate')->setPaymentMethod('checkmo');
$quote->getPayment()->importData(array('method' => 'checkmo'));
$quote->collectTotals()->save();
$service = Mage::getModel('sales/service_quote', $quote);
$service->submitAll();
$order = $service->getOrder();
echo 'Created order #' . $order->getIncrementId();
?>发布于 2012-04-22 00:27:40
在示例代码中,您将Magento类使用到一个独立的PHP文件中。这样,Magento重定向将无法工作,因为它是来自Mage_Core_Controller_Front_Action的一种方法。您必须使用Magento控制器来尝试这种重定向方式。
无论如何,您可以使用PHP 标题函数:header("Location: http://somepayment.com/complexUrl"); die;
https://stackoverflow.com/questions/10261406
复制相似问题