first commit
This commit is contained in:
50
web/block.cartInfo.php
Normal file
50
web/block.cartInfo.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
// #####################################################
|
||||
// # BLOK MENU - VYPISE AKTIVNI VLASTNI ODKAZY V MENU
|
||||
|
||||
use KupShop\KupShopBundle\Context\UserContext;
|
||||
use KupShop\KupShopBundle\Util\Contexts;
|
||||
|
||||
function block_cartInfo()
|
||||
{
|
||||
$totalPieces = 0;
|
||||
$totalProducts = 0;
|
||||
$totalPriceWithVat = DecimalConstants::zero();
|
||||
$totalPriceNoVat = DecimalConstants::zero();
|
||||
$freeShipping = false;
|
||||
|
||||
if (Contexts::get(UserContext::class)->isActive()) {
|
||||
$items = CartItem::createFromSpec(\Query\Operator::equals(['c.id_user' => Contexts::get(UserContext::class)->getActiveId()]));
|
||||
} else {
|
||||
$items = CartItem::createFromSpec(\Query\Operator::equals(['c.user_key' => Cart::getCartID()]));
|
||||
}
|
||||
|
||||
foreach ($items as $item) {
|
||||
/*if (findModule(Modules::PRICELISTS)) {
|
||||
$item['price'] = $item['product']->price_array;
|
||||
}*/
|
||||
|
||||
$price = $item['price'];
|
||||
// celkova cena s dani
|
||||
$totalPriceWithVat = $totalPriceWithVat->add($price['value_with_vat']);
|
||||
// celkova cena bez dane
|
||||
$totalPriceNoVat = $totalPriceNoVat->add($price['value_without_vat']);
|
||||
// celkovy pocet druhu produktu
|
||||
$totalProducts++;
|
||||
// celkovy pocet objednavanych kusu
|
||||
$totalPieces += $item->pieces;
|
||||
// Doprava zdarma
|
||||
$freeShipping |= $item['freeShipping'];
|
||||
}
|
||||
|
||||
return [
|
||||
'items' => $items,
|
||||
'totalPrice' => printPrice($totalPriceWithVat, ['ceil' => false, 'decimal' => 'dynamic', 'dealerdiscount' => false]),
|
||||
'totalPriceWithVat_array' => formatPrice($totalPriceWithVat, 0, false),
|
||||
'totalPriceNoVat_array' => formatPrice($totalPriceNoVat, 0, false),
|
||||
'totalPieces' => $totalPieces,
|
||||
'totalProducts' => $totalProducts,
|
||||
'freeShipping' => $freeShipping,
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user