Magento Coding Solutions

Programmatic Add to cart product and there options and supper attribute etc in Magento

******************************************
Programmatic Add to cart and option in Magento
**************************************
<?php
$carturl = Mage::getBaseUrl()."checkout/cart/";
$cart = Mage::getSingleton('checkout/cart');
$cart->addProduct($productIdtoadd, array(
'qty' => $qty,
'total_price'=>$total,
'super_attribute' => array($attributeid =>$assproductColorOptionId),
'options' =>array($option_id=> $value,
                                                          $width_option_id => $width,

 )
)
);

$cart->save();
echo "<script language='javascript'>location.href='".$carturl."'</script>";

?>

No comments:

Post a Comment