1 | <?php |
||
42 | class Autofill |
||
43 | extends \Aimeos\MShop\Plugin\Provider\Factory\Base |
||
|
|||
44 | implements \Aimeos\MShop\Plugin\Provider\Factory\Iface |
||
45 | { |
||
46 | private $beConfig = array( |
||
47 | 'autofill.address' => array( |
||
48 | 'code' => 'autofill.address', |
||
49 | 'internalcode'=> 'autofill.address', |
||
50 | 'label'=> 'Add customer address automatically', |
||
51 | 'type'=> 'boolean', |
||
52 | 'internaltype'=> 'boolean', |
||
53 | 'default'=> '', |
||
54 | 'required'=> false, |
||
55 | ), |
||
56 | 'autofill.delivery' => array( |
||
57 | 'code' => 'autofill.delivery', |
||
58 | 'internalcode'=> 'autofill.delivery', |
||
59 | 'label'=> 'Add delivery option automatically', |
||
60 | 'type'=> 'boolean', |
||
61 | 'internaltype'=> 'boolean', |
||
62 | 'default'=> '', |
||
63 | 'required'=> false, |
||
64 | ), |
||
65 | 'autofill.deliverycode' => array( |
||
66 | 'code' => 'autofill.deliverycode', |
||
67 | 'internalcode'=> 'autofill.deliverycode', |
||
68 | 'label'=> 'Add delivery by code', |
||
69 | 'type'=> 'string', |
||
70 | 'internaltype'=> 'string', |
||
71 | 'default'=> '', |
||
72 | 'required'=> false, |
||
73 | ), |
||
74 | 'autofill.payment' => array( |
||
75 | 'code' => 'autofill.payment', |
||
76 | 'internalcode'=> 'autofill.payment', |
||
77 | 'label'=> 'Add payment option automatically', |
||
78 | 'type'=> 'boolean', |
||
79 | 'internaltype'=> 'boolean', |
||
80 | 'default'=> '', |
||
81 | 'required'=> false, |
||
82 | ), |
||
83 | 'autofill.paymentcode' => array( |
||
84 | 'code' => 'autofill.paymentcode', |
||
85 | 'internalcode'=> 'autofill.paymentcode', |
||
86 | 'label'=> 'Add payment by code', |
||
87 | 'type'=> 'string', |
||
88 | 'internaltype'=> 'string', |
||
89 | 'default'=> '', |
||
90 | 'required'=> false, |
||
91 | ), |
||
92 | 'autofill.useorder' => array( |
||
93 | 'code' => 'autofill.useorder', |
||
94 | 'internalcode'=> 'autofill.useorder', |
||
95 | 'label'=> 'Add from last order', |
||
96 | 'type'=> 'boolean', |
||
97 | 'internaltype'=> 'boolean', |
||
98 | 'default'=> '', |
||
99 | 'required'=> false, |
||
100 | ), |
||
101 | 'autofill.orderaddress' => array( |
||
102 | 'code' => 'autofill.orderaddress', |
||
103 | 'internalcode'=> 'autofill.orderaddress', |
||
104 | 'label'=> 'Add address from last order', |
||
105 | 'type'=> 'boolean', |
||
106 | 'internaltype'=> 'boolean', |
||
107 | 'default'=> '', |
||
108 | 'required'=> false, |
||
109 | ), |
||
110 | 'autofill.orderservice' => array( |
||
111 | 'code' => 'autofill.orderservice', |
||
112 | 'internalcode'=> 'autofill.orderservice', |
||
113 | 'label'=> 'Add delivery/payment from last order', |
||
114 | 'type'=> 'boolean', |
||
115 | 'internaltype'=> 'boolean', |
||
116 | 'default'=> '', |
||
117 | 'required'=> false, |
||
118 | ), |
||
119 | ); |
||
120 | |||
121 | |||
122 | /** |
||
123 | * Checks the backend configuration attributes for validity. |
||
124 | * |
||
125 | * @param array $attributes Attributes added by the shop owner in the administraton interface |
||
126 | * @return array An array with the attribute keys as key and an error message as values for all attributes that are |
||
127 | * known by the provider but aren't valid |
||
128 | */ |
||
129 | public function checkConfigBE( array $attributes ) |
||
135 | |||
136 | |||
137 | /** |
||
138 | * Returns the configuration attribute definitions of the provider to generate a list of available fields and |
||
139 | * rules for the value of each field in the administration interface. |
||
140 | * |
||
141 | * @return array List of attribute definitions implementing \Aimeos\MW\Common\Critera\Attribute\Iface |
||
142 | */ |
||
143 | public function getConfigBE() |
||
147 | |||
148 | |||
149 | /** |
||
150 | * Subscribes itself to a publisher |
||
151 | * |
||
152 | * @param \Aimeos\MW\Observer\Publisher\Iface $p Object implementing publisher interface |
||
153 | */ |
||
154 | public function register( \Aimeos\MW\Observer\Publisher\Iface $p ) |
||
159 | |||
160 | |||
161 | /** |
||
162 | * Receives a notification from a publisher object |
||
163 | * |
||
164 | * @param \Aimeos\MW\Observer\Publisher\Iface $order Shop basket instance implementing publisher interface |
||
165 | * @param string $action Name of the action to listen for |
||
166 | * @param mixed $value Object or value changed in publisher |
||
167 | * @throws \Aimeos\MShop\Plugin\Provider\Exception if an error occurs |
||
168 | * @return bool true if subsequent plugins should be processed |
||
169 | */ |
||
170 | public function update( \Aimeos\MW\Observer\Publisher\Iface $order, $action, $value = null ) |
||
207 | |||
208 | |||
209 | /** |
||
210 | * Returns the order service item for the given type and code if available. |
||
211 | * |
||
212 | * @param \Aimeos\MShop\Order\Item\Base\Iface $order Basket of the customer |
||
213 | * @param string $type Service type constant from \Aimeos\MShop\Order\Item\Base\Service\Base |
||
214 | * @param string|null $code Service item code |
||
215 | * @return \Aimeos\MShop\Order\Item\Base\Service\Iface|null Order service item if available or null otherwise |
||
216 | */ |
||
217 | protected function getServiceItem( \Aimeos\MShop\Order\Item\Base\Iface $order, $type, $code = null ) |
||
253 | |||
254 | |||
255 | /** |
||
256 | * Adds the addresses from the given order item to the basket. |
||
257 | * |
||
258 | * @param \Aimeos\MShop\Order\Item\Base\Iface $order Basket object |
||
259 | * @param \Aimeos\MShop\Order\Item\Iface $item Existing order to fetch the addresses from |
||
260 | */ |
||
261 | protected function setAddresses( \Aimeos\MShop\Order\Item\Base\Iface $order, \Aimeos\MShop\Order\Item\Iface $item ) |
||
277 | |||
278 | |||
279 | /** |
||
280 | * Adds the services from the given order item to the basket. |
||
281 | * |
||
282 | * @param \Aimeos\MShop\Order\Item\Base\Iface $order Basket object |
||
283 | * @param \Aimeos\MShop\Order\Item\Iface $item Existing order to fetch the services from |
||
284 | */ |
||
285 | protected function setServices( \Aimeos\MShop\Order\Item\Base\Iface $order, \Aimeos\MShop\Order\Item\Iface $item ) |
||
306 | |||
307 | |||
308 | /** |
||
309 | * Adds the default addresses to the basket if they are not available. |
||
310 | * |
||
311 | * @param \Aimeos\MShop\Order\Item\Base\Iface $order Basket object |
||
312 | */ |
||
313 | protected function setAddressDefault( \Aimeos\MShop\Order\Item\Base\Iface $order ) |
||
333 | |||
334 | |||
335 | /** |
||
336 | * Adds the default services to the basket if they are not available. |
||
337 | * |
||
338 | * @param \Aimeos\MShop\Order\Item\Base\Iface $order Basket object |
||
339 | */ |
||
340 | protected function setServicesDefault( \Aimeos\MShop\Order\Item\Base\Iface $order ) |
||
363 | } |
||
364 |