|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (c) 2013-2014 eBay Enterprise, Inc. |
|
4
|
|
|
* |
|
5
|
|
|
* NOTICE OF LICENSE |
|
6
|
|
|
* |
|
7
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
|
8
|
|
|
* that is bundled with this package in the file LICENSE.md. |
|
9
|
|
|
* It is also available through the world-wide-web at this URL: |
|
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
|
11
|
|
|
* |
|
12
|
|
|
* @copyright Copyright (c) 2013-2014 eBay Enterprise, Inc. (http://www.ebayenterprise.com/) |
|
13
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
class EbayEnterprise_GiftCard_CartController extends EbayEnterprise_GiftCard_Controller_Abstract |
|
17
|
|
|
{ |
|
18
|
|
|
//** @see EbayEnterprise_GiftCard_Controller_Abstract */ |
|
19
|
|
|
const REDIRECT_PATH = 'checkout/cart/'; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* add a giftcard to the cart. |
|
23
|
|
|
*/ |
|
24
|
|
|
public function addAction() |
|
25
|
|
|
{ |
|
26
|
|
|
list($cardNumber, $pin) = $this->_getCardInfoFromRequest(); |
|
27
|
|
|
|
|
28
|
|
|
if ($cardNumber) { |
|
29
|
|
|
|
|
30
|
|
|
$container = $this->_getContainer(); |
|
31
|
|
|
// try a balance request. |
|
32
|
|
|
$giftcard = $container->getGiftCard($cardNumber)->setPin($pin); |
|
33
|
|
|
|
|
34
|
|
|
try { |
|
35
|
|
|
|
|
36
|
|
|
$this->_helper->addGiftCardToOrder($giftcard, $container); |
|
37
|
|
|
$this->_getCheckoutSession() |
|
38
|
|
|
->addSuccess($this->_helper->__(EbayEnterprise_GiftCard_Helper_Data::GIFT_CARD_ADD_SUCCESS, $giftcard->getCardNumber())); |
|
39
|
|
|
|
|
40
|
|
|
} catch (EbayEnterprise_GiftCard_Exception $e) { |
|
41
|
|
|
|
|
42
|
|
|
$this->_getCheckoutSession()->addError($this->_helper->__($e->getMessage())); |
|
43
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
$this->_redirect(static::REDIRECT_PATH); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* remove a giftcard from the cart. |
|
51
|
|
|
*/ |
|
52
|
|
|
public function removeAction() |
|
53
|
|
|
{ |
|
54
|
|
|
list($cardNumber) = $this->_getCardInfoFromRequest(); |
|
55
|
|
|
|
|
56
|
|
|
$giftcard = $this->_getContainer()->getGiftCard($cardNumber); |
|
57
|
|
|
|
|
58
|
|
|
$this->_getContainer()->removeGiftCard($giftcard); |
|
59
|
|
|
|
|
60
|
|
|
$this->_getCheckoutSession() |
|
61
|
|
|
->addSuccess($this->_helper->__(EbayEnterprise_GiftCard_Helper_Data::GIFT_CARD_REMOVE_SUCCESS, $giftcard->getCardNumber())); |
|
62
|
|
|
|
|
63
|
|
|
$this->_redirect(static::REDIRECT_PATH); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|