Showing posts with label cart. Show all posts
Showing posts with label cart. Show all posts
Monday, September 26, 2016
Friday, May 3, 2013
Magento-Get information of Items in Cart
Magento-Get Information of Items in Cart
$items=Mage::getSingleton('Checkout/Session')->getQuote()->getAllItems();
foreach($items as $item)
{
echo $item->getName();
->getQty();
->getPrice();
->getSku();
->getProductid()
}
$items=Mage::getSingleton('Checkout/Session')->getQuote()->getAllItems();
foreach($items as $item)
{
echo $item->getName();
->getQty();
->getPrice();
->getSku();
->getProductid()
}
Labels:
cart,
checkout,
get,
getAllItems,
getQuote,
getSingleton,
information,
Items,
magento,
session
Tuesday, December 11, 2012
Oscommerce Add products to cart manually
In order to add products manually by Id or customize cart manually in OSCommerce
we need to first include the following file
require("includes/application_top.php")
What this does is automatically includes the following class
require(DIR_WS_CLASSES . 'shopping_cart.php');(line 126)
and instantiates an object of class
if (!tep_session_is_registered('cart') || !is_object($cart)) {
tep_session_register('cart');
$cart = new shoppingCart;
}
or you can yourself include these files and create an object
But for any action in oscommerce I prefer to include application_top.php
If you are building up a new cart add
$cart->reset();
This will reset your cart which is only required if you are planning to add a new cart in my case I was sending all Items from another website to my oscommerce website so I decided to reset cart first
Now let us suppose we have item information in an array $items
foreach($items as $item)
foreach($items as $item)
{
$attributes = isset($HTTP_POST_VARS['id']) ? $HTTP_POST_VARS['id'] : '';
$cart->add_cart($item['id'],$item['quant'],$attributes);
//In case cart is not empty and you want to add quantity to an item
$cart->add_cart($item['id'], $cart->get_quantity('$item['id']')+1);
}
$cart->add_cart($item['id'],$item['quant'],$attributes);
//In case cart is not empty and you want to add quantity to an item
$cart->add_cart($item['id'], $cart->get_quantity('$item['id']')+1);
}
Then add the following lines
//Cleans any product with quantity zero
$cart->cleanup();
$cart->cleanup();
//Calculates the weight and total cost in all finalizes your cart
$cart->calculate();
That's All
That's All
Subscribe to:
Posts (Atom)