|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
You may not change or alter any portion of this comment or credits |
|
4
|
|
|
of supporting developers from this source code or any supporting source code |
|
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
6
|
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
|
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* oledrion |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
16
|
|
|
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
|
17
|
|
|
* @author Hervé Thouzard (http://www.herve-thouzard.com/) |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* block to display items in cart |
|
22
|
|
|
* |
|
23
|
|
|
* @param integer $options [0] Count of items to show (0 = no limit) |
|
24
|
|
|
* @return array Block's content |
|
|
|
|
|
|
25
|
|
|
*/ |
|
26
|
|
|
function b_oledrion_cart_show($options) |
|
27
|
|
|
{ |
|
28
|
|
|
global $mod_pref, $xoopsConfig; |
|
|
|
|
|
|
29
|
|
|
include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php'; |
|
30
|
|
|
$productsCount = (int)$options[0]; |
|
31
|
|
|
|
|
32
|
|
|
$cartForTemplate = $block = array(); |
|
33
|
|
|
$emptyCart = false; |
|
34
|
|
|
$shippingAmount = $commandAmount = $vatAmount = $discountsCount = 0; |
|
35
|
|
|
$goOn = ''; |
|
36
|
|
|
$commandAmountTTC = 0; |
|
37
|
|
|
$discountsDescription = array(); |
|
38
|
|
|
// Calcul du montant total du caddy |
|
39
|
|
|
$reductions = new oledrion_reductions(); |
|
40
|
|
|
$reductions->computeCart($cartForTemplate, $emptyCart, $shippingAmount, $commandAmount, $vatAmount, $goOn, $commandAmountTTC, $discountsDescription, $discountsCount); |
|
|
|
|
|
|
41
|
|
|
$dec = OledrionUtility::getModuleOption('decimals_count'); |
|
42
|
|
|
if ($emptyCart) { |
|
43
|
|
|
return ''; |
|
44
|
|
|
} |
|
45
|
|
|
$block['block_money_full'] = OledrionUtility::getModuleOption('money_full'); |
|
46
|
|
|
$block['block_money_short'] = OledrionUtility::getModuleOption('money_short'); |
|
47
|
|
|
$block['block_shippingAmount'] = sprintf('%0.' . $dec . 'f', $shippingAmount); // Montant des frais de port |
|
48
|
|
|
$block['block_commandAmount'] = sprintf('%0.' . $dec . 'f', $commandAmount); // Montant HT de la commande |
|
49
|
|
|
$block['block_vatAmount'] = sprintf('%0.' . $dec . 'f', $vatAmount); // Montant de la TVA |
|
50
|
|
|
$block['block_commandAmountTTC'] = sprintf('%0.' . $dec . 'f', $commandAmountTTC); // Montant TTC de la commande |
|
51
|
|
|
$block['block_discountsDescription'] = $discountsDescription; // Liste des réductions accordées |
|
52
|
|
|
if (($productsCount > 0) && (count($cartForTemplate) > $productsCount)) { |
|
53
|
|
|
array_slice($cartForTemplate, 0, $productsCount - 1); |
|
54
|
|
|
} |
|
55
|
|
|
$block['block_caddieProducts'] = $cartForTemplate; // Produits dans le caddy |
|
56
|
|
|
|
|
57
|
|
|
return $block; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param $options |
|
62
|
|
|
* @return string |
|
63
|
|
|
*/ |
|
64
|
|
View Code Duplication |
function b_oledrion_cart_edit($options) |
|
|
|
|
|
|
65
|
|
|
{ |
|
66
|
|
|
global $xoopsConfig; |
|
|
|
|
|
|
67
|
|
|
include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php'; |
|
68
|
|
|
$form = ''; |
|
69
|
|
|
$form .= "<table border='0'>"; |
|
70
|
|
|
$form .= '<tr><td>' . _MB_OLEDRION_MAX_ITEMS . "</td><td><input type='text' name='options[]' id='options' value='" . $options[0] . "'></td></tr>"; |
|
71
|
|
|
$form .= '</table>'; |
|
72
|
|
|
|
|
73
|
|
|
return $form; |
|
74
|
|
|
} |
|
75
|
|
|
|
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.