Passed
Pull Request — master (#138)
by
unknown
10:14
created

Standard   A

Complexity

Total Complexity 38

Size/Duplication

Total Lines 688
Duplicated Lines 0 %

Importance

Changes 7
Bugs 0 Features 0
Metric Value
eloc 122
c 7
b 0
f 0
dl 0
loc 688
rs 9.36
wmc 38

12 Methods

Rating   Name   Duplication   Size   Complexity  
A getHeader() 0 9 2
A getBody() 0 38 3
A getSubClient() 0 77 1
C process() 0 78 12
A isSubscription() 0 10 3
A getSubClientNames() 0 3 1
B addFormData() 0 38 7
A getUrlConfirm() 0 74 1
A addData() 0 5 1
A getUrlUpdate() 0 74 1
A processPayment() 0 27 5
A getUrlSelf() 0 74 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2021
6
 * @package Client
7
 * @subpackage Html
8
 */
9
10
11
namespace Aimeos\Client\Html\Checkout\Standard\Process;
12
13
14
// Strings for translation
15
sprintf( 'process' );
16
17
18
/**
19
 * Default implementation of checkout process HTML client.
20
 *
21
 * @package Client
22
 * @subpackage Html
23
 */
24
class Standard
25
	extends \Aimeos\Client\Html\Common\Client\Factory\Base
26
	implements \Aimeos\Client\Html\Common\Client\Factory\Iface
27
{
28
	/** client/html/checkout/standard/process/subparts
29
	 * List of HTML sub-clients rendered within the checkout standard process section
30
	 *
31
	 * The output of the frontend is composed of the code generated by the HTML
32
	 * clients. Each HTML client can consist of serveral (or none) sub-clients
33
	 * that are responsible for rendering certain sub-parts of the output. The
34
	 * sub-clients can contain HTML clients themselves and therefore a
35
	 * hierarchical tree of HTML clients is composed. Each HTML client creates
36
	 * the output that is placed inside the container of its parent.
37
	 *
38
	 * At first, always the HTML code generated by the parent is printed, then
39
	 * the HTML code of its sub-clients. The order of the HTML sub-clients
40
	 * determines the order of the output of these sub-clients inside the parent
41
	 * container. If the configured list of clients is
42
	 *
43
	 *  array( "subclient1", "subclient2" )
44
	 *
45
	 * you can easily change the order of the output by reordering the subparts:
46
	 *
47
	 *  client/html/<clients>/subparts = array( "subclient1", "subclient2" )
48
	 *
49
	 * You can also remove one or more parts if they shouldn't be rendered:
50
	 *
51
	 *  client/html/<clients>/subparts = array( "subclient1" )
52
	 *
53
	 * As the clients only generates structural HTML, the layout defined via CSS
54
	 * should support adding, removing or reordering content by a fluid like
55
	 * design.
56
	 *
57
	 * @param array List of sub-client names
58
	 * @since 2014.03
59
	 * @category Developer
60
	 */
61
	private $subPartPath = 'client/html/checkout/standard/process/subparts';
62
63
	/** client/html/checkout/standard/process/account/name
64
	 * Name of the account part used by the checkout standard process client implementation
65
	 *
66
	 * Use "Myname" if your class is named "\Aimeos\Client\Html\Checkout\Standard\Process\Account\Myname".
67
	 * The name is case-sensitive and you should avoid camel case names like "MyName".
68
	 *
69
	 * @param string Last part of the client class name
70
	 * @since 2017.04
71
	 * @category Developer
72
	 */
73
74
	/** client/html/checkout/standard/process/address/name
75
	 * Name of the address part used by the checkout standard process client implementation
76
	 *
77
	 * Use "Myname" if your class is named "\Aimeos\Client\Html\Checkout\Standard\Process\Address\Myname".
78
	 * The name is case-sensitive and you should avoid camel case names like "MyName".
79
	 *
80
	 * @param string Last part of the client class name
81
	 * @since 2017.04
82
	 * @category Developer
83
	 */
84
	private $subPartNames = array( 'account', 'address' );
85
86
87
	/**
88
	 * Returns the HTML code for insertion into the body.
89
	 *
90
	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
91
	 * @return string HTML code
92
	 */
93
	public function getBody( string $uid = '' ) : string
94
	{
95
		$view = $this->getView();
96
97
		if( $view->get( 'standardStepActive' ) !== 'process' ) {
98
			return '';
99
		}
100
101
		$html = '';
102
		foreach( $this->getSubClients() as $subclient ) {
103
			$html .= $subclient->setView( $view )->getBody( $uid );
104
		}
105
		$view->processBody = $html;
106
107
		/** client/html/checkout/standard/process/template-body
108
		 * Relative path to the HTML body template of the checkout standard process client.
109
		 *
110
		 * The template file contains the HTML code and processing instructions
111
		 * to generate the result shown in the body of the frontend. The
112
		 * configuration string is the path to the template file relative
113
		 * to the templates directory (usually in client/html/templates).
114
		 *
115
		 * You can overwrite the template file configuration in extensions and
116
		 * provide alternative templates. These alternative templates should be
117
		 * named like the default one but with the string "standard" replaced by
118
		 * an unique name. You may use the name of your project for this. If
119
		 * you've implemented an alternative client class as well, "standard"
120
		 * should be replaced by the name of the new class.
121
		 *
122
		 * @param string Relative path to the template creating code for the HTML page body
123
		 * @since 2014.03
124
		 * @category Developer
125
		 * @see client/html/checkout/standard/process/template-header
126
		 */
127
		$tplconf = 'client/html/checkout/standard/process/template-body';
128
		$default = 'checkout/standard/process-body-standard';
129
130
		return $view->render( $view->config( $tplconf, $default ) );
131
	}
132
133
134
	/**
135
	 * Returns the HTML string for insertion into the header.
136
	 *
137
	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
138
	 * @return string|null String including HTML tags for the header on error
139
	 */
140
	public function getHeader( string $uid = '' ) : ?string
141
	{
142
		$view = $this->getView();
143
144
		if( $view->get( 'standardStepActive' ) !== 'process' ) {
145
			return '';
146
		}
147
148
		return parent::getHeader( $uid );
149
	}
150
151
152
	/**
153
	 * Returns the sub-client given by its name.
154
	 *
155
	 * @param string $type Name of the client type
156
	 * @param string|null $name Name of the sub-client (Default if null)
157
	 * @return \Aimeos\Client\Html\Iface Sub-client object
158
	 */
159
	public function getSubClient( string $type, string $name = null ) : \Aimeos\Client\Html\Iface
160
	{
161
		/** client/html/checkout/standard/process/decorators/excludes
162
		 * Excludes decorators added by the "common" option from the checkout standard process html client
163
		 *
164
		 * Decorators extend the functionality of a class by adding new aspects
165
		 * (e.g. log what is currently done), executing the methods of the underlying
166
		 * class only in certain conditions (e.g. only for logged in users) or
167
		 * modify what is returned to the caller.
168
		 *
169
		 * This option allows you to remove a decorator added via
170
		 * "client/html/common/decorators/default" before they are wrapped
171
		 * around the html client.
172
		 *
173
		 *  client/html/checkout/standard/process/decorators/excludes = array( 'decorator1' )
174
		 *
175
		 * This would remove the decorator named "decorator1" from the list of
176
		 * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
177
		 * "client/html/common/decorators/default" to the html client.
178
		 *
179
		 * @param array List of decorator names
180
		 * @since 2015.08
181
		 * @category Developer
182
		 * @see client/html/common/decorators/default
183
		 * @see client/html/checkout/standard/process/decorators/global
184
		 * @see client/html/checkout/standard/process/decorators/local
185
		 */
186
187
		/** client/html/checkout/standard/process/decorators/global
188
		 * Adds a list of globally available decorators only to the checkout standard process html client
189
		 *
190
		 * Decorators extend the functionality of a class by adding new aspects
191
		 * (e.g. log what is currently done), executing the methods of the underlying
192
		 * class only in certain conditions (e.g. only for logged in users) or
193
		 * modify what is returned to the caller.
194
		 *
195
		 * This option allows you to wrap global decorators
196
		 * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
197
		 *
198
		 *  client/html/checkout/standard/process/decorators/global = array( 'decorator1' )
199
		 *
200
		 * This would add the decorator named "decorator1" defined by
201
		 * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
202
		 *
203
		 * @param array List of decorator names
204
		 * @since 2015.08
205
		 * @category Developer
206
		 * @see client/html/common/decorators/default
207
		 * @see client/html/checkout/standard/process/decorators/excludes
208
		 * @see client/html/checkout/standard/process/decorators/local
209
		 */
210
211
		/** client/html/checkout/standard/process/decorators/local
212
		 * Adds a list of local decorators only to the checkout standard process html client
213
		 *
214
		 * Decorators extend the functionality of a class by adding new aspects
215
		 * (e.g. log what is currently done), executing the methods of the underlying
216
		 * class only in certain conditions (e.g. only for logged in users) or
217
		 * modify what is returned to the caller.
218
		 *
219
		 * This option allows you to wrap local decorators
220
		 * ("\Aimeos\Client\Html\Checkout\Decorator\*") around the html client.
221
		 *
222
		 *  client/html/checkout/standard/process/decorators/local = array( 'decorator2' )
223
		 *
224
		 * This would add the decorator named "decorator2" defined by
225
		 * "\Aimeos\Client\Html\Checkout\Decorator\Decorator2" only to the html client.
226
		 *
227
		 * @param array List of decorator names
228
		 * @since 2015.08
229
		 * @category Developer
230
		 * @see client/html/common/decorators/default
231
		 * @see client/html/checkout/standard/process/decorators/excludes
232
		 * @see client/html/checkout/standard/process/decorators/global
233
		 */
234
235
		return $this->createSubClient( 'checkout/standard/process/' . $type, $name );
236
	}
237
238
239
	/**
240
	 * Processes the input, e.g. store given order.
241
	 *
242
	 * A view must be available and this method doesn't generate any output
243
	 * besides setting view variables.
244
	 */
245
	public function process()
246
	{
247
		$view = $this->getView();
248
		$context = $this->getContext();
249
250
		if( $view->param( 'c_step' ) !== 'process'
251
			|| $view->get( 'standardErrorList', [] ) !== []
252
			|| $view->get( 'standardStepActive' ) !== null
253
		) {
254
			return true;
255
		}
256
257
		try
258
		{
259
			$orderCntl = \Aimeos\Controller\Frontend::create( $context, 'order' );
260
			$basketCntl = \Aimeos\Controller\Frontend::create( $context, 'basket' );
261
262
263
			if( $view->param( 'cs_order', null ) !== null )
264
			{
265
				parent::process();
266
267
				$basket = $basketCntl->store();
268
				$orderItem = $orderCntl->add( $basket->getId(), ['order.type' => 'web'] )->store();
269
270
				$context->getSession()->set( 'aimeos/orderid', $orderItem->getId() );
271
			}
272
			elseif( $view->param( 'cp_payment', null ) !== null )
273
			{
274
				$parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL;
275
				$orderItem = $orderCntl->get( $context->getSession()->get( 'aimeos/orderid' ), false );
276
				$basket = $basketCntl->load( $orderItem->getBaseId(), $parts, false );
277
			}
278
			else
279
			{
280
				return;
281
			}
282
283
			if( ( $form = $this->processPayment( $basket, $orderItem ) ) === null )
284
			{
285
				$args = array();
286
287
				$services = $basket->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT );
288
289
				if( ( $service = reset( $services ) ) !== false )
290
				{
291
					$args = array( 'code' => $service->getCode() );
292
				}
293
294
				$orderCntl->save( $orderItem->setPaymentStatus( \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED ) );
295
				$view->standardUrlNext = $this->getUrlConfirm( $view, $args, [] );
296
				$view->standardMethod = 'POST';
297
			}
298
			else // no payment service available
299
			{
300
				$view = $this->addFormData( $view, $form );
301
			}
302
		}
303
		catch( \Aimeos\Client\Html\Exception $e )
304
		{
305
			$error = array( $context->getI18n()->dt( 'client', $e->getMessage() ) );
306
			$view->standardErrorList = array_merge( $view->get( 'standardErrorList', [] ), $error );
307
		}
308
		catch( \Aimeos\Controller\Frontend\Exception $e )
309
		{
310
			$error = array( $context->getI18n()->dt( 'controller/frontend', $e->getMessage() ) );
311
			$view->standardErrorList = array_merge( $view->get( 'standardErrorList', [] ), $error );
312
		}
313
		catch( \Aimeos\MShop\Exception $e )
314
		{
315
			$error = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) );
316
			$view->standardErrorList = array_merge( $view->get( 'standardErrorList', [] ), $error );
317
		}
318
		catch( \Exception $e )
319
		{
320
			$error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) );
321
			$view->standardErrorList = array_merge( $view->get( 'standardErrorList', [] ), $error );
322
			$this->logException( $e );
323
		}
324
	}
325
326
327
	/**
328
	 * Adds the required data for the payment form to the view
329
	 *
330
	 * @param \Aimeos\MW\View\Iface $view View object to assign the data to
331
	 * @param \Aimeos\MShop\Common\Helper\Form\Iface $form Form helper object including the form data
332
	 * @return \Aimeos\MW\View\Iface View object with assigned data
333
	 */
334
	protected function addFormData( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Common\Helper\Form\Iface $form )
335
	{
336
		$url = $form->getUrl();
337
338
		if( $form->getMethod() === 'GET' )
339
		{
340
			$urlParams = [];
341
342
			foreach( $form->getValues() as $item )
343
			{
344
				foreach( (array) $item->getDefault() as $key => $value ) {
345
					$urlParams[$item->getInternalCode()][$key] = $value;
346
				}
347
			}
348
349
			$url .= strpos( $url, '?' ) ? '&' : '?' . map( $urlParams )->toUrl();
350
		}
351
352
		$public = $hidden = [];
353
354
		foreach( $form->getValues() as $key => $item )
355
		{
356
			if( $item->isPublic() ) {
357
				$public[$key] = $item;
358
			} else {
359
				$hidden[$key] = $item;
360
			}
361
		}
362
363
		$view->standardUrlNext = $url;
364
		$view->standardProcessPublic = $public;
365
		$view->standardProcessHidden = $hidden;
366
		$view->standardProcessParams = $form->getValues();
367
		$view->standardUrlExternal = $form->getExternal();
368
		$view->standardMethod = $form->getMethod();
369
		$view->standardHtml = $form->getHtml();
370
371
		return $view;
372
	}
373
374
375
	/**
376
	 * Returns the form helper object for building the payment form in the frontend
377
	 *
378
	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Saved basket object including payment service object
379
	 * @param \Aimeos\MShop\Order\Item\Iface $orderItem Saved order item created for the basket object
380
	 * @return \Aimeos\MShop\Common\Helper\Form\Iface|null Form object with URL, parameters, etc.
381
	 * 	or null if no form data is required
382
	 */
383
	protected function processPayment( \Aimeos\MShop\Order\Item\Base\Iface $basket, \Aimeos\MShop\Order\Item\Iface $orderItem ) : ?\Aimeos\MShop\Common\Helper\Form\Iface
384
	{
385
		if( $basket->getPrice()->getValue() + $basket->getPrice()->getCosts() <= 0
386
			&& $this->isSubscription( $basket->getProducts() ) === false
387
		) {
388
			return null;
389
		}
390
391
		$view = $this->getView();
392
		$services = $basket->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT );
393
394
		if( ( $service = reset( $services ) ) !== false )
395
		{
396
			$args = array( 'code' => $service->getCode() );
397
			$urls = array(
398
				'payment.url-self' => $this->getUrlSelf( $view, ['c_step' => 'process'], [] ),
399
				'payment.url-update' => $this->getUrlUpdate( $view, $args + ['orderid' => $orderItem->getId()], [] ),
400
				'payment.url-success' => $this->getUrlConfirm( $view, $args, [] ),
401
			);
402
403
			$params = $view->param();
404
			foreach( $service->getAttributeItems() as $item ) {
405
				$params[$item->getCode()] = $item->getValue();
406
			}
407
408
			$serviceCntl = \Aimeos\Controller\Frontend::create( $this->getContext(), 'service' );
409
			return $serviceCntl->process( $orderItem, $service->getServiceId(), $urls, $params );
410
		}
411
	}
412
413
414
	/**
415
	 * Returns the list of sub-client names configured for the client.
416
	 *
417
	 * @return array List of HTML client names
418
	 */
419
	protected function getSubClientNames() : array
420
	{
421
		return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
422
	}
423
424
425
	/**
426
	 * Returns the URL to the confirm page.
427
	 *
428
	 * @param \Aimeos\MW\View\Iface $view View object
429
	 * @param array $params Parameters that should be part of the URL
430
	 * @param array $config Default URL configuration
431
	 * @return string URL string
432
	 */
433
	protected function getUrlConfirm( \Aimeos\MW\View\Iface $view, array $params, array $config ) : string
434
	{
435
		/** client/html/checkout/confirm/url/target
436
		 * Destination of the URL where the controller specified in the URL is known
437
		 *
438
		 * The destination can be a page ID like in a content management system or the
439
		 * module of a software development framework. This "target" must contain or know
440
		 * the controller that should be called by the generated URL.
441
		 *
442
		 * @param string Destination of the URL
443
		 * @since 2014.03
444
		 * @category Developer
445
		 * @see client/html/checkout/confirm/url/controller
446
		 * @see client/html/checkout/confirm/url/action
447
		 * @see client/html/checkout/confirm/url/config
448
		 */
449
		$target = $view->config( 'client/html/checkout/confirm/url/target' );
450
451
		/** client/html/checkout/confirm/url/controller
452
		 * Name of the controller whose action should be called
453
		 *
454
		 * In Model-View-Controller (MVC) applications, the controller contains the methods
455
		 * that create parts of the output displayed in the generated HTML page. Controller
456
		 * names are usually alpha-numeric.
457
		 *
458
		 * @param string Name of the controller
459
		 * @since 2014.03
460
		 * @category Developer
461
		 * @see client/html/checkout/confirm/url/target
462
		 * @see client/html/checkout/confirm/url/action
463
		 * @see client/html/checkout/confirm/url/config
464
		 */
465
		$cntl = $view->config( 'client/html/checkout/confirm/url/controller', 'checkout' );
466
467
		/** client/html/checkout/confirm/url/action
468
		 * Name of the action that should create the output
469
		 *
470
		 * In Model-View-Controller (MVC) applications, actions are the methods of a
471
		 * controller that create parts of the output displayed in the generated HTML page.
472
		 * Action names are usually alpha-numeric.
473
		 *
474
		 * @param string Name of the action
475
		 * @since 2014.03
476
		 * @category Developer
477
		 * @see client/html/checkout/confirm/url/target
478
		 * @see client/html/checkout/confirm/url/controller
479
		 * @see client/html/checkout/confirm/url/config
480
		 */
481
		$action = $view->config( 'client/html/checkout/confirm/url/action', 'confirm' );
482
483
		/** client/html/checkout/confirm/url/config
484
		 * Associative list of configuration options used for generating the URL
485
		 *
486
		 * You can specify additional options as key/value pairs used when generating
487
		 * the URLs, like
488
		 *
489
		 *  client/html/<clientname>/url/config = array( 'absoluteUri' => true )
490
		 *
491
		 * The available key/value pairs depend on the application that embeds the e-commerce
492
		 * framework. This is because the infrastructure of the application is used for
493
		 * generating the URLs. The full list of available config options is referenced
494
		 * in the "see also" section of this page.
495
		 *
496
		 * @param string Associative list of configuration options
497
		 * @since 2014.03
498
		 * @category Developer
499
		 * @see client/html/checkout/confirm/url/target
500
		 * @see client/html/checkout/confirm/url/controller
501
		 * @see client/html/checkout/confirm/url/action
502
		 * @see client/html/url/config
503
		 */
504
		$config = $view->config( 'client/html/checkout/confirm/url/config', $config );
505
506
		return $view->url( $target, $cntl, $action, $params, [], $config );
507
	}
508
509
510
	/**
511
	 * Returns the URL to the current page.
512
	 *
513
	 * @param \Aimeos\MW\View\Iface $view View object
514
	 * @param array $params Parameters that should be part of the URL
515
	 * @param array $config Default URL configuration
516
	 * @return string URL string
517
	 */
518
	protected function getUrlSelf( \Aimeos\MW\View\Iface $view, array $params, array $config ) : string
519
	{
520
		/** client/html/checkout/standard/url/target
521
		 * Destination of the URL where the controller specified in the URL is known
522
		 *
523
		 * The destination can be a page ID like in a content management system or the
524
		 * module of a software development framework. This "target" must contain or know
525
		 * the controller that should be called by the generated URL.
526
		 *
527
		 * @param string Destination of the URL
528
		 * @since 2014.03
529
		 * @category Developer
530
		 * @see client/html/checkout/standard/url/controller
531
		 * @see client/html/checkout/standard/url/action
532
		 * @see client/html/checkout/standard/url/config
533
		 */
534
		$target = $view->config( 'client/html/checkout/standard/url/target' );
535
536
		/** client/html/checkout/standard/url/controller
537
		 * Name of the controller whose action should be called
538
		 *
539
		 * In Model-View-Controller (MVC) applications, the controller contains the methods
540
		 * that create parts of the output displayed in the generated HTML page. Controller
541
		 * names are usually alpha-numeric.
542
		 *
543
		 * @param string Name of the controller
544
		 * @since 2014.03
545
		 * @category Developer
546
		 * @see client/html/checkout/standard/url/target
547
		 * @see client/html/checkout/standard/url/action
548
		 * @see client/html/checkout/standard/url/config
549
		 */
550
		$cntl = $view->config( 'client/html/checkout/standard/url/controller', 'checkout' );
551
552
		/** client/html/checkout/standard/url/action
553
		 * Name of the action that should create the output
554
		 *
555
		 * In Model-View-Controller (MVC) applications, actions are the methods of a
556
		 * controller that create parts of the output displayed in the generated HTML page.
557
		 * Action names are usually alpha-numeric.
558
		 *
559
		 * @param string Name of the action
560
		 * @since 2014.03
561
		 * @category Developer
562
		 * @see client/html/checkout/standard/url/target
563
		 * @see client/html/checkout/standard/url/controller
564
		 * @see client/html/checkout/standard/url/config
565
		 */
566
		$action = $view->config( 'client/html/checkout/standard/url/action', 'index' );
567
568
		/** client/html/checkout/standard/url/config
569
		 * Associative list of configuration options used for generating the URL
570
		 *
571
		 * You can specify additional options as key/value pairs used when generating
572
		 * the URLs, like
573
		 *
574
		 *  client/html/<clientname>/url/config = array( 'absoluteUri' => true )
575
		 *
576
		 * The available key/value pairs depend on the application that embeds the e-commerce
577
		 * framework. This is because the infrastructure of the application is used for
578
		 * generating the URLs. The full list of available config options is referenced
579
		 * in the "see also" section of this page.
580
		 *
581
		 * @param string Associative list of configuration options
582
		 * @since 2014.03
583
		 * @category Developer
584
		 * @see client/html/checkout/standard/url/target
585
		 * @see client/html/checkout/standard/url/controller
586
		 * @see client/html/checkout/standard/url/action
587
		 * @see client/html/url/config
588
		 */
589
		$config = $view->config( 'client/html/checkout/standard/url/config', $config );
590
591
		return $view->url( $target, $cntl, $action, $params, [], $config );
592
	}
593
594
595
	/**
596
	 * Returns the URL to the update page.
597
	 *
598
	 * @param \Aimeos\MW\View\Iface $view View object
599
	 * @param array $params Parameters that should be part of the URL
600
	 * @param array $config Default URL configuration
601
	 * @return string URL string
602
	 */
603
	protected function getUrlUpdate( \Aimeos\MW\View\Iface $view, array $params, array $config ) : string
604
	{
605
		/** client/html/checkout/update/url/target
606
		 * Destination of the URL where the controller specified in the URL is known
607
		 *
608
		 * The destination can be a page ID like in a content management system or the
609
		 * module of a software development framework. This "target" must contain or know
610
		 * the controller that should be called by the generated URL.
611
		 *
612
		 * @param string Destination of the URL
613
		 * @since 2014.03
614
		 * @category Developer
615
		 * @see client/html/checkout/update/url/controller
616
		 * @see client/html/checkout/update/url/action
617
		 * @see client/html/checkout/update/url/config
618
		 */
619
		$target = $view->config( 'client/html/checkout/update/url/target' );
620
621
		/** client/html/checkout/update/url/controller
622
		 * Name of the controller whose action should be called
623
		 *
624
		 * In Model-View-Controller (MVC) applications, the controller contains the methods
625
		 * that create parts of the output displayed in the generated HTML page. Controller
626
		 * names are usually alpha-numeric.
627
		 *
628
		 * @param string Name of the controller
629
		 * @since 2014.03
630
		 * @category Developer
631
		 * @see client/html/checkout/update/url/target
632
		 * @see client/html/checkout/update/url/action
633
		 * @see client/html/checkout/update/url/config
634
		 */
635
		$cntl = $view->config( 'client/html/checkout/update/url/controller', 'checkout' );
636
637
		/** client/html/checkout/update/url/action
638
		 * Name of the action that should create the output
639
		 *
640
		 * In Model-View-Controller (MVC) applications, actions are the methods of a
641
		 * controller that create parts of the output displayed in the generated HTML page.
642
		 * Action names are usually alpha-numeric.
643
		 *
644
		 * @param string Name of the action
645
		 * @since 2014.03
646
		 * @category Developer
647
		 * @see client/html/checkout/update/url/target
648
		 * @see client/html/checkout/update/url/controller
649
		 * @see client/html/checkout/update/url/config
650
		 */
651
		$action = $view->config( 'client/html/checkout/update/url/action', 'update' );
652
653
		/** client/html/checkout/update/url/config
654
		 * Associative list of configuration options used for generating the URL
655
		 *
656
		 * You can specify additional options as key/value pairs used when generating
657
		 * the URLs, like
658
		 *
659
		 *  client/html/<clientname>/url/config = array( 'absoluteUri' => true )
660
		 *
661
		 * The available key/value pairs depend on the application that embeds the e-commerce
662
		 * framework. This is because the infrastructure of the application is used for
663
		 * generating the URLs. The full list of available config options is referenced
664
		 * in the "see also" section of this page.
665
		 *
666
		 * @param string Associative list of configuration options
667
		 * @since 2014.03
668
		 * @category Developer
669
		 * @see client/html/checkout/update/url/target
670
		 * @see client/html/checkout/update/url/controller
671
		 * @see client/html/checkout/update/url/action
672
		 * @see client/html/url/config
673
		 */
674
		$config = $view->config( 'client/html/checkout/update/url/config', $config );
675
676
		return $view->url( $target, $cntl, $action, $params, [], $config );
677
	}
678
679
680
	/**
681
	 * Tests if one of the products is a subscription
682
	 *
683
	 * @param \Aimeos\Map $products Ordered products implementing \Aimeos\MShop\Order\Item\Base\Product\Iface
684
	 * @return bool True if at least one product is a subscription, false if not
685
	 */
686
	protected function isSubscription( \Aimeos\Map $products ) : bool
687
	{
688
		foreach( $products as $orderProduct )
689
		{
690
			if( $orderProduct->getAttributeItem( 'interval', 'config' ) ) {
691
				return true;
692
			}
693
		}
694
695
		return false;
696
	}
697
698
699
	/**
700
	 * Sets the necessary parameter values in the view.
701
	 *
702
	 * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
703
	 * @param array &$tags Result array for the list of tags that are associated to the output
704
	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
705
	 * @return \Aimeos\MW\View\Iface Modified view object
706
	 */
707
	public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface
708
	{
709
		$view->standardUrlPayment = $this->getUrlSelf( $view, array( 'c_step' => 'payment' ), [] );
710
711
		return parent::addData( $view, $tags, $expire );
712
	}
713
}
714