first commit

This commit is contained in:
2024-10-25 23:02:37 +02:00
commit faeb2e52e8
7653 changed files with 1095335 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
<?php
global $lang_id;
$attribute_details = \front\factory\ShopAttribute::attribute_details( $this -> attribute['id'], $lang_id );
if ( $attribute_details['type'] == 0 )
{
?>
<div class="attribute-container fradio-group attribute-<?= \S::seo( $attribute_details['language']['name'] );?>" level="<?= $this -> level;?>" order="<?= $this -> order;?>" attribute="<?= \S::seo( $attribute_details['language']['name'] );?>" attribute-name="<?= $attribute_details['language']['name'];?>">
<p class="attribute-label"><?= $attribute_details['language']['name'];?>:</p>
<? foreach ( $this -> attribute['values'] as $value ):?>
<div class="fradio">
<input type="radio" id="<?= $this -> attribute['id'];?>-<?= $value['id'];?>" <? if ( $value['is_default'] ):?>checked="checked"<? endif;?> require="true" value="<?= $this -> attribute['id'];?>-<?= $value['id'];?>" name="<?= \S::seo( $attribute_details['language']['name'] );?>">
<label for="<?= $this -> attribute['id'];?>-<?= $value['id'];?>" order="<?= $this -> order;?>"><?= \shop\ProductAttribute::get_value_name( $value['id'], $lang_id );?></label>
</div>
<? if ( $value['is_default'] ):?>
<script class="footer" type="text/javascript">
$( function()
{
<? if ( $this -> level == $this -> max_level ):?>
var refresh = true;
<? else:?>
var refresh = false;
<? endif;?>
fradio_label_click( $( "label[for='<?= $this -> attribute['id'];?>-<?= $value['id'];?>']" ), refresh );
});
</script>
<? endif;?>
<? endforeach;?>
</div>
<?
}

View File

@@ -0,0 +1,10 @@
<? if ( is_array( $this -> custom_fields ) ): foreach ( $this -> custom_fields as $custom_field ):?>
<div class="custom-field">
<div class="_name">
<?= $custom_field['name'];?>:
</div>
<div class="_input">
<input type="text" class="form-control" name="custom_field[<?= $custom_field['id_additional_field'];?>]" field_name="<?= $custom_field['name'];?>" value="">
</div>
</div>
<? endforeach; endif;?>

View File

@@ -0,0 +1,15 @@
<?php
use shop\Product;
$product_meta = Product::product_meta($this->product_id);
?>
<?php if (is_array($product_meta) && count($product_meta)): ?>
<? $lastKey = array_key_last($product_meta); ?>
<div id="product-meta">
Kategorie:
<? foreach ($product_meta as $key => $value) : ?>
<a href="/<?= $value['seo_link']; ?>"><?= $value['title']; ?></a><?= $lastKey != $key ? ', ': ''; ?>
<? endforeach; ?>
</div>
<?php endif; ?>

View File

@@ -0,0 +1,22 @@
<div class="warehouse-message">
<?
// jeżeli produkt nie jest kombinacją
if ( !$this -> product['product_combinations'] )
{
if ( $this -> product['quantity'] > 0 or $this -> product['quantity'] == 0 and $this -> product['stock_0_buy'] )
{
if ( $this -> product -> language['warehouse_message_nonzero'] )
echo $this -> product -> language['warehouse_message_nonzero'];
else if ( $this -> settings['warehouse_message_nonzero_' . $this -> lang_id] )
echo $this -> settings['warehouse_message_nonzero_' . $this -> lang_id];
}
else
{
if ( $this -> product -> language['warehouse_message_zero'] )
echo $this -> product -> language['warehouse_message_zero'];
else if ( $this -> settings['warehouse_message_zero_' . $this -> lang_id] )
echo $this -> settings['warehouse_message_zero_' . $this -> lang_id];
}
}
?>
</div>

View File

@@ -0,0 +1,69 @@
<? global $lang_id;?>
<?
$this -> product -> language['seo_link'] ? $url = '/' . $this -> product -> language['seo_link'] : $url = '/p-' . $this -> product['id'] . '-' . \S::seo( $this -> product -> language['name'] );
if ( \S::get_session( 'current-lang' ) != \front\factory\Languages::default_language() and $url != '#' )
$url = '/' . \S::get_session( 'current-lang' ) . $url;
?>
<div class="product-mini <?= $this -> product_mini_class;?>">
<? if ( $this -> product -> new_to_date and $this -> product -> new_to_date >= date( 'Y-m-d' ) ):?>
<div class="new"><?= \S::lang( 'nowosc' );?></div>
<? endif;?>
<a href="<?= $url;?>">
<div class="img">
<? if ( file_exists( substr( $this -> product -> images[0]['src'], 1 ) ) ):?>
<? if ( $this -> class == 'item' ):?>
<img class="<?= $this -> product_mini_class == 'swiper-slide' ? '' : 'owl-lazy';?>" src="/thumb/500/0/<?= substr( $this -> product -> images[0]['src'], 1, strlen( $this -> product -> images[0]['src'] ) );?>" alt="<?= $this -> product -> images[0]['alt'];?>">
<? else:?>
<img class="first" src="/thumb/500/0/<?= substr( $this -> product -> images[0]['src'], 1, strlen( $this -> product -> images[0]['src'] ) );?>" alt="<?= $this -> product -> images[0]['alt'];?>">
<? if ( file_exists( substr( $this -> product -> images[1]['src'], 1 ) ) ):?>
<img class="second" src="/thumb/1000/0/<?= substr( $this -> product -> images[1]['src'], 1, strlen( $this -> product -> images[1]['src'] ) );?>" alt="<?= $this -> product -> images[1]['alt'];?>">
<? else:?>
<img class="second" src="/thumb/1000/0/<?= substr( $this -> product -> images[0]['src'], 1, strlen( $this -> product -> images[0]['src'] ) );?>" alt="<?= $this -> product -> images[0]['alt'];?>">
<? endif;?>
<? endif;?>
<? else:?>
<? endif;?>
</div>
<div class="product-details">
<h2 class="name">
<?= $this -> product -> language['name'];?>
</h2>
<div class="prices">
<?
$prices = $this -> product -> getDefaultCombinationPrices();
if ( $prices )
{
if ( $prices['price_brutto_promo'] ):?>
<div class="price-old">
<?= \shop\Shop::shortPrice( $prices['price_brutto'] );?> <span class="small">zł</span>
</div>
<div class="price">
<?= \shop\Shop::shortPrice( $prices['price_brutto_promo'] );?> <span class="small">zł</span>
</div>
<? else:?>
<div class="price">
<?= \shop\Shop::shortPrice( $prices['price_brutto'] );?> <span class="small">zł</span>
</div>
<? endif;
}
else
{
if ( $this -> product -> price_brutto_promo ):?>
<div class="price-old">
<?= \shop\Shop::shortPrice( $this -> product -> price_brutto );?> <span class="small">zł</span>
</div>
<div class="price">
<?= \shop\Shop::shortPrice( $this -> product -> price_brutto_promo );?> <span class="small">zł</span>
</div>
<? else:?>
<div class="price">
<?= \shop\Shop::shortPrice( $this -> product -> price_brutto );?> <span class="small">zł</span>
</div>
<? endif;
};?>
</div>
</div>
</a>
</div>

View File

@@ -0,0 +1,694 @@
<? global $lang_id;?>
<?
$attributes = \shop\Product::get_product_attributes( $this -> product['product_combinations'] );
?>
<script class="footer" type="text/javascript">
function fradio_label_click( element, refresh )
{
element.parents( '.fradio' ).siblings().children( 'label' ).removeClass( 'active' );
element.parents( '.fradio' ).siblings().children( 'input' ).removeAttr( 'checked' );
element.parents( '.fradio' ).children( 'label' ).addClass( 'active' );
element.parents( '.fradio' ).children( 'input' ).prop( "checked", true );
if ( refresh )
refresh_product_attributes( element.attr( 'for' ), element.attr( 'order' ) );
}
</script>
<div id="product">
<div class="row">
<div class="col-12 col-md-6">
<div id="image-big">
<? if ( $this -> product -> new_to_date and $this -> product -> new_to_date >= date( 'Y-m-d' ) ):?>
<div class="new"><?= \S::lang( 'nowosc' );?></div>
<? endif;?>
<? if ( file_exists( substr( $this -> product -> images[0]['src'], 1 ) ) ):?>
<a image-id="0">
<img src="/thumb/625/0<?= $this -> product -> images[0]['src'];?>" alt="">
</a>
<? else:?>
<? endif;?>
</div>
<div class="gallery">
<? for ( $i = 0; $i < count( $this -> product -> images ); $i++ ): if ( file_exists( substr( $this -> product -> images[$i]['src'], 1 ) ) ):?>
<a href="<?= $this -> product -> images[$i]['src'];?>" class="item" data-fancybox="product" id="image-<?= $i;?>" i="<?= $i;?>">
<img src="/thumb/180/0<?= $this -> product -> images[$i]['src'];?>" src="" alt="<?= $this -> product -> images[$i]['alt'];?>">
</a>
<? endif; endfor;?>
</div>
</div>
<div class="col-12 col-md-6">
<div class="product-options" id="product-options">
<?= \Tpl::view( 'shop-product/_partial/product-warehouse-message', [
'product' => $this -> product,
'lang_id' => $this -> lang_id,
'settings' => $this -> settings
] );?>
<h1><?= $this -> product -> language['name'];?></h1>
<div class="prices">
<? if ( $this -> product -> price_brutto_promo ):?>
<div class="price">
<?= \shop\Shop::shortPrice( $this -> product -> price_brutto_promo );?> <span class="small">zł</span>
</div>
<div class="price-old">
<?= \shop\Shop::shortPrice( $this -> product -> price_brutto );?> <span class="small">zł</span>
</div>
<div class="price-minimal">
Najniższa cena w ciągu ostatnich 30 dni: <strong><?= \shop\Shop::shortPrice( \front\factory\ShopProduct::get_minimal_price( $this -> product['id'], $this -> product -> price_brutto_promo ) );?> zł</strong>
</div>
<? if ( $this -> product -> weight && $this -> product -> product_unit_id ):?>
<div class="price_weight">
<?= \shop\Shop::shortPrice( $this -> product -> price_brutto_promo / $this -> product -> wegiht * 1 );?> <?= $this -> product -> product_unit;?>
</div>
<? endif;?>
<? else:?>
<div class="price">
<?= \shop\Shop::shortPrice( $this -> product -> price_brutto );?> <span class="small">zł</span>
</div>
<? if ( $this -> product -> weight && $this -> product -> product_unit_id ):?>
<div class="price_weight">
<?= \shop\Shop::shortPrice( $this -> product -> price_brutto / $this -> product -> weight );?> <span class="small">zł</span> / <?= \front\factory\Dictionaries::get_name_by_id( $this -> product -> product_unit_id, $this -> lang_id );?>
</div>
<? endif;?>
<? endif;?>
</div>
<form class="product-options" id="product-<?= $this -> product['id'];?>">
<input type="hidden" name="product-id" value="<?= $this -> product -> id;?>">
<? if ( \S::is_array_fix( $attributes ) ):?>
<div id="attributes">
<div class="title">Opcje produktu</div>
<? foreach ( $attributes as $key => $val )
echo \Tpl::view( 'shop-product/_partial/product-attribute', [
'attribute' => $val,
'order' => $key,
'level' => ++$level,
'max_level' => count( $attributes )
] );?>
</div>
<? endif;?>
<? if ( $this -> product['additional_message'] ):?>
<div class="product-message">
<textarea class="form-control" name="product-message" <? if ( $this -> product['additional_message_required'] ):?>required="required"<? endif;?> placeholder="<?= $this -> product['additional_message_text'] ? $this -> product['additional_message_text'] : 'Miejsce na dodatkową wiadomość';?>"></textarea>
</div>
<? endif;?>
<?= \Tpl::view( 'shop-product/_partial/product-custom-fields', [
'custom_fields' => $this -> product['custom_fields']
] );?>
<div class="add-to-basket">
<div class="quantity-container">
<a href="#" class="btn-minus">
<i class="fa fa-minus"></i>
</a>
<input type="text" name="quantity" id="quantity" value="1" class="int-format" min="1" max="<?= ( !$this -> product['quantity'] and $this -> product['stock_0_buy'] ) ? 999 : $this -> product['quantity'];?>">
<a href="#" class="btn-plus">
<i class="fa fa-plus"></i>
</a>
</div>
<button id="add-to-basket" class="btn btn-success"><?= \S::lang( 'do-koszyka' );?></span>
</button>
<div class="alert hidden">Produkt chwilowo niedostępny.</div>
<?
if ( !$this -> product['product_combinations'] and !( $this -> product['quantity'] > 0 or $this -> product['stock_0_buy'] ) ):
?>
<script class="footer" type="text/javascript">
$(function ()
{
$('#product-<?= $this -> product -> id;?> .add-to-basket .quantity-container, #product-<?= $this -> product -> id;?> .add-to-basket #add-to-basket').addClass('hidden');
$('#product-<?= $this -> product -> id;?> .add-to-basket .alert').removeClass('hidden');
});
</script>
<? endif;?>
</div>
</form>
<? if ( $this -> product['producer'] and $this -> product['producer']['status'] ):?>
<div class="product-producer">
Producent: <a href="/producent/<?= \S::seo( $this -> product['producer']['name'] );?>" title="Produkty marki <?= htmlspecialchars( $this -> product['producer']['name'] );?>"><?= $this -> product['producer']['name'];?></a>
</div>
<? endif;?>
<?= \Tpl::view( 'shop-product/_partial/product-meta', [
'product_id' => $this->product['id']
]);?>
<div class="short-description">
<?= $this -> product -> language['short_description'];?>
</div>
</div>
</div>
</div>
<div id="description">
<div class="row">
<div class="col-12 col-lg-8">
<ul class="tabs" id="tabs-menu">
<li class="tab-link current" id="tab-link-0" tab="0"><?= ucfirst( \S::lang( 'opis' ) );?></li>
<? if ( $this -> product -> language['tab_name_1'] ):?>
<li class="tab-link" id="tab-link-1" tab="1"><?= $this -> product -> language['tab_name_1'];?></li>
<? endif;?>
<li class="tab-link" id="tab-link-2" tab="2"><?= ucfirst( \S::lang( 'opinie' ) );?></li>
</ul>
<div id="tab-0" class="tab-content">
<div class="tab-title"><?= \S::lang( 'opis-produktu' );?></div>
<?= $this -> product -> language['description'];?>
</div>
<? if ( $this -> product -> language['tab_description_1'] ):?>
<div id="tab-1" class="tab-content">
<div class="tab-title"><?= $this -> product -> language['tab_name_1'];?></div>
<?= $this -> product -> language['tab_description_1'];?>
</div>
<? endif;?>
<div id="tab-2" class="tab-content reviews">
<div class="tab-title"><?= ucfirst( \S::lang( 'opinie' ) );?></div>
<div id="widget-container" class="data-ekomi-emp ekomi-widget-container ekomi-widget-sf14835961656364de9f9" ></div>
<div id="ekomi-product-widget-identifier" class="prod-data-emp" style="visibility: hidden"><?= $this -> product['id'];?></div>
<a href="https://www.ekomi-pl.com/opinie-marianek.html" target="_blank"><img alt="marianek.pl Reviews with ekomi-pl.com" src="https://smart-widget-assets.ekomiapps.de/resources/ekomi_logo.png" style="display: none;"/></a>
<script type="text/javascript">
function registerWidget (w, token) {
w['_ekomiWidgetsServerUrl'] = 'https://widgets.ekomi.com';
w['_customerId'] = 148359;
w['_language'] = new Array();
w['_language'][token] = 'auto';
if(typeof(w['_ekomiWidgetTokens']) !== 'undefined'){
w['_ekomiWidgetTokens'][w['_ekomiWidgetTokens'].length] = token;
} else {
w['_ekomiWidgetTokens'] = new Array(token);
}
if(typeof(ekomiWidgetJs) == 'undefined') {
ekomiWidgetJs = true;
var scr = document.createElement('script');scr.src = 'https://sw-assets.ekomiapps.de/static_resources/widget.js';
var head = document.getElementsByTagName('head')[0];head.appendChild(scr);
}
return true;
}
(function (w) {
var token = 'sf14835961656364de9f9';
var k = document.getElementsByClassName("ekomi-widget-" + token);
for(var x=0;x<k.length;x++){ registerWidget(w,token); }
})(window);
</script>
</div>
</div>
<div class="col-12 col-lg-4">
<? if ( $this -> product -> language['tab_name_2'] ):?>
<div class="description-right">
<div class="title"><?= $this -> product -> language['tab_name_2'];?></div>
<div class="content">
<?= $this -> product -> language['tab_description_2'];?>
</div>
</div>
<? endif;?>
</div>
</div>
</div>
<? if ( \S::is_array_fix( $this -> product['products_sets'] ) ):?>
<div class="products-sets box">
<div class="row">
<div class="col-12">
<div class="box-title"><?= ucfirst( \S::lang( 'dobierz-do-kompletu' ) );?></div>
<div class="owl-carousel owl-theme">
<?
foreach ( $this -> product['products_sets'] as $product_sets_id ):
$product = \shop\Product::getFromCache( $product_sets_id, $lang_id );
if ( $product and $product -> status ):
echo \Tpl::view( 'shop-product/product-mini', [
'product' => $product,
'class' => 'item'
] );
endif;
endforeach;
?>
</div>
</div>
</div>
</div>
<? endif;?>
<? if ( \S::is_array_fix( $this -> product['products_related'] ) ):?>
<div class="products-related box">
<div class="row">
<div class="col-12">
<div class="box-title">Inne wzory i kolory</div>
<div class="owl-carousel owl-theme">
<?
foreach ( $this -> product['products_related'] as $product_related_id ):
$product = \shop\Product::getFromCache( $product_related_id, $lang_id );
if ( $product and $product -> status ):
echo \Tpl::view( 'shop-product/product-mini', [
'product' => $product,
'class' => 'item'
] );
endif;
endforeach;
?>
</div>
</div>
</div>
</div>
<? endif;?>
<a href="javascript:history.go(-1)" class="btn btn-success history-back"><?= \S::lang( 'wstecz' );?></a>
</div>
<link class="footer" rel="stylesheet" type="text/css" href="/libraries/fancybox3/css/core.css">
<link class="footer" rel="stylesheet" type="text/css" href="/plugins/OwlCarousel/owl.carousel.css">
<link class="footer" rel="stylesheet" type="text/css" href="/plugins/OwlCarousel/owl.theme.default.css">
<script class="footer" type="text/javascript" src="/libraries/fancybox3/js/core.js"></script>
<script class="footer" type="text/javascript" src="/libraries/fancybox3/js/guestures.js"></script>
<script class="footer" type="text/javascript" src="/libraries/fancybox3/js/wheel.js"></script>
<script class="footer" type="text/javascript" src="/plugins/OwlCarousel/owl.carousel.js"></script>
<script type="text/javascript">
<? if ( $this -> settings['google_tag_manager_id'] ):?>
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: "view_item",
ecommerce: {
items: [
{
item_id: "<?= $this -> product -> id;?>",
item_name: "<?= str_replace( '"', '', $this -> product -> language['name'] );?>",
price: '<? if ( $this -> product -> price_brutto_promo ): echo \S::normalize_decimal( $this -> product -> price_brutto_promo ); else: echo \S::normalize_decimal( $this -> product -> price_brutto ); endif;?>',
quantity: 1
}
]
}
});
<? endif;?>
</script>
<script class="footer" type="text/javascript">
$( function ()
{
var fullUrl = window.location.href;
var hash = fullUrl.split('/')[4];
if ( hash ) {
// Podziel fragment na tablicę za pomocą znaku /
var array = hash.split('/');
// Sprawdź, czy tablica nie jest pusta
if (array.length > 0) {
// Przechodź przez tablicę elementów
array.forEach(function(element, index) {
// Ustaw opóźnienie na podstawie indeksu, aby kliknięcia były w odstępach półsekundowych
setTimeout(function() {
// Znajdź label z atrybutem for odpowiadającym aktualnemu elementowi tablicy i kliknij go
$("label[for='" + element + "']").click();
}, 100 * index); // 500 ms * indeks elementu
});
}
}
if ( windowsize > 767 )
{
$( "#tabs-menu" ).sticky({
topSpacing: 56
});
}
else
{
$( "#tabs-menu" ).sticky({
topSpacing: 0
});
};
if ( $( '#product #tab-0' ).visible() )
$( '#product #tabs-menu #tab-link-0' ).addClass( 'current' );
else
$( '#product #tabs-menu #tab-link-0' ).removeClass( 'current' );
if ( $( '#product #tab-1' ).visible() )
$( '#product #tabs-menu #tab-link-1' ).addClass( 'current' );
else
$( '#product #tabs-menu #tab-link-1' ).removeClass( 'current' );
if ( $( '#product #tab-2' ).visible() )
$( '#product #tabs-menu #tab-link-2' ).addClass( 'current' );
else
$( '#product #tabs-menu #tab-link-2' ).removeClass( 'current' );
$( 'body' ).on( click_event, '.fradio label', function()
{
fradio_label_click( $( this ), true );
});
$( 'body' ).on( click_event, '.tab-link', function()
{
$( 'html, body' ).animate({
scrollTop: $( "#tab-" + $( this ).attr( 'tab' ) ).offset().top - 120
}, 333 );
});
$('.products-sets .owl-carousel, .products-related .owl-carousel').owlCarousel({
loop: false,
responsiveClass: true,
dots: false,
lazyLoad: true,
responsive: {
0: {
items: 1,
nav: true
},
576: {
items: 2,
nav: true
},
768: {
items: 3,
nav: true
},
1280: {
items: 4,
nav: true
}
}
});
// powiększenie zdjęcia
$('body').on( click_event, '#image-big a', function ()
{
var image_id = $(this).attr('image-id');
$('#image-' + image_id).trigger('click');
});
$('body').on('mouseover', '#gallery a', function()
{
var i = $(this).attr('i');
var src = $(this).attr('href');
if (i != $('#image-big a').attr('image-id'))
{
$('#image-big a').attr('image-id', i);
$('#image-big img').attr('src', src);
}
});
$('body').on('change', '#quantity', function(e)
{
e.preventDefault();
var quantity = parseInt($('#quantity').val());
var max_value = parseInt($('input#quantity').attr('max'));
quantity = quantity + 1;
if (quantity > max_value)
{
quantity = max_value;
$.alert(
{
title: '<?= ucfirst( \S::lang( 'uwaga' ) );?>',
content: 'Maksymalna ilość wybranego produktu wynosi: <b>' + max_value + '<\/b>',
type: 'blue',
closeIcon: true,
closeIconClass: 'fas fa-times',
typeAnimated: true,
animation: 'opacity',
useBootstrap: false,
theme: 'modern',
autoClose: 'confirm|5000',
icon: 'fas fa-exclamation',
buttons: {
confirm: {
text: '<?= \S::lang( 'zamknij' );?>',
btnClass: 'btn-blue',
keys: ['enter'],
action: function () {}
}
}
});
}
$('input#quantity').val(quantity);
return false;
});
$( 'body').on( click_event, '.btn-plus', function (e)
{
e.preventDefault();
var quantity = parseInt($('#quantity').val());
var max_value = parseInt($('input#quantity').attr('max'));
quantity = quantity + 1;
if (quantity > max_value)
{
quantity = max_value;
$.alert(
{
title: '<?= ucfirst( \S::lang( 'uwaga' ) );?>',
content: 'Maksymalna ilość wybranego produktu wynosi: <b>' + max_value + '<\/b>',
type: 'blue',
closeIcon: true,
closeIconClass: 'fas fa-times',
typeAnimated: true,
animation: 'opacity',
useBootstrap: false,
theme: 'modern',
autoClose: 'confirm|5000',
icon: 'fas fa-exclamation',
buttons: {
confirm: {
text: '<?= \S::lang( 'zamknij' );?>',
btnClass: 'btn-blue',
keys: ['enter'],
action: function () {}
}
}
});
}
$('input#quantity').val(quantity);
return false;
});
$('body').on(click_event, '.btn-minus', function (e)
{
e.preventDefault();
var quantity = parseInt($('input#quantity').val());
var min_value = parseInt($('input#quantity').attr('min'));
quantity = quantity - 1;
if (quantity < min_value)
quantity = min_value;
$('input#quantity').val(quantity);
return false;
});
$('body').on(click_event, '#add-to-basket', function ()
{
var check = true;
$( '#attributes input[type="hidden"], #attributes select' ).each( function( index, element )
{
if ( $( element ).val() == '' )
{
var name = $( element ).attr( 'description' );
shopAlert(
'<?= ucfirst( \S::lang( 'uwaga' ) );?>',
'<?= ucfirst( \S::lang( 'prosze-wybrac' ) );?>: <b>' + name + '</b>',
[
'<a href="#" onclick="shopAlertClose(); return false;" class="btn btn-success">Zamknij</a>',
] );
check = false;
return false;
}
});
$( '#attributes .fradio-group' ).each( function( index, element )
{
var atrribute = $( element ).attr( 'attribute' );
var value = $( element ).find( 'input[type="radio"]:checked' ).val();
if ( typeof value === "undefined" )
{
var name = $( element ).attr( 'attribute-name' );
shopAlert(
'<?= ucfirst( \S::lang( 'uwaga' ) );?>',
'<?= ucfirst( \S::lang( 'prosze-wybrac' ) );?>: <b>' + name + '</b>',
[
'<a href="#" onclick="shopAlertClose(); return false;" class="btn btn-success">Zamknij</a>',
] );
check = false;
return false;
}
});
if ( $( '.product-message textarea' ).prop( 'required' ) && $.trim( $( '.product-message textarea' ).val() ) == '' )
{
shopAlert(
'<?= ucfirst( \S::lang( 'uwaga' ) );?>',
'Proszę uzupełnić pole na dodatkową wiadomość.',
[
'<a href="#" onclick="shopAlertClose(); return false;" class="btn btn-success">Zamknij</a>',
] );
check = false;
return false;
}
// dodatkowe pola muszą być uzupełnione
$( '.custom-field input' ).each( function( index, element )
{
if ( $.trim( $( element ).val() ) == '' )
{
shopAlert(
'<?= ucfirst( \S::lang( 'uwaga' ) );?>',
'Proszę uzupełnić pole: <b>' + $( element ).attr( 'field_name' ) + '</b>',
[
'<a href="#" onclick="shopAlertClose(); return false;" class="btn btn-success">Zamknij</a>',
] );
check = false;
return false;
}
});
if (!check)
return false;
var values = $( '#product-<?= $this -> product -> id;?>' ).serializeArray();
var quantity = $('#product-<?= $this -> product -> id;?> #quantity').val();
jQuery.ajax(
{
type: 'POST',
cache: false,
url: '/shopBasket/basket_add_product',
data:
{
values: JSON.stringify(values)
},
beforeSend: function()
{
$('#add-to-basket').addClass('disabled');
},
success: function( response )
{
data = jQuery.parseJSON(response);
$('#add-to-basket').removeClass('disabled');
$('#basket-mini #products-count').html(data.basket_mini_count);
$('#basket-mini #basket-value').html(data.basket_mini_value);
$('#product #quantity').val(1);
if (data.result == 'ok')
{
<? if ( $this -> settings['piksel'] ):?>
for (var i = 1; i <= quantity; i++)
{
fbq('track', 'AddToCart', {
content_name: '<?= str_replace( '"', '', $this -> product -> language['name'] );?>',
content_category: 'produkt',
content_ids: ['<?= $this -> product -> id;?>'],
content_type: 'product',
value: '<?
if ( $this -> product -> price_brutto_promo ):
echo \S::normalize_decimal( $this -> product -> price_brutto_promo );
else:
echo \S::normalize_decimal( $this -> product -> price_brutto );
endif;
?>',
currency: 'PLN'
});
}
<? endif;?>
<? if ( $this -> settings['google_tag_manager_id'] ):?>
var add_to_cart_value = <? if ( $this -> product -> price_brutto_promo ): echo \S::normalize_decimal( $this -> product -> price_brutto_promo ); else: echo \S::normalize_decimal( $this -> product -> price_brutto ); endif;?> * quantity;
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: "add_to_cart",
ecommerce: {
currency: "PLN",
value: add_to_cart_value,
items: [
{
item_id: "<?= $this -> product -> id;?>",
item_name: "<?= str_replace( '"', '', $this -> product -> language['name'] );?>",
price: <? if ( $this -> product -> price_brutto_promo ): echo \S::normalize_decimal( $this -> product -> price_brutto_promo ); else: echo \S::normalize_decimal( $this -> product -> price_brutto ); endif;?>,
quantity: quantity
}
]
}
});
<? endif;?>
shopAlert(
'Produkt dodany do koszyka',
data.product_sets,
[
'<a href="#" onclick="shopAlertClose(); return false;" class="btn btn-default">Wróć do zakupów</a>',
'<a href="/koszyk" class="btn btn-success">Przejdź do koszyka</a>'
] );
observer.observe();
}
}
});
return false;
});
});
// odświeżenie listy atrybutów produktu
function refresh_product_attributes( attribute_with_value, attribute_order )
{
// Wybierz wszystkie etykiety z klasą "active" wewnątrz elementu o ID "attributes"
const activeLabels = document.querySelectorAll('#attributes label.active');
// Utwórz tablicę z wartościami atrybutu "for" tych etykiet
const forValues = Array.from(activeLabels).map(label => label.getAttribute('for'));
$.ajax({
type: 'POST',
cache: false,
url: '/shopProduct/draw_product_attributes',
data: {
selected_values: forValues,
product_id: <?= $this -> product['id'];?>
},
beforeSend: function() {
$( '#add-to-basket' ).addClass('disabled');
},
success: function( response ) {
data = jQuery.parseJSON( response );
$( '#add-to-basket' ).removeClass( 'disabled' );
if ( data.product_data )
{
if ( data.product_data.price_brutto_promo )
{
$( '#product-options .prices .price-old' ).html( data.product_data.price_brutto + ' <span class="small">zł</span>' );
$( '#product-options .prices .price' ).html( data.product_data.price_brutto_promo + ' <span class="small">zł</span>' );
}
else
{
$( '#product-options .prices .price' ).html( data.product_data.price_brutto + ' <span class="small">zł</span>' );
}
// jeżeli stan magazynowy jest większy niż 0
if ( data.product_data.quantity > 0 )
{
$( '.warehouse-message' ).html( data.product_data.messages.warehouse_message_nonzero );
$( '#quantity' ).attr( 'max', data.product_data.quantity );
$( '.add-to-basket #add-to-basket, .add-to-basket .quantity-container' ).show();
$( '.add-to-basket .alert' ).addClass( 'hidden' );
}
// jeżeli stan magazynowy jest równy 0
else
{
// jeżeli można kupić produkt ze stanem magazynowym równym 0
if ( data.product_data.stock_0_buy == 1 )
{
$( '.warehouse-message' ).html( data.product_data.messages.warehouse_message_zero );
$( '#quantity' ).attr( 'max', 99 );
$( '.add-to-basket #add-to-basket, .add-to-basket .quantity-container' ).show();
$( '.add-to-basket .alert' ).addClass( 'hidden' );
}
// jeżeli nie można kupić produktu ze stanem magazynowym równym 0
else
{
$( '.warehouse-message' ).html( '' );
$( '#quantity' ).attr( 'max', 0 );
$( '.add-to-basket #add-to-basket, .add-to-basket .quantity-container' ).hide();
$( '.add-to-basket .alert' ).removeClass( 'hidden' );
}
}
}
}
});
return false;
}
</script>

View File

@@ -0,0 +1,68 @@
<? $hash = md5( time() . rand( 0, 9999999999 ) );?>
<div class="products-box-<?= $hash;?>">
<div class="swiper">
<div class="swiper-wrapper">
<?
foreach ( $this -> products as $product ):
if ( $product -> status ):
echo \Tpl::view( 'shop-product/product-mini', [
'product' => $product,
'class' => 'item',
'product_mini_class' => 'swiper-slide'
] );
endif;
endforeach;
?>
</div>
</div>
<div class="swiper-button-next products-box-<?= $hash;?>-next"></div>
<div class="swiper-button-prev products-box-<?= $hash;?>-prev"></div>
</div>
<script class="footer" type="text/javascript">
$( function()
{
if( $( ".products-box-<?= $hash;?> .swiper").length ) {
const swiper<?= $hash;?> = new Swiper(".products-box-<?= $hash;?> .swiper", {
slidesPerView: 6,
spaceBetween: 30,
initialSlide : 1,
centeredSlides: true,
lazy: true,
pagination: {
el: ".swiper-pagination",
clickable: true,
},
navigation: {
nextEl: ".products-box-<?= $hash;?>-next",
prevEl: ".products-box-<?= $hash;?>-prev",
},
breakpoints: {
1400: {
slidesPerView: 6,
},
1200: {
slidesPerView: 5,
},
991: {
slidesPerView: 4,
},
576: {
slidesPerView: 3,
},
300: {
slidesPerView: 2,
},
200: {
slidesPerView: 1,
}
},
on: {
slideChange: function() {
observer.observe();
}
}
});
}
});
</script>

View File

@@ -0,0 +1,18 @@
<? global $lang_id;?>
<div class="box-title"><?= ucfirst( \S::lang( 'polecane-produkty' ) );?></div>
<div class="content">
<? if ( is_array( $this -> products ) ): foreach ( $this -> products as $product_id ):?>
<?
$product = \shop\Product::getFromCache( $product_id, $lang_id );
$product -> languages[$lang_id]['seo_link'] ? $url = '/' . $product -> languages[$lang_id]['seo_link'] : $url = '/p-' . $product['id'] . '-' . \S::seo( $product -> languages[$lang_id]['name'] );
if ( \S::get_session( 'current-lang' ) != \front\factory\Languages::default_language() and $url != '#' )
$url = '/' . \S::get_session( 'current-lang' ) . $url;
?>
<?= \Tpl::view( 'shop-product/product-mini', [
'product' => $product,
'class' => 'col-12 col-sm-4 col-md-4 col-lg-3'
] );?>
<? endforeach; endif;?>
</div>