1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2025 |
6
|
|
|
* @package Client |
7
|
|
|
* @subpackage Html |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Client\Html\Checkout\Confirm; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Default implementation of confirm checkout HTML client. |
16
|
|
|
* |
17
|
|
|
* @package Client |
18
|
|
|
* @subpackage Html |
19
|
|
|
*/ |
20
|
|
|
class Standard |
21
|
|
|
extends \Aimeos\Client\Html\Common\Client\Factory\Base |
22
|
|
|
implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
23
|
|
|
{ |
24
|
|
|
/** client/html/checkout/confirm/name |
25
|
|
|
* Class name of the used checkout confirm client implementation |
26
|
|
|
* |
27
|
|
|
* Each default HTML client can be replace by an alternative imlementation. |
28
|
|
|
* To use this implementation, you have to set the last part of the class |
29
|
|
|
* name as configuration value so the client factory knows which class it |
30
|
|
|
* has to instantiate. |
31
|
|
|
* |
32
|
|
|
* For example, if the name of the default class is |
33
|
|
|
* |
34
|
|
|
* \Aimeos\Client\Html\Checkout\Confirm\Standard |
35
|
|
|
* |
36
|
|
|
* and you want to replace it with your own version named |
37
|
|
|
* |
38
|
|
|
* \Aimeos\Client\Html\Checkout\Confirm\Myconfirm |
39
|
|
|
* |
40
|
|
|
* then you have to set the this configuration option: |
41
|
|
|
* |
42
|
|
|
* client/html/checkout/confirm/name = Myconfirm |
43
|
|
|
* |
44
|
|
|
* The value is the last part of your own class name and it's case sensitive, |
45
|
|
|
* so take care that the configuration value is exactly named like the last |
46
|
|
|
* part of the class name. |
47
|
|
|
* |
48
|
|
|
* The allowed characters of the class name are A-Z, a-z and 0-9. No other |
49
|
|
|
* characters are possible! You should always start the last part of the class |
50
|
|
|
* name with an upper case character and continue only with lower case characters |
51
|
|
|
* or numbers. Avoid chamel case names like "MyConfirm"! |
52
|
|
|
* |
53
|
|
|
* @param string Last part of the class name |
54
|
|
|
* @since 2014.03 |
55
|
|
|
*/ |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Processes the input, e.g. store given values. |
60
|
|
|
* |
61
|
|
|
* A view must be available and this method doesn't generate any output |
62
|
|
|
* besides setting view variables if necessary. |
63
|
|
|
*/ |
64
|
|
|
public function init() |
65
|
|
|
{ |
66
|
|
|
$view = $this->view(); |
67
|
|
|
$context = $this->context(); |
68
|
|
|
|
69
|
|
|
$config = $context->config(); |
70
|
|
|
$session = $context->session(); |
71
|
|
|
|
72
|
|
|
if( $context->session()->get( 'aimeos/basket/list' ) !== null && ( $orderid = $session->get( 'aimeos/orderid' ) ) === null ) { |
73
|
|
|
throw new \Aimeos\Client\Html\Exception( 'No order ID available' ); |
74
|
|
|
} else if ($orderid !== null) { |
|
|
|
|
75
|
|
|
|
76
|
|
|
$ref = $config->get( 'mshop/order/manager/subdomains', [] ); |
77
|
|
|
$ref = $config->get( 'client/html/checkout/confirm/domains', $ref ); |
78
|
|
|
$orderCntl = \Aimeos\Controller\Frontend::create( $context, 'order' )->uses( $ref ); |
79
|
|
|
|
80
|
|
|
if( ( $code = $view->param( 'code' ) ) !== null ) |
81
|
|
|
{ |
82
|
|
|
$url = $view->link( 'client/html/checkout/confirm/url', ['code' => $code], ['absoluteUri' => true] ); |
83
|
|
|
|
84
|
|
|
$serviceCntl = \Aimeos\Controller\Frontend::create( $context, 'service' ); |
85
|
|
|
$orderItem = $serviceCntl->config( ['payment.url-self' => $url] )->updateSync( $view->request(), $code, $orderid ); |
86
|
|
|
} |
87
|
|
|
else |
88
|
|
|
{ |
89
|
|
|
$orderItem = $orderCntl->get( $orderid, false ); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
// update stock, coupons, etc. |
93
|
|
|
$orderCntl->update( $orderItem ); |
94
|
|
|
|
95
|
|
|
parent::init(); |
96
|
|
|
|
97
|
|
|
if( $orderItem->getStatusPayment() > \Aimeos\MShop\Order\Item\Base::PAY_REFUSED ) |
98
|
|
|
{ |
99
|
|
|
\Aimeos\Controller\Frontend::create( $context, 'basket' )->clear(); |
100
|
|
|
$session->remove( array_keys( $session->get( 'aimeos/basket/cache', [] ) ) ); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
$orderCntl->save( $orderItem ); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Sets the necessary parameter values in the view. |
110
|
|
|
* |
111
|
|
|
* @param \Aimeos\Base\View\Iface $view The view object which generates the HTML output |
112
|
|
|
* @param array &$tags Result array for the list of tags that are associated to the output |
113
|
|
|
* @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
114
|
|
|
* @return \Aimeos\Base\View\Iface Modified view object |
115
|
|
|
*/ |
116
|
|
|
public function data( \Aimeos\Base\View\Iface $view, array &$tags = [], ?string &$expire = null ) : \Aimeos\Base\View\Iface |
117
|
|
|
{ |
118
|
|
|
$context = $this->context(); |
119
|
|
|
$config = $context->config(); |
120
|
|
|
|
121
|
|
|
if( $context->session()->get( 'aimeos/basket/list' ) !== null && ( $id = $context->session()->get( 'aimeos/orderid' ) ) === null ) { |
122
|
|
|
throw new \Aimeos\Client\Html\Exception( $context->translate( 'client', 'No order ID available in session' ) ); |
123
|
|
|
} else if ($id !== null) { |
|
|
|
|
124
|
|
|
|
125
|
|
|
/** client/html/checkout/confirm/domains |
126
|
|
|
* List of domains to fetch items related to the order |
127
|
|
|
* |
128
|
|
|
* To adapt the order data loaded for displaying at the checkout confirmation |
129
|
|
|
* page, add or remove the names of the domains using this setting. By default, |
130
|
|
|
* all order sub-domains are included (order/address, order/coupon, order/product |
131
|
|
|
* and order/service) and you can remove unused domains or add additional ones |
132
|
|
|
* like "product" to get the original product items for the bought order products. |
133
|
|
|
* You can also add domains related to e.g. products like "catalog" for the |
134
|
|
|
* categories the products are assigned to. |
135
|
|
|
* |
136
|
|
|
* @param array List of domain names |
137
|
|
|
* @since 2023.07 |
138
|
|
|
*/ |
139
|
|
|
$ref = $config->get( 'mshop/order/manager/subdomains', [] ); |
140
|
|
|
$ref = $config->get( 'client/html/checkout/confirm/domains', $ref ); |
141
|
|
|
$order = \Aimeos\Controller\Frontend::create( $context, 'order' )->uses( $ref )->get( $id, false ); |
142
|
|
|
|
143
|
|
|
$view->confirmOrderItem = $order; |
144
|
|
|
$view->summaryBasket = $order; |
145
|
|
|
|
146
|
|
|
} else { |
147
|
|
|
$view->noOrder = true; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
return parent::data($view, $tags, $expire); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
|
154
|
|
|
/** client/html/checkout/confirm/template-body |
155
|
|
|
* Relative path to the HTML body template of the checkout confirm client. |
156
|
|
|
* |
157
|
|
|
* The template file contains the HTML code and processing instructions |
158
|
|
|
* to generate the result shown in the body of the frontend. The |
159
|
|
|
* configuration string is the path to the template file relative |
160
|
|
|
* to the templates directory (usually in templates/client/html). |
161
|
|
|
* |
162
|
|
|
* You can overwrite the template file configuration in extensions and |
163
|
|
|
* provide alternative templates. These alternative templates should be |
164
|
|
|
* named like the default one but suffixed by |
165
|
|
|
* an unique name. You may use the name of your project for this. If |
166
|
|
|
* you've implemented an alternative client class as well, it |
167
|
|
|
* should be suffixed by the name of the new class. |
168
|
|
|
* |
169
|
|
|
* @param string Relative path to the template creating code for the HTML page body |
170
|
|
|
* @since 2014.03 |
171
|
|
|
* @see client/html/checkout/confirm/template-header |
172
|
|
|
*/ |
173
|
|
|
|
174
|
|
|
/** client/html/checkout/confirm/template-header |
175
|
|
|
* Relative path to the HTML header template of the checkout confirm client. |
176
|
|
|
* |
177
|
|
|
* The template file contains the HTML code and processing instructions |
178
|
|
|
* to generate the HTML code that is inserted into the HTML page header |
179
|
|
|
* of the rendered page in the frontend. The configuration string is the |
180
|
|
|
* path to the template file relative to the templates directory (usually |
181
|
|
|
* in templates/client/html). |
182
|
|
|
* |
183
|
|
|
* You can overwrite the template file configuration in extensions and |
184
|
|
|
* provide alternative templates. These alternative templates should be |
185
|
|
|
* named like the default one but suffixed by |
186
|
|
|
* an unique name. You may use the name of your project for this. If |
187
|
|
|
* you've implemented an alternative client class as well, it |
188
|
|
|
* should be suffixed by the name of the new class. |
189
|
|
|
* |
190
|
|
|
* @param string Relative path to the template creating code for the HTML page head |
191
|
|
|
* @since 2014.03 |
192
|
|
|
* @see client/html/checkout/confirm/template-body |
193
|
|
|
*/ |
194
|
|
|
|
195
|
|
|
/** client/html/checkout/confirm/decorators/excludes |
196
|
|
|
* Excludes decorators added by the "common" option from the checkout confirm html client |
197
|
|
|
* |
198
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
199
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
200
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
201
|
|
|
* modify what is returned to the caller. |
202
|
|
|
* |
203
|
|
|
* This option allows you to remove a decorator added via |
204
|
|
|
* "client/html/common/decorators/default" before they are wrapped |
205
|
|
|
* around the html client. |
206
|
|
|
* |
207
|
|
|
* client/html/checkout/confirm/decorators/excludes = array( 'decorator1' ) |
208
|
|
|
* |
209
|
|
|
* This would remove the decorator named "decorator1" from the list of |
210
|
|
|
* common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via |
211
|
|
|
* "client/html/common/decorators/default" to the html client. |
212
|
|
|
* |
213
|
|
|
* @param array List of decorator names |
214
|
|
|
* @since 2014.05 |
215
|
|
|
* @see client/html/common/decorators/default |
216
|
|
|
* @see client/html/checkout/confirm/decorators/global |
217
|
|
|
* @see client/html/checkout/confirm/decorators/local |
218
|
|
|
*/ |
219
|
|
|
|
220
|
|
|
/** client/html/checkout/confirm/decorators/global |
221
|
|
|
* Adds a list of globally available decorators only to the checkout confirm html client |
222
|
|
|
* |
223
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
224
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
225
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
226
|
|
|
* modify what is returned to the caller. |
227
|
|
|
* |
228
|
|
|
* This option allows you to wrap global decorators |
229
|
|
|
* ("\Aimeos\Client\Html\Common\Decorator\*") around the html client. |
230
|
|
|
* |
231
|
|
|
* client/html/checkout/confirm/decorators/global = array( 'decorator1' ) |
232
|
|
|
* |
233
|
|
|
* This would add the decorator named "decorator1" defined by |
234
|
|
|
* "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client. |
235
|
|
|
* |
236
|
|
|
* @param array List of decorator names |
237
|
|
|
* @since 2014.05 |
238
|
|
|
* @see client/html/common/decorators/default |
239
|
|
|
* @see client/html/checkout/confirm/decorators/excludes |
240
|
|
|
* @see client/html/checkout/confirm/decorators/local |
241
|
|
|
*/ |
242
|
|
|
|
243
|
|
|
/** client/html/checkout/confirm/decorators/local |
244
|
|
|
* Adds a list of local decorators only to the checkout confirm html client |
245
|
|
|
* |
246
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
247
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
248
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
249
|
|
|
* modify what is returned to the caller. |
250
|
|
|
* |
251
|
|
|
* This option allows you to wrap local decorators |
252
|
|
|
* ("\Aimeos\Client\Html\Checkout\Decorator\*") around the html client. |
253
|
|
|
* |
254
|
|
|
* client/html/checkout/confirm/decorators/local = array( 'decorator2' ) |
255
|
|
|
* |
256
|
|
|
* This would add the decorator named "decorator2" defined by |
257
|
|
|
* "\Aimeos\Client\Html\Checkout\Decorator\Decorator2" only to the html client. |
258
|
|
|
* |
259
|
|
|
* @param array List of decorator names |
260
|
|
|
* @since 2014.05 |
261
|
|
|
* @see client/html/common/decorators/default |
262
|
|
|
* @see client/html/checkout/confirm/decorators/excludes |
263
|
|
|
* @see client/html/checkout/confirm/decorators/global |
264
|
|
|
*/ |
265
|
|
|
} |
266
|
|
|
|