3

How can I programatically add Gift Card with message to cart ? I was able to add configurable and simple products; but not gif cards.

Thanks!

iqbalmp
  • 193
  • 7

1 Answers1

1

I got the solution, by adding gift cart attributes to the addtocart method.

$quote          =  Mage::getSingleton('checkout/session')->getQuote(); /* Current Quote Object */
$productId      = 34; /* Product ID*/
$params         = array();
$curQuantity    = 3; /* Item Quantity */
$currentProduct = Mage::getModel('catalog/product')->load($productId);  
$params['product']                  = $productId;
$params['qty']                      = $curQuantity;               
$params['giftcard_amount']          = 200; /* Gift Card Amount */
$params['giftcard_sender_name']     = 'My Name'; /* Sender Name */
$params['giftcard_recipient_name']  = 'test@gmail.com'; /* Sender Email */
$params['giftcard_sender_email']    = 'Your Name'; /* Recipient Name */
$params['giftcard_recipient_email'] = 'test2@gmail.com'; /* Recipient Email */  
$request                            = new Varien_Object(); 
$request->setData($params);
$resultItem = $quote->addProduct($currentProduct , $request);
7ochem
  • 7,532
  • 14
  • 51
  • 80
iqbalmp
  • 193
  • 7