Reputation: 37
I don't know how to specify this Question, What I want is that , I Have to call the cart page from an external file, where Product id's and quantity are store in sales_flat_quote_item table and I have to show this product in cart. I tried calling
header( 'Location: ' . Mage::getUrl('checkout/cart/'));
and what I have done is also attaching to this : please go and verify it.
$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/'));
But is get redirects to the empty cart page.
I tried to figure this out for over 24 hours, But results are same. Please help me.
Thanks in Advance.
Upvotes: 0
Views: 1850
Reputation: 37
Thank You Anton,
I finally figure it out. We have to load the quote-Id to the the checkout session before calling cart
Mage::getSingleton('checkout/session')->setQuoteId($orderid);
$cart = Mage::getSingleton('checkout/cart');
header('Location: '.Mage::getUrl('../index.php/checkout').'cart');
Upvotes: 1
Reputation: 12750
You are doing it slightly wrong. Try to set some goals first:
Upvotes: 1