我不知道如何指定这个问题,我想要的是,我必须从外部文件调用购物车页面,其中产品ID和数量存储在sales_flat_quote_item表中,我必须显示这个产品在购物车。我试着打电话
header( 'Location: ' . Mage::getUrl('checkout/cart/'));
我所做的也与此相关:请去核实。
$orderid=$_GET['orderId'];
//$_GET['orderId'];
$cusid=$_GET['customer'];
//$_GET['customer'];
require_once "app/Mage.php";
Mage::app();
Mage::getSingleton('core/session', array('name'=>'frontend') );
Mage::getSingleton('customer/session')->loginById($cusid);
$sql = Mage::getSingleton('core/resource')->getConnection('core_write');
$result=$sql->query('select
sales_flat_quote_item.product_id,sales_flat_quote_item.weight,sales_flat_quote_item.qty,sales_flat_quote_item.price
from sales_flat_quote left outer join sales_flat_quote_item on sales_flat_quote.entity_id=sales_flat_quote_item.quote_id
Where sales_flat_quote.entity_id='.$orderid);
while($row=$result->fetch(PDO::FETCH_ASSOC))
{
$pid=$row['product_id'];
//print_r($id); .'&qty='.$qty
$qty=$row['qty'];
//print_r($qty);
}
$carthelp = Mage::helper('checkout/cart')->getQuote()->getId();
//$cart = Mage::getSingleton('checkout/cart');
//$cart->save();
/*$cart = Mage::getSingleton('checkout/cart')->loadbyId($carthelp);
$cart->save();
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);*/
//echo Mage::getUrl('../index.php/checkout/cart/');
//header('Location: '.Mage::getUrl('../index.php/checkout/cart/'));
/*$url = Mage::getModel('core/url')
->getUrl("/../index.php/checkout/cart/index");
Mage::app()
->getResponse()
->setRedirect($url);
Mage::app()
->getResponse()
->sendResponse();
header( 'Location: ' . $url ); */
//header( 'Location: ' . Mage::getUrl('../index.php/checkout/cart/'));
但是会重定向到空的购物车页面。
我试图解决这个问题超过24小时,但结果是一样的。请帮帮我。
先谢谢。
答案 0 :(得分:1)
你做得有点不对劲。尝试先设定一些目标:
答案 1 :(得分:1)
谢谢你,
我终于明白了。 我们必须在调用购物车之前将quote-Id加载到结帐会话
Mage::getSingleton('checkout/session')->setQuoteId($orderid);
$cart = Mage::getSingleton('checkout/cart');
header('Location: '.Mage::getUrl('../index.php/checkout').'cart');