Files
shopPRO/templates/shop-basket/basket-details.php
2024-10-23 13:44:50 +02:00

114 lines
5.3 KiB
PHP

<div class="mini-box">
<h1 class="box-title"><?= ucfirst( \S::lang( 'zawartosc-koszyka' ) ); ?>:</h1>
<div id="basket" class="content">
<? if ( is_array( $this -> basket ) and count($this->basket)) : ?>
<? foreach ($this->basket as $position_hash => $position) : ?>
<?
unset( $price );
unset( $price_new );
$product = \shop\Product::getFromCache( (int)$position['product-id'], $this -> lang_id );
?>
<div class="basket-product">
<div class="image">
<? if ( file_exists( substr( $product['images'][0]['src'], 1 ) ) ) : ?>
<img class="main-img" src="<?= $product['images'][0]['src']; ?>" alt="">
<? else : ?>
<? endif; ?>
</div>
<div class="details">
<?php
$url = \front\factory\ShopProduct::product_url( $product );
if ( \S::get_session( 'current-lang' ) != \front\factory\Languages::default_language() and $url != '#')
$url = '/' . \S::get_session('current-lang') . $url;
?>
<div class="name">
<a href="<?= $url; ?>"><?= $product['language']['name']; ?></a>
</div>
<? if (is_array($position['attributes']) and count($position['attributes'])) : ?>
<? foreach ($position['attributes'] as $row) : ?>
<div class="description">
<?
if ($row)
{
$row = explode('-', $row);
$attribute = \front\factory\ShopAttribute::attribute_details($row[0], $this->lang_id);
echo '<div>' . $attribute['language']['name'] . ':</div>';
$value = \front\factory\ShopAttribute::value_details($row[1], $this->lang_id);
echo '<div>' . $value['language']['name'] . '</div>';
}
?>
</div>
<? endforeach; ?>
<hr>
<? endif; ?>
<?= \Tpl::view( 'shop-basket/_partials/product-custom-fields', [
'custom_fields' => $position['custom_fields']
] ); ?>
<? if ( $product -> additional_message ):?>
<div class="basket-product-message">
<textarea name="product-message" class="form-control" position="<?= $position_hash;?>" placeholder="Miejsce na dodatkową wiadomość"><?= htmlspecialchars( $position['message'] );?></textarea>
</div>
<? endif;?>
</div>
<div class="prices">
<div class="price">
<?
$price_product = \shop\Product::calculate_basket_product_price( (float)$product['price_brutto_promo'], (float)$product['price_brutto'], $this -> coupon, $position );
if ( $price_product['price_new'] )
echo \S::decimal( $price_product['price_new'] ) . ' zł';
if ($price_product['price_new'] and $price_product['price_new'] < $price_product['price'])
echo '<u>' . \S::decimal( $price_product['price'] ) . ' zł</u>';
if ($price_product['price_new'] and $price_product['price_new'] < $price_product['price'])
$discount += \S::normalize_decimal(($price_product['price'] - $price_product['price_new']) * $position['quantity']);
?>
</div>
</div>
<div class="buttons">
<a href="#" class="btn btn-default btn-minus" product-hash="<?= $position_hash; ?>">
<i class="fa fa-minus"></i>
</a>
<input type="text" name="quantity" id="quantity" class="int-format form-control" min="1" max="<?= \shop\Product::get_product_quantity( (int)$position['product-id'] ); ?>" value="<?= $position['quantity']; ?>" product-hash="<?= $position_hash; ?>">
<a href="#" class="btn btn-default btn-plus" product-hash="<?= $position_hash; ?>">
<i class="fa fa-plus"></i>
</a>
<a href="#" class="btn btn-danger btn-delete" product-hash="<?= $position_hash; ?>">
<i class="fa fa-trash"></i>
</a>
</div>
</div>
<? $summary += $price_product['price'] * $position['quantity'];?>
<? endforeach; ?>
<div class="basket-summary">
Wartość koszyka: <span class="price"><?= \S::decimal($summary); ?> zł</span>
</div>
<? if ($discount) : ?>
<div class="basket-summary">
Rabat:
<span class="text-danger">-<?= \S::decimal($discount); ?> zł</span>
</div>
<div class="basket-summary">
Wartość koszyka po rabacie:
<span class="text-danger"><?= \S::decimal($summary - $discount); ?> zł</span>
</div>
<? endif; ?>
<div class="basket-bottom">
<div class="basket-message">
<textarea name="basket-message" class="form-control" id="basket-message" placeholder="Dodatkowe informacje..."><?= htmlspecialchars($this->basket_message); ?></textarea>
</div>
<div class="coupon">
<?= \Tpl::view( 'shop-coupon/form', [
'coupon' => \S::get_session('coupon')
] );
?>
</div>
</div>
<? else : ?>
<div class="alert alert-danger">Brak produktów w koszyku</div>
<? endif; ?>
</div>
</div>