Passed
Pull Request — master (#138)
by
unknown
04:31 queued 10s
created

Standard::getUrlConfirm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 74
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 3
dl 0
loc 74
rs 10
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
				$config = array();
287
288
				$services = $basket->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT );
289
290
				if( ( $service = reset( $services ) ) !== false )
291
				{
292
					$args = array( 'code' => $service->getCode() );
293
					$config = array( 'absoluteUri' => true, 'namespace' => false );
294
				}
295
296
				$orderCntl->save( $orderItem->setPaymentStatus( \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED ) );
297
				$view->standardUrlNext = $this->getUrlConfirm( $view, $args, $config );
298
				$view->standardMethod = 'POST';
299
			}
300
			else // no payment service available
301
			{
302
				$view = $this->addFormData( $view, $form );
303
			}
304
		}
305
		catch( \Aimeos\Client\Html\Exception $e )
306
		{
307
			$error = array( $context->getI18n()->dt( 'client', $e->getMessage() ) );
308
			$view->standardErrorList = array_merge( $view->get( 'standardErrorList', [] ), $error );
309
		}
310
		catch( \Aimeos\Controller\Frontend\Exception $e )
311
		{
312
			$error = array( $context->getI18n()->dt( 'controller/frontend', $e->getMessage() ) );
313
			$view->standardErrorList = array_merge( $view->get( 'standardErrorList', [] ), $error );
314
		}
315
		catch( \Aimeos\MShop\Exception $e )
316
		{
317
			$error = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) );
318
			$view->standardErrorList = array_merge( $view->get( 'standardErrorList', [] ), $error );
319
		}
320
		catch( \Exception $e )
321
		{
322
			$error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) );
323
			$view->standardErrorList = array_merge( $view->get( 'standardErrorList', [] ), $error );
324
			$this->logException( $e );
325
		}
326
	}
327
328
329
	/**
330
	 * Adds the required data for the payment form to the view
331
	 *
332
	 * @param \Aimeos\MW\View\Iface $view View object to assign the data to
333
	 * @param \Aimeos\MShop\Common\Helper\Form\Iface $form Form helper object including the form data
334
	 * @return \Aimeos\MW\View\Iface View object with assigned data
335
	 */
336
	protected function addFormData( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Common\Helper\Form\Iface $form )
337
	{
338
		$url = $form->getUrl();
339
340
		if( $form->getMethod() === 'GET' )
341
		{
342
			$urlParams = [];
343
344
			foreach( $form->getValues() as $item )
345
			{
346
				foreach( (array) $item->getDefault() as $key => $value ) {
347
					$urlParams[$item->getInternalCode()][$key] = $value;
348
				}
349
			}
350
351
			$url .= strpos( $url, '?' ) ? '&' : '?' . map( $urlParams )->toUrl();
352
		}
353
354
		$public = $hidden = [];
355
356
		foreach( $form->getValues() as $key => $item )
357
		{
358
			if( $item->isPublic() ) {
359
				$public[$key] = $item;
360
			} else {
361
				$hidden[$key] = $item;
362
			}
363
		}
364
365
		$view->standardUrlNext = $url;
366
		$view->standardProcessPublic = $public;
367
		$view->standardProcessHidden = $hidden;
368
		$view->standardProcessParams = $form->getValues();
369
		$view->standardUrlExternal = $form->getExternal();
370
		$view->standardMethod = $form->getMethod();
371
		$view->standardHtml = $form->getHtml();
372
373
		return $view;
374
	}
375
376
377
	/**
378
	 * Returns the form helper object for building the payment form in the frontend
379
	 *
380
	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Saved basket object including payment service object
381
	 * @param \Aimeos\MShop\Order\Item\Iface $orderItem Saved order item created for the basket object
382
	 * @return \Aimeos\MShop\Common\Helper\Form\Iface|null Form object with URL, parameters, etc.
383
	 * 	or null if no form data is required
384
	 */
385
	protected function processPayment( \Aimeos\MShop\Order\Item\Base\Iface $basket, \Aimeos\MShop\Order\Item\Iface $orderItem ) : ?\Aimeos\MShop\Common\Helper\Form\Iface
386
	{
387
		if( $basket->getPrice()->getValue() + $basket->getPrice()->getCosts() <= 0
388
			&& $this->isSubscription( $basket->getProducts() ) === false
389
		) {
390
			return null;
391
		}
392
393
		$view = $this->getView();
394
		$services = $basket->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT );
395
396
		if( ( $service = reset( $services ) ) !== false )
397
		{
398
			$args = array( 'code' => $service->getCode() );
399
			$config = array( 'absoluteUri' => true, 'namespace' => false );
400
			$urls = array(
401
				'payment.url-self' => $this->getUrlSelf( $view, ['c_step' => 'process'], [] ),
402
				'payment.url-update' => $this->getUrlUpdate( $view, $args + ['orderid' => $orderItem->getId()], $config ),
403
				'payment.url-success' => $this->getUrlConfirm( $view, $args, $config ),
404
			);
405
406
			$params = $view->param();
407
			foreach( $service->getAttributeItems() as $item ) {
408
				$params[$item->getCode()] = $item->getValue();
409
			}
410
411
			$serviceCntl = \Aimeos\Controller\Frontend::create( $this->getContext(), 'service' );
412
			return $serviceCntl->process( $orderItem, $service->getServiceId(), $urls, $params );
413
		}
414
	}
415
416
417
	/**
418
	 * Returns the list of sub-client names configured for the client.
419
	 *
420
	 * @return array List of HTML client names
421
	 */
422
	protected function getSubClientNames() : array
423
	{
424
		return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
425
	}
426
427
428
	/**
429
	 * Returns the URL to the confirm page.
430
	 *
431
	 * @param \Aimeos\MW\View\Iface $view View object
432
	 * @param array $params Parameters that should be part of the URL
433
	 * @param array $config Default URL configuration
434
	 * @return string URL string
435
	 */
436
	protected function getUrlConfirm( \Aimeos\MW\View\Iface $view, array $params, array $config ) : string
437
	{
438
		/** client/html/checkout/confirm/url/target
439
		 * Destination of the URL where the controller specified in the URL is known
440
		 *
441
		 * The destination can be a page ID like in a content management system or the
442
		 * module of a software development framework. This "target" must contain or know
443
		 * the controller that should be called by the generated URL.
444
		 *
445
		 * @param string Destination of the URL
446
		 * @since 2014.03
447
		 * @category Developer
448
		 * @see client/html/checkout/confirm/url/controller
449
		 * @see client/html/checkout/confirm/url/action
450
		 * @see client/html/checkout/confirm/url/config
451
		 */
452
		$target = $view->config( 'client/html/checkout/confirm/url/target' );
453
454
		/** client/html/checkout/confirm/url/controller
455
		 * Name of the controller whose action should be called
456
		 *
457
		 * In Model-View-Controller (MVC) applications, the controller contains the methods
458
		 * that create parts of the output displayed in the generated HTML page. Controller
459
		 * names are usually alpha-numeric.
460
		 *
461
		 * @param string Name of the controller
462
		 * @since 2014.03
463
		 * @category Developer
464
		 * @see client/html/checkout/confirm/url/target
465
		 * @see client/html/checkout/confirm/url/action
466
		 * @see client/html/checkout/confirm/url/config
467
		 */
468
		$cntl = $view->config( 'client/html/checkout/confirm/url/controller', 'checkout' );
469
470
		/** client/html/checkout/confirm/url/action
471
		 * Name of the action that should create the output
472
		 *
473
		 * In Model-View-Controller (MVC) applications, actions are the methods of a
474
		 * controller that create parts of the output displayed in the generated HTML page.
475
		 * Action names are usually alpha-numeric.
476
		 *
477
		 * @param string Name of the action
478
		 * @since 2014.03
479
		 * @category Developer
480
		 * @see client/html/checkout/confirm/url/target
481
		 * @see client/html/checkout/confirm/url/controller
482
		 * @see client/html/checkout/confirm/url/config
483
		 */
484
		$action = $view->config( 'client/html/checkout/confirm/url/action', 'confirm' );
485
486
		/** client/html/checkout/confirm/url/config
487
		 * Associative list of configuration options used for generating the URL
488
		 *
489
		 * You can specify additional options as key/value pairs used when generating
490
		 * the URLs, like
491
		 *
492
		 *  client/html/<clientname>/url/config = array( 'absoluteUri' => true )
493
		 *
494
		 * The available key/value pairs depend on the application that embeds the e-commerce
495
		 * framework. This is because the infrastructure of the application is used for
496
		 * generating the URLs. The full list of available config options is referenced
497
		 * in the "see also" section of this page.
498
		 *
499
		 * @param string Associative list of configuration options
500
		 * @since 2014.03
501
		 * @category Developer
502
		 * @see client/html/checkout/confirm/url/target
503
		 * @see client/html/checkout/confirm/url/controller
504
		 * @see client/html/checkout/confirm/url/action
505
		 * @see client/html/url/config
506
		 */
507
		$config = $view->config( 'client/html/checkout/confirm/url/config', $config );
508
509
		return $view->url( $target, $cntl, $action, $params, [], $config );
510
	}
511
512
513
	/**
514
	 * Returns the URL to the current page.
515
	 *
516
	 * @param \Aimeos\MW\View\Iface $view View object
517
	 * @param array $params Parameters that should be part of the URL
518
	 * @param array $config Default URL configuration
519
	 * @return string URL string
520
	 */
521
	protected function getUrlSelf( \Aimeos\MW\View\Iface $view, array $params, array $config ) : string
522
	{
523
		/** client/html/checkout/standard/url/target
524
		 * Destination of the URL where the controller specified in the URL is known
525
		 *
526
		 * The destination can be a page ID like in a content management system or the
527
		 * module of a software development framework. This "target" must contain or know
528
		 * the controller that should be called by the generated URL.
529
		 *
530
		 * @param string Destination of the URL
531
		 * @since 2014.03
532
		 * @category Developer
533
		 * @see client/html/checkout/standard/url/controller
534
		 * @see client/html/checkout/standard/url/action
535
		 * @see client/html/checkout/standard/url/config
536
		 */
537
		$target = $view->config( 'client/html/checkout/standard/url/target' );
538
539
		/** client/html/checkout/standard/url/controller
540
		 * Name of the controller whose action should be called
541
		 *
542
		 * In Model-View-Controller (MVC) applications, the controller contains the methods
543
		 * that create parts of the output displayed in the generated HTML page. Controller
544
		 * names are usually alpha-numeric.
545
		 *
546
		 * @param string Name of the controller
547
		 * @since 2014.03
548
		 * @category Developer
549
		 * @see client/html/checkout/standard/url/target
550
		 * @see client/html/checkout/standard/url/action
551
		 * @see client/html/checkout/standard/url/config
552
		 */
553
		$cntl = $view->config( 'client/html/checkout/standard/url/controller', 'checkout' );
554
555
		/** client/html/checkout/standard/url/action
556
		 * Name of the action that should create the output
557
		 *
558
		 * In Model-View-Controller (MVC) applications, actions are the methods of a
559
		 * controller that create parts of the output displayed in the generated HTML page.
560
		 * Action names are usually alpha-numeric.
561
		 *
562
		 * @param string Name of the action
563
		 * @since 2014.03
564
		 * @category Developer
565
		 * @see client/html/checkout/standard/url/target
566
		 * @see client/html/checkout/standard/url/controller
567
		 * @see client/html/checkout/standard/url/config
568
		 */
569
		$action = $view->config( 'client/html/checkout/standard/url/action', 'index' );
570
571
		/** client/html/checkout/standard/url/config
572
		 * Associative list of configuration options used for generating the URL
573
		 *
574
		 * You can specify additional options as key/value pairs used when generating
575
		 * the URLs, like
576
		 *
577
		 *  client/html/<clientname>/url/config = array( 'absoluteUri' => true )
578
		 *
579
		 * The available key/value pairs depend on the application that embeds the e-commerce
580
		 * framework. This is because the infrastructure of the application is used for
581
		 * generating the URLs. The full list of available config options is referenced
582
		 * in the "see also" section of this page.
583
		 *
584
		 * @param string Associative list of configuration options
585
		 * @since 2014.03
586
		 * @category Developer
587
		 * @see client/html/checkout/standard/url/target
588
		 * @see client/html/checkout/standard/url/controller
589
		 * @see client/html/checkout/standard/url/action
590
		 * @see client/html/url/config
591
		 */
592
		$config = $view->config( 'client/html/checkout/standard/url/config', $config );
593
594
		return $view->url( $target, $cntl, $action, $params, [], $config );
595
	}
596
597
598
	/**
599
	 * Returns the URL to the update page.
600
	 *
601
	 * @param \Aimeos\MW\View\Iface $view View object
602
	 * @param array $params Parameters that should be part of the URL
603
	 * @param array $config Default URL configuration
604
	 * @return string URL string
605
	 */
606
	protected function getUrlUpdate( \Aimeos\MW\View\Iface $view, array $params, array $config ) : string
607
	{
608
		/** client/html/checkout/update/url/target
609
		 * Destination of the URL where the controller specified in the URL is known
610
		 *
611
		 * The destination can be a page ID like in a content management system or the
612
		 * module of a software development framework. This "target" must contain or know
613
		 * the controller that should be called by the generated URL.
614
		 *
615
		 * @param string Destination of the URL
616
		 * @since 2014.03
617
		 * @category Developer
618
		 * @see client/html/checkout/update/url/controller
619
		 * @see client/html/checkout/update/url/action
620
		 * @see client/html/checkout/update/url/config
621
		 */
622
		$target = $view->config( 'client/html/checkout/update/url/target' );
623
624
		/** client/html/checkout/update/url/controller
625
		 * Name of the controller whose action should be called
626
		 *
627
		 * In Model-View-Controller (MVC) applications, the controller contains the methods
628
		 * that create parts of the output displayed in the generated HTML page. Controller
629
		 * names are usually alpha-numeric.
630
		 *
631
		 * @param string Name of the controller
632
		 * @since 2014.03
633
		 * @category Developer
634
		 * @see client/html/checkout/update/url/target
635
		 * @see client/html/checkout/update/url/action
636
		 * @see client/html/checkout/update/url/config
637
		 */
638
		$cntl = $view->config( 'client/html/checkout/update/url/controller', 'checkout' );
639
640
		/** client/html/checkout/update/url/action
641
		 * Name of the action that should create the output
642
		 *
643
		 * In Model-View-Controller (MVC) applications, actions are the methods of a
644
		 * controller that create parts of the output displayed in the generated HTML page.
645
		 * Action names are usually alpha-numeric.
646
		 *
647
		 * @param string Name of the action
648
		 * @since 2014.03
649
		 * @category Developer
650
		 * @see client/html/checkout/update/url/target
651
		 * @see client/html/checkout/update/url/controller
652
		 * @see client/html/checkout/update/url/config
653
		 */
654
		$action = $view->config( 'client/html/checkout/update/url/action', 'update' );
655
656
		/** client/html/checkout/update/url/config
657
		 * Associative list of configuration options used for generating the URL
658
		 *
659
		 * You can specify additional options as key/value pairs used when generating
660
		 * the URLs, like
661
		 *
662
		 *  client/html/<clientname>/url/config = array( 'absoluteUri' => true )
663
		 *
664
		 * The available key/value pairs depend on the application that embeds the e-commerce
665
		 * framework. This is because the infrastructure of the application is used for
666
		 * generating the URLs. The full list of available config options is referenced
667
		 * in the "see also" section of this page.
668
		 *
669
		 * @param string Associative list of configuration options
670
		 * @since 2014.03
671
		 * @category Developer
672
		 * @see client/html/checkout/update/url/target
673
		 * @see client/html/checkout/update/url/controller
674
		 * @see client/html/checkout/update/url/action
675
		 * @see client/html/url/config
676
		 */
677
		$config = $view->config( 'client/html/checkout/update/url/config', $config );
678
679
		return $view->url( $target, $cntl, $action, $params, [], $config );
680
	}
681
682
683
	/**
684
	 * Tests if one of the products is a subscription
685
	 *
686
	 * @param \Aimeos\Map $products Ordered products implementing \Aimeos\MShop\Order\Item\Base\Product\Iface
687
	 * @return bool True if at least one product is a subscription, false if not
688
	 */
689
	protected function isSubscription( \Aimeos\Map $products ) : bool
690
	{
691
		foreach( $products as $orderProduct )
692
		{
693
			if( $orderProduct->getAttributeItem( 'interval', 'config' ) ) {
694
				return true;
695
			}
696
		}
697
698
		return false;
699
	}
700
701
702
	/**
703
	 * Sets the necessary parameter values in the view.
704
	 *
705
	 * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
706
	 * @param array &$tags Result array for the list of tags that are associated to the output
707
	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
708
	 * @return \Aimeos\MW\View\Iface Modified view object
709
	 */
710
	public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface
711
	{
712
		$view->standardUrlPayment = $this->getUrlSelf( $view, array( 'c_step' => 'payment' ), [] );
713
714
		return parent::addData( $view, $tags, $expire );
715
	}
716
}
717