1: <?php
2: /**
3: * Magento
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.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Adminhtml
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * Adminhtml sales order create sidebar cart block
29: *
30: * @category Mage
31: * @package Mage_Adminhtml
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Adminhtml_Block_Sales_Order_Create_Sidebar_Cart
35: extends Mage_Adminhtml_Block_Sales_Order_Create_Sidebar_Abstract
36: {
37: /**
38: * Storage action on selected item
39: *
40: * @var string
41: */
42: protected $_sidebarStorageAction = 'add_cart_item';
43:
44: protected function _construct()
45: {
46: parent::_construct();
47: $this->setId('sales_order_create_sidebar_cart');
48: $this->setDataId('cart');
49: }
50:
51: public function getHeaderText()
52: {
53: return Mage::helper('sales')->__('Shopping Cart');
54: }
55:
56: /**
57: * Retrieve item collection
58: *
59: * @return mixed
60: */
61: public function getItemCollection()
62: {
63: $collection = $this->getData('item_collection');
64: if (is_null($collection)) {
65: $collection = $this->getCreateOrderModel()->getCustomerCart()->getAllVisibleItems();
66: $this->setData('item_collection', $collection);
67: }
68: return $collection;
69: }
70:
71: public function canDisplayItemQty()
72: {
73: return true;
74: }
75:
76: /**
77: * Retrieve identifier of block item
78: *
79: * @param Varien_Object $item
80: * @return int
81: */
82: public function getIdentifierId($item)
83: {
84: return $item->getId();
85: }
86:
87: /**
88: * Retrieve product identifier linked with item
89: *
90: * @param Mage_Sales_Model_Quote_Item $item
91: * @return int
92: */
93: public function getProductId($item)
94: {
95: return $item->getProduct()->getId();
96: }
97:
98: /**
99: * Prepare layout
100: *
101: * Add button that clears customer's shopping cart
102: *
103: * @return Mage_Adminhtml_Block_Sales_Order_Create_Sidebar_Cart
104: */
105: protected function _prepareLayout()
106: {
107: $deleteAllConfirmString = Mage::helper('sales')->__('Are you sure you want to delete all items from shopping cart?');
108: $button = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
109: 'label' => Mage::helper('sales')->__('Clear Shopping Cart'),
110: 'onclick' => 'order.clearShoppingCart(\'' . $deleteAllConfirmString . '\')',
111: 'style' => 'float: right;'
112: ));
113: $this->setChild('empty_customer_cart_button', $button);
114:
115: return parent::_prepareLayout();
116: }
117: }
118: