/** * Add a gift card to the container. Will make the gift card balance check * and make sure card can be applied to the order. * @param EbayEnterprise_GiftCard_Model_IGiftcard $card * @return self * @throws EbayEnterprise_GiftCard_Exception If gift card could not be added to the order. */ public function addGiftCardToOrder(EbayEnterprise_GiftCard_Model_IGiftcard $card, EbayEnterprise_GiftCard_Model_IContainer $giftCardContainer) { $card->checkBalance(); // Treat 0 balance gift cards as invalid. if ($card->getBalanceAmount() <= 0) { throw Mage::exception('EbayEnterprise_GiftCard', $this->__(self::ZERO_BALANCE_CARD_MESSAGE, $card->getCardNumber())); } $giftCardContainer->updateGiftCard($card); return $this; }
/** * Add a gift card to the container. Will make the gift card balance check * and make sure card can be applied to the order. * @param EbayEnterprise_GiftCard_Model_IGiftcard $card * @return self */ public function addGiftCardToOrder(EbayEnterprise_GiftCard_Model_IGiftcard $card) { try { $card->checkBalance(); // only add cards with an available balance if ($card->getBalanceAmount() > 0) { $this->_giftCardContainer->updateGiftCard($card); } else { // throw exception to trigger error handling below, let 0 balance card // get handled like any other balance check failure throw Mage::exception('EbayEnterprise_GiftCard', $this->__(self::ZERO_BALANCE_CARD_MESSAGE, $card->getCardNumber())); } } catch (EbayEnterprise_GiftCard_Exception $e) { Mage::getSingleton('checkout/session')->addError($this->__($e->getMessage())); } return $this; }