/
Base.php
106 lines (91 loc) · 2.93 KB
/
Base.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/**
* @copyright Metaways Infosystems GmbH, 2013
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
* @copyright Aimeos (aimeos.org), 2015
* @package Client
* @subpackage Html
*/
namespace Aimeos\Client\Html\Common\Summary\Detail;
/**
* Default implementation of checkout detail summary HTML client.
*
* @package Client
* @subpackage Html
*/
abstract class Base
extends \Aimeos\Client\Html\Common\Client\Factory\Base
{
/**
* Returns a list of tax rates and values for the given basket.
*
* @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket containing the products, services, etc.
* @return array Associative list of tax rates as key and corresponding amounts as value
*/
protected function getTaxRates( \Aimeos\MShop\Order\Item\Base\Iface $basket )
{
$taxrates = array();
foreach( $basket->getProducts() as $product )
{
$price = clone $product->getPrice();
$taxrate = $price->getTaxrate();
if( isset( $taxrates[$taxrate] ) ) {
$taxrates[$taxrate]->addItem( $price, $product->getQuantity() );
} else {
$taxrates[$taxrate] = $price->addItem( $price, $product->getQuantity() - 1 );
}
}
try
{
$price = clone $basket->getService( 'delivery' )->getPrice();
$taxrate = $price->getTaxrate();
if( isset( $taxrates[$taxrate] ) ) {
$taxrates[$taxrate]->addItem( $price );
} else {
$taxrates[$taxrate] = $price;
}
}
catch( \Exception $e ) { ; } // if delivery service isn't available
try
{
$price = clone $basket->getService( 'payment' )->getPrice();
$taxrate = $price->getTaxrate();
if( isset( $taxrates[$taxrate] ) ) {
$taxrates[$taxrate]->addItem( $price );
} else {
$taxrates[$taxrate] = $price;
}
}
catch( \Exception $e ) { ; } // if payment service isn't available
return $taxrates;
}
/**
* Returns the payment status at which download files are shown
*
* @return integer Payment status from \Aimeos\MShop\Order\Item\Base
*/
protected function getDownloadPaymentStatus()
{
$config = $this->getContext()->getConfig();
$default = \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED;
/** client/html/common/summary/detail/download/payment-status
* Minium payment status value for product download files
*
* This setting specifies the payment status value of an order for which
* links to bought product download files are shown on the "thank you"
* page, in the "MyAccount" and in the e-mails sent to the customers.
*
* The value is one of the payment constant values from
* {@link https://github.com/aimeos/aimeos-core/blob/master/lib/mshoplib/src/MShop/Order/Item/Base.php#L105}.
* Most of the time, only two values are of interest:
* * 5: payment authorized
* * 6: payment received
*
* @param integer Order payment constant value
* @since 2016.3
* @category User
* @category Developer
*/
return $config->get( 'client/html/common/summary/detail/download/payment-status', $default );
}
}