1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2013 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2025 |
7
|
|
|
* @package Client |
8
|
|
|
* @subpackage Html |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
namespace Aimeos\Client\Html\Checkout\Standard\Summary; |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
// Strings for translation |
16
|
|
|
sprintf( 'summary' ); |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Default implementation of checkout summary HTML client. |
21
|
|
|
* |
22
|
|
|
* @package Client |
23
|
|
|
* @subpackage Html |
24
|
|
|
*/ |
25
|
|
|
class Standard |
26
|
|
|
extends \Aimeos\Client\Html\Base |
27
|
|
|
implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* Returns the HTML code for insertion into the body. |
31
|
|
|
* |
32
|
|
|
* @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
33
|
|
|
* @return string HTML code |
34
|
|
|
*/ |
35
|
|
|
public function body( string $uid = '' ) : string |
36
|
|
|
{ |
37
|
|
|
$view = $this->view(); |
38
|
|
|
$step = $view->get( 'standardStepActive' ); |
39
|
|
|
$onepage = $view->config( 'client/html/checkout/standard/onepage', [] ); |
40
|
|
|
|
41
|
|
|
if( $step != 'summary' && !( in_array( 'summary', $onepage ) && in_array( $step, $onepage ) ) ) { |
42
|
|
|
return ''; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
return parent::body( $uid ); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Processes the input, e.g. store given values. |
51
|
|
|
* |
52
|
|
|
* A view must be available and this method doesn't generate any output |
53
|
|
|
* besides setting view variables. |
54
|
|
|
*/ |
55
|
|
|
public function init() |
56
|
|
|
{ |
57
|
|
|
$result = true; |
58
|
|
|
$view = $this->view(); |
59
|
|
|
|
60
|
|
|
try |
61
|
|
|
{ |
62
|
|
|
if( $view->param( 'cs_order', null ) === null ) { |
63
|
|
|
return $result; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
$context = $this->context(); |
68
|
|
|
$controller = \Aimeos\Controller\Frontend::create( $context, 'basket' ); |
69
|
|
|
$customerref = strip_tags( $view->param( 'cs_customerref', '', false ) ); |
70
|
|
|
$comment = strip_tags( $view->param( 'cs_comment', '', false ) ); |
71
|
|
|
|
72
|
|
|
if( $customerref || $comment ) |
73
|
|
|
{ |
74
|
|
|
$controller->get()->setCustomerReference( $customerref )->setComment( $comment ); |
75
|
|
|
$controller->save(); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
// only start if there's something to do |
80
|
|
|
if( $view->param( 'cs_option_terms', null ) !== null |
81
|
|
|
&& ( $option = $view->param( 'cs_option_terms_value', 0 ) ) != 1 |
|
|
|
|
82
|
|
|
) { |
83
|
|
|
$error = $view->translate( 'client', 'Please accept the terms and conditions' ); |
84
|
|
|
$errors = $view->get( 'summaryErrorCodes', [] ); |
85
|
|
|
$errors['option']['terms'] = $error; |
86
|
|
|
|
87
|
|
|
$view->summaryErrorCodes = $errors; |
88
|
|
|
$view->standardStepActive = 'summary'; |
89
|
|
|
$view->errors = array_merge( $view->get( 'errors', [] ), array( $error ) ); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
|
93
|
|
|
parent::init(); |
94
|
|
|
|
95
|
|
|
$controller->get()->check( $context->config()->get( 'mshop/order/manager/subdomains', [] ) ); |
96
|
|
|
} |
97
|
|
|
catch( \Exception $e ) |
98
|
|
|
{ |
99
|
|
|
$view->standardStepActive = 'summary'; |
100
|
|
|
throw $e; |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
|
105
|
|
|
/** client/html/checkout/standard/summary/template-body |
106
|
|
|
* Relative path to the HTML body template of the checkout standard summary client. |
107
|
|
|
* |
108
|
|
|
* The template file contains the HTML code and processing instructions |
109
|
|
|
* to generate the result shown in the body of the frontend. The |
110
|
|
|
* configuration string is the path to the template file relative |
111
|
|
|
* to the templates directory (usually in templates/client/html). |
112
|
|
|
* |
113
|
|
|
* You can overwrite the template file configuration in extensions and |
114
|
|
|
* provide alternative templates. These alternative templates should be |
115
|
|
|
* named like the default one but suffixed by |
116
|
|
|
* an unique name. You may use the name of your project for this. If |
117
|
|
|
* you've implemented an alternative client class as well, it |
118
|
|
|
* should be suffixed by the name of the new class. |
119
|
|
|
* |
120
|
|
|
* @param string Relative path to the template creating code for the HTML page body |
121
|
|
|
* @since 2014.03 |
122
|
|
|
* @see client/html/checkout/standard/summary/template-header |
123
|
|
|
*/ |
124
|
|
|
} |
125
|
|
|
|