|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2022 |
|
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
|
|
|
/** |
|
25
|
|
|
* Processes the input, e.g. store given values. |
|
26
|
|
|
* |
|
27
|
|
|
* A view must be available and this method doesn't generate any output |
|
28
|
|
|
* besides setting view variables if necessary. |
|
29
|
|
|
*/ |
|
30
|
|
|
public function init() |
|
31
|
|
|
{ |
|
32
|
|
|
$view = $this->view(); |
|
33
|
|
|
$context = $this->context(); |
|
34
|
|
|
|
|
35
|
|
|
$session = $context->session(); |
|
36
|
|
|
|
|
37
|
|
|
if( ( $orderid = $session->get( 'aimeos/orderid' ) ) === null ) { |
|
38
|
|
|
throw new \Aimeos\Client\Html\Exception( 'No order ID available' ); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
if( ( $code = $view->param( 'code' ) ) !== null ) |
|
43
|
|
|
{ |
|
44
|
|
|
$serviceCntl = \Aimeos\Controller\Frontend::create( $context, 'service' ); |
|
45
|
|
|
$orderItem = $serviceCntl->updateSync( $view->request(), $code, $orderid ); |
|
46
|
|
|
} |
|
47
|
|
|
else |
|
48
|
|
|
{ |
|
49
|
|
|
$orderCntl = \Aimeos\Controller\Frontend::create( $context, 'order' ); |
|
50
|
|
|
$orderItem = $orderCntl->get( $orderid, false ); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
// update stock, coupons, etc. |
|
54
|
|
|
\Aimeos\Controller\Common\Order\Factory::create( $context )->update( $orderItem ); |
|
55
|
|
|
|
|
56
|
|
|
parent::init(); |
|
57
|
|
|
|
|
58
|
|
|
if( $orderItem->getStatusPayment() > \Aimeos\MShop\Order\Item\Base::PAY_REFUSED ) |
|
59
|
|
|
{ |
|
60
|
|
|
\Aimeos\Controller\Frontend::create( $context, 'basket' )->clear(); |
|
61
|
|
|
$session->remove( array_keys( $session->get( 'aimeos/basket/cache', [] ) ) ); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Sets the necessary parameter values in the view. |
|
68
|
|
|
* |
|
69
|
|
|
* @param \Aimeos\Base\View\Iface $view The view object which generates the HTML output |
|
70
|
|
|
* @param array &$tags Result array for the list of tags that are associated to the output |
|
71
|
|
|
* @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
72
|
|
|
* @return \Aimeos\Base\View\Iface Modified view object |
|
73
|
|
|
*/ |
|
74
|
|
|
public function data( \Aimeos\Base\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\Base\View\Iface |
|
75
|
|
|
{ |
|
76
|
|
|
$context = $this->context(); |
|
77
|
|
|
|
|
78
|
|
|
if( ( $id = $context->session()->get( 'aimeos/orderid' ) ) === null ) |
|
79
|
|
|
{ |
|
80
|
|
|
$context->logger()->log( 'Lost session at confirmation page' . PHP_EOL . print_r( $_SERVER, true ) ); |
|
|
|
|
|
|
81
|
|
|
throw new \Aimeos\Client\Html\Exception( $context->translate( 'client', 'No order ID available in session' ) ); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
$parts = ['order/base/address', 'order/base/coupon', 'order/base/product', 'order/base/service']; |
|
85
|
|
|
$controller = \Aimeos\Controller\Frontend::create( $this->context(), 'basket' ); |
|
86
|
|
|
$basket = $controller->load( $view->confirmOrderItem->getBaseId(), $parts, false ); |
|
87
|
|
|
|
|
88
|
|
|
$view->summaryBasket = $basket; |
|
89
|
|
|
$view->confirmOrderItem = \Aimeos\Controller\Frontend::create( $context, 'order' )->get( $id, false ); |
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
return parent::data( $view, $tags, $expire ); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
|
|
96
|
|
|
/** client/html/checkout/confirm/template-body |
|
97
|
|
|
* Relative path to the HTML body template of the checkout confirm client. |
|
98
|
|
|
* |
|
99
|
|
|
* The template file contains the HTML code and processing instructions |
|
100
|
|
|
* to generate the result shown in the body of the frontend. The |
|
101
|
|
|
* configuration string is the path to the template file relative |
|
102
|
|
|
* to the templates directory (usually in client/html/templates). |
|
103
|
|
|
* |
|
104
|
|
|
* You can overwrite the template file configuration in extensions and |
|
105
|
|
|
* provide alternative templates. These alternative templates should be |
|
106
|
|
|
* named like the default one but suffixed by |
|
107
|
|
|
* an unique name. You may use the name of your project for this. If |
|
108
|
|
|
* you've implemented an alternative client class as well, it |
|
109
|
|
|
* should be suffixed by the name of the new class. |
|
110
|
|
|
* |
|
111
|
|
|
* @param string Relative path to the template creating code for the HTML page body |
|
112
|
|
|
* @since 2014.03 |
|
113
|
|
|
* @see client/html/checkout/confirm/template-header |
|
114
|
|
|
*/ |
|
115
|
|
|
|
|
116
|
|
|
/** client/html/checkout/confirm/template-header |
|
117
|
|
|
* Relative path to the HTML header template of the checkout confirm client. |
|
118
|
|
|
* |
|
119
|
|
|
* The template file contains the HTML code and processing instructions |
|
120
|
|
|
* to generate the HTML code that is inserted into the HTML page header |
|
121
|
|
|
* of the rendered page in the frontend. The configuration string is the |
|
122
|
|
|
* path to the template file relative to the templates directory (usually |
|
123
|
|
|
* in client/html/templates). |
|
124
|
|
|
* |
|
125
|
|
|
* You can overwrite the template file configuration in extensions and |
|
126
|
|
|
* provide alternative templates. These alternative templates should be |
|
127
|
|
|
* named like the default one but suffixed by |
|
128
|
|
|
* an unique name. You may use the name of your project for this. If |
|
129
|
|
|
* you've implemented an alternative client class as well, it |
|
130
|
|
|
* should be suffixed by the name of the new class. |
|
131
|
|
|
* |
|
132
|
|
|
* @param string Relative path to the template creating code for the HTML page head |
|
133
|
|
|
* @since 2014.03 |
|
134
|
|
|
* @see client/html/checkout/confirm/template-body |
|
135
|
|
|
*/ |
|
136
|
|
|
} |
|
137
|
|
|
|