1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2016 |
6
|
|
|
* @package Controller |
7
|
|
|
* @subpackage Frontend |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Frontend\Basket\Decorator; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Base for basket frontend controller decorators |
16
|
|
|
* |
17
|
|
|
* @package Controller |
18
|
|
|
* @subpackage Frontend |
19
|
|
|
*/ |
20
|
|
|
abstract class Base extends \Aimeos\Controller\Frontend\Common\Decorator\Base |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Empties the basket and removing all products, addresses, services, etc. |
24
|
|
|
* @return void |
25
|
|
|
*/ |
26
|
|
|
public function clear() |
27
|
|
|
{ |
28
|
|
|
$this->getController()->clear(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Returns the basket object. |
34
|
|
|
* |
35
|
|
|
* @return \Aimeos\MShop\Order\Item\Base\Iface Basket holding products, addresses and delivery/payment options |
36
|
|
|
*/ |
37
|
|
|
public function get() |
38
|
|
|
{ |
39
|
|
|
return $this->getController()->get(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Explicitely persists the basket content |
45
|
|
|
*/ |
46
|
|
|
public function save() |
47
|
|
|
{ |
48
|
|
|
$this->getController()->save(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Adds a categorized product to the basket of the user stored in the session. |
54
|
|
|
* |
55
|
|
|
* @param string $prodid ID of the base product to add |
56
|
|
|
* @param integer $quantity Amount of products that should by added |
57
|
|
|
* @param array $options Possible options are: 'stock'=>true|false and 'variant'=>true|false |
58
|
|
|
* The 'stock'=>false option allows adding products without being in stock. |
59
|
|
|
* The 'variant'=>false option allows adding the selection product to the basket |
60
|
|
|
* instead of the specific sub-product if the variant-building attribute IDs |
61
|
|
|
* doesn't match a specific sub-product or if the attribute IDs are missing. |
62
|
|
|
* @param array $variantAttributeIds List of variant-building attribute IDs that identify a specific product |
63
|
|
|
* in a selection products |
64
|
|
|
* @param array $configAttributeIds List of attribute IDs that doesn't identify a specific product in a |
65
|
|
|
* selection of products but are stored together with the product (e.g. for configurable products) |
66
|
|
|
* @param array $hiddenAttributeIds List of attribute IDs that should be stored along with the product in the order |
67
|
|
|
* @param array $customAttributeValues Associative list of attribute IDs and arbitrary values that should be stored |
68
|
|
|
* along with the product in the order |
69
|
|
|
* @param string $warehouse Unique code of the warehouse to deliver the products from |
70
|
|
|
* @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
71
|
|
|
* @return void |
72
|
|
|
*/ |
73
|
|
|
public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
74
|
|
|
array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
75
|
|
|
$warehouse = 'default' ) |
76
|
|
|
{ |
77
|
|
|
$this->getController()->addProduct( |
78
|
|
|
$prodid, $quantity, $options, $variantAttributeIds, $configAttributeIds, |
79
|
|
|
$hiddenAttributeIds, $customAttributeValues, $warehouse |
80
|
|
|
); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Deletes a product item from the basket. |
86
|
|
|
* |
87
|
|
|
* @param integer $position Position number (key) of the order product item |
88
|
|
|
* @return void |
89
|
|
|
*/ |
90
|
|
|
public function deleteProduct( $position ) |
91
|
|
|
{ |
92
|
|
|
$this->getController()->deleteProduct( $position ); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Edits the quantity of a product item in the basket. |
98
|
|
|
* |
99
|
|
|
* @param integer $position Position number (key) of the order product item |
100
|
|
|
* @param integer $quantity New quantiy of the product item |
101
|
|
|
* @param array $configAttributeCodes Codes of the product config attributes that should be REMOVED |
102
|
|
|
* @return void |
103
|
|
|
*/ |
104
|
|
|
public function editProduct( $position, $quantity, array $configAttributeCodes = array() ) |
105
|
|
|
{ |
106
|
|
|
$this->getController()->editProduct( $position, $quantity, $configAttributeCodes ); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Adds the given coupon code and updates the basket. |
112
|
|
|
* |
113
|
|
|
* @param string $code Coupon code entered by the user |
114
|
|
|
* @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
115
|
|
|
* @return void |
116
|
|
|
*/ |
117
|
|
|
public function addCoupon( $code ) |
118
|
|
|
{ |
119
|
|
|
$this->getController()->addCoupon( $code ); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Removes the given coupon code and its effects from the basket. |
125
|
|
|
* |
126
|
|
|
* @param string $code Coupon code entered by the user |
127
|
|
|
* @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
128
|
|
|
* @return void |
129
|
|
|
*/ |
130
|
|
|
public function deleteCoupon( $code ) |
131
|
|
|
{ |
132
|
|
|
$this->getController()->deleteCoupon( $code ); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Sets the address of the customer in the basket. |
138
|
|
|
* |
139
|
|
|
* @param string $type Address type constant from \Aimeos\MShop\Order\Item\Base\Address\Base |
140
|
|
|
* @param \Aimeos\MShop\Common\Item\Address\Iface|array|null $value Address object or array with key/value pairs of address or null to remove address from basket |
141
|
|
|
* @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of |
142
|
|
|
* if one of the keys is invalid when using an array with key/value pairs |
143
|
|
|
* @return void |
144
|
|
|
*/ |
145
|
|
|
public function setAddress( $type, $value ) |
146
|
|
|
{ |
147
|
|
|
$this->getController()->setAddress( $type, $value ); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Sets the delivery/payment service item based on the service ID. |
153
|
|
|
* |
154
|
|
|
* @param string $type Service type code like 'payment' or 'delivery' |
155
|
|
|
* @param string $id Unique ID of the service item |
156
|
|
|
* @param array $attributes Associative list of key/value pairs containing the attributes selected or |
157
|
|
|
* entered by the customer when choosing one of the delivery or payment options |
158
|
|
|
* @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
159
|
|
|
* @return void |
160
|
|
|
*/ |
161
|
|
|
public function setService( $type, $id, array $attributes = array() ) |
162
|
|
|
{ |
163
|
|
|
$this->getController()->setService( $type, $id, $attributes ); |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
|