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,15 @@
<? if ( $this -> custom_fields ): foreach ( $this -> custom_fields as $key => $val ):?>
<? if ( $key ):?>
<div class="custom-field">
<div class="_name">
<?
$custom_field = \shop\ProductCustomField::getFromCache( $key );
echo $custom_field['name'] . ':';
?>
</div>
<div class="_text">
<?= $val;?>
</div>
</div>
<? endif;?>
<? endforeach; endif;?>

View File

@@ -0,0 +1,114 @@
<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 = new \shop\Product( (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>

View File

@@ -0,0 +1,430 @@
<div id="basket-container">
<div id="content">
<?= $this -> basket_details;?>
</div>
<? if ( is_array( $this -> basket ) and count( $this -> basket ) ):?>
<div class="basket-options">
<div class="content">
<div class="left">
<div class="box-title"><?= ucfirst( \S::lang( 'dostawa' ) );?>:</div>
<div id="transport-methods">
<?= $this -> transport_methods;?>
</div>
<div class="inpost-map-container">
<a href="#" onclick="inpost_check(); return false;" class="inpost-hide"><?= \S::lang( 'zamknij' );?></a>
<div id="inpost-map"></div>
</div>
</div>
<div class="right">
<div class="box-title"><?= ucfirst( \S::lang( 'platnosc' ) );?>:</div>
<div id="payment-methods"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<a href="/koszyk-podsumowanie" id="btn-basket-summary" class="btn btn-success disabled float-right"><span class="text"><?= ucfirst( \S::lang( 'przejdz-do-podsumowania' ) );?></span></a>
</div>
</div>
<? endif;?>
</div>
<link class="footer" rel="stylesheet" type="text/css" href="/libraries/grid/plugins/icheck/skins/square/_all.css">
<link class="footer" rel="stylesheet" type="text/css" href="https://geowidget.easypack24.net/css/easypack.css">
<script class="footer" type="text/javascript" src="/libraries/grid/plugins/icheck/icheck.min.js"></script>
<script class="footer" type="text/javascript" src="https://geowidget.easypack24.net/js/sdk-for-javascript.js"></script>
<script class="footer" type="text/javascript">
var inpost_transport_method_id = '';
function inpost_check() {
$.ajax({
type: 'POST',
cache: false,
url: '/shopBasket/inpost_check',
beforeSend: function() {
},
success: function( response ) {
data = jQuery.parseJSON( response );
if ( data.result == 'bad' ) {
$( '.inpost-info-' + inpost_transport_method_id ).html( '<a href="#" onclick="inpost_map( ' + inpost_transport_method_id + ' ); return false;">wybierz</a>' );
}
$( '.inpost-map-container' ).hide();
}
});
return false;
}
function payment_checked( payment_method_id )
{
$.ajax(
{
type: 'POST',
cache: false,
url: '/shopBasket/basket_payment_method_set',
data:
{
payment_method_id: payment_method_id
},
beforeSend: function()
{
$( '#basket-container *' ).addClass( 'disabled' );
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'disable' );
},
success: function( response )
{
response = jQuery.parseJSON( response );
$( '#basket-container *' ).removeClass( 'disabled' );
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'enable' );
$( '#btn-basket-summary' ).removeClass( 'disabled' );
}
});
return false;
}
function inpost_map( transport_method_id )
{
inpost_transport_method_id = transport_method_id;
window.easyPackAsyncInit = function () {
easyPack.init({
mapType: 'osm',
searchType: 'osm',
});
var map = easyPack.mapWidget( 'inpost-map', function(point)
{
$.ajax(
{
type: 'POST',
cache: false,
url: '/shopBasket/inpost_save',
data: {
paczkomat: point.name + ' | ' + point.address.line1 + ', ' + point.address.line2
},
beforeSend: function() {},
success: function( response ) {
$( '.inpost-info-' + transport_method_id ).html( point.name + ' | ' + point.address.line1 + ', ' + point.address.line2 + '<a href="#" onclick="inpost_map( ' + transport_method_id + ' ); return false;">zmień</a>' );
$( '.inpost-map-container' ).hide();
}
});
});
};
$( '.inpost-map-container' ).show();
}
function transport_checked( transport_method_id, payment_method_id, event_click )
{
$.ajax({
type: 'POST',
cache: false,
url: '/shopBasket/basket_payments_methods',
data:
{
payment_method_id: payment_method_id,
transport_method_id: transport_method_id
},
beforeSend: function()
{
$( '#basket-container *' ).addClass( 'disabled' );
$( '#transport-methods .icheck, #transport-methods .icheck' ).iCheck( 'disable' );
},
success: function( response )
{
response = jQuery.parseJSON( response );
$( '#basket-container *' ).removeClass( 'disabled' );
$( '#transport-methods .icheck, #transport-methods .icheck' ).iCheck( 'enable' );
$( '#payment-methods' ).html( response.payment_methods );
$( '#payment-methods .icheck' ).iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue'
});
if ( payment_method_id )
$( '#btn-basket-summary' ).removeClass( 'disabled' );
$( '#payment-methods .icheck' ).on( 'ifChecked', function( event )
{
var payment_method_id = $( this ).val();
payment_checked( payment_method_id );
});
if ( event_click && ( transport_method_id == '1' || transport_method_id == '2' ) )
inpost_map( transport_method_id )
}
});
return false;
}
$( function()
{
$( 'body' ).on( 'change', '#basket .basket-product-message textarea', function()
{
var _this = $( this);
$.ajax({
type: 'POST',
cache: false,
url: '/shopBasket/product_message_change',
data: {
product_message: _this.val(),
position_code: _this.attr( 'position' )
},
beforeSend: function() {},
success: function() {}
});
});
$( 'body' ).on( click_event, '#btn-basket-summary', function(e) {
e.preventDefault();
$.ajax({
type: 'POST',
cache: false,
url: '/shopBasket/transport_method_inpost_check',
data: {},
beforeSend: function() {
$( '#basket-container *' ).addClass( 'disabled' );
},
success: function( response ) {
data = jQuery.parseJSON( response );
$( '#basket-container *' ).removeClass( 'disabled' );
if ( data.result === 'bad' ) {
$.alert({
title: '<?= ucfirst( \S::lang( 'uwaga' ) );?>',
content: 'Proszę wybrać paczkomat.',
type: 'blue',
closeIcon: true,
closeIconClass: 'fa fa-times',
typeAnimated: true,
animation: 'opacity',
useBootstrap: false,
theme: 'modern',
autoClose: 'confirm|5000',
icon: 'fa fa-exclamation',
buttons: {
confirm: {
text: '<?= \S::lang( 'zamknij' );?>',
btnClass: 'btn-blue',
keys: ['enter'],
action: function () {}
}
}
});
} else {
document.location.href = '/koszyk-podsumowanie';
}
}
});
});
$( 'body' ).on( 'change', '#basket-message', function()
{
var _this = $( this);
$.ajax({
type: 'POST',
cache: false,
url: '/shopBasket/basket_message_save',
data: {
basket_message: _this.val()
},
beforeSend: function() {
$( '#basket-container *' ).addClass( 'disabled' );
},
success: function( response ) {
data = jQuery.parseJSON( response );
$( '#basket-container *' ).removeClass( 'disabled' );
}
});
});
$( 'body' ).on( 'change', '.basket-product .int-format', function()
{
var product_hash = $( this ).attr( 'product-hash' );
var quantity = $( this ).val();
$.ajax(
{
type: 'POST',
cache: false,
url: '/shopBasket/basket_change_quantity_product',
data:
{
product_hash: product_hash,
quantity: quantity
},
beforeSend: function()
{
$( '#basket-container *' ).addClass( 'disabled' );
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'disable' );
},
success: function( response )
{
data = jQuery.parseJSON( response );
if ( data.products_count === 0 )
{
document.location.href = '/koszyk';
$( '.mini-box' ).hide();
return false;
}
$( '#basket-container *' ).removeClass( 'disabled' );
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'enable' );
$( '#basket-container #content' ).html( data.basket );
$( '#basket-mini #products-count' ).html( data.basket_mini_count );
$( '#basket-mini #basket-value').html( data.basket_mini_value );
$( '#basket-container #transport-methods' ).html( data.transport_methods );
}
});
return false;
});
$( 'body' ).on( click_event, '.basket-product .btn-minus', function() {
var product_hash = $( this ).attr( 'product-hash' );
$.ajax({
type: 'POST',
cache: false,
url: '/shopBasket/basket_decrease_quantity_product',
data: {
product_hash: product_hash
},
beforeSend: function() {
$( '#basket-container *' ).addClass( 'disabled' );
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'disable' );
},
success: function( response ) {
data = jQuery.parseJSON( response );
if ( data.products_count === 0 ) {
document.location.href = '/koszyk';
$( '.mini-box' ).hide();
return false;
}
$( '#basket-container *' ).removeClass( 'disabled' );
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'enable' );
$( '#basket-container #content' ).html( data.basket );
$( '#basket-mini #products-count' ).html( data.basket_mini_count );
$( '#basket-mini #basket-value').html( data.basket_mini_value );
$( '#basket-container #transport-methods' ).html( data.transport_methods );
}
});
return false;
});
$( 'body' ).on( click_event, '.basket-product .btn-plus', function()
{
var product_hash = $( this ).attr( 'product-hash' );
$.ajax(
{
type: 'POST',
cache: false,
url: '/shopBasket/basket_increase_quantity_product',
data: {
product_hash: product_hash
},
beforeSend: function() {
$( '#basket-container *' ).addClass( 'disabled' );
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'disable' );
},
success: function( response ) {
data = jQuery.parseJSON( response );
if ( data.products_count === 0 )
{
document.location.href = '/koszyk';
$( '.mini-box' ).hide();
return false;
}
$( '#basket-container *' ).removeClass( 'disabled' );
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'enable' );
$( '#basket-container #content' ).html( data.basket );
$( '#basket-mini #products-count' ).html( data.basket_mini_count );
$( '#basket-mini #basket-value').html( data.basket_mini_value );
$( '#basket-container #transport-methods' ).html( data.transport_methods );
}
});
return false;
});
$( 'body' ).on( click_event, '.basket-product .btn-delete', function()
{
var product_hash = $( this ).attr( 'product-hash' );
$.alert({
title: '<?= ucfirst( \S::lang( 'potwierdz' ) );?>',
content: '<?= \S::lang( 'potwierdz-usuniecie-produktu-z-koszyka' );?>',
closeIcon: true,
closeIconClass: 'fas fa-close',
typeAnimated: true,
animation: 'opacity',
useBootstrap: false,
theme: 'modern',
autoClose: 'cancel|10000',
buttons: {
confirm: {
text: '<?= \S::lang( 'usun' );?>',
btnClass: 'btn-orange',
keys: ['enter'],
action: function() {
$.ajax({
type: 'POST',
cache: false,
url: '/shopBasket/basket_remove_product',
data: {
product_hash: product_hash
},
beforeSend: function() {
$( '#basket-container *' ).addClass( 'disabled' );
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'disable' );
},
success: function( response )
{
data = jQuery.parseJSON( response );
if ( data.products_count === 0 )
{
document.location.href = '/koszyk';
$( '.mini-box' ).hide();
return false;
}
$( '#basket-container *' ).removeClass( 'disabled' );
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'enable' );
$( '#basket-container #content' ).html( data.basket );
$( '#basket-mini #products-count' ).html( data.basket_mini_count );
$( '#basket-mini #basket-value').html( data.basket_mini_value );
$( '#basket-container #transport-methods' ).html( data.transport_methods );
}
});
}
},
cancel: {
text: '<?= \S::lang( 'zamknij' );?>',
btnClass: 'btn-blue',
action: function() {}
}
}
});
return false;
});
});
</script>

View File

@@ -0,0 +1,175 @@
<? global $client, $lang_id;?>
<div class="basket-summary-container box">
<h1 class="box-title"><?= ucfirst( \S::lang( 'podsumowanie-zamowienia' ) );?>:</h1>
<div id="basket-summary" class="content">
<? if ( is_array( $this -> basket ) and count( $this -> basket ) ):?>
<? foreach ( $this -> basket as $position_hash => $position ):?>
<? $product = new \shop\Product( $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">
<?
$product[ 'language' ][ 'seo_link' ] ? $url = '/' . $product[ 'language' ][ 'seo_link' ] : $url = '/p-' . $product[ 'id' ] . '-' . \S::seo( $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="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 '<span>' . $attribute['language']['name'] . ':</span> ';
$value = \front\factory\ShopAttribute::value_details($row[1], $this->lang_id);
echo $value['language']['name'];
}
?>
</div>
<? endforeach; ?>
<hr>
<? endif;?>
<?= \Tpl::view( 'shop-basket/_partials/product-custom-fields', [
'custom_fields' => $position['custom_fields']
] ); ?>
<div class="product-message">
<?= $position['message'] != '' ? '<strong>Wiadomość:</strong> ' . $position['message'] : '';?>
</div>
</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']);
?>
<span>x <?= $position[ 'quantity' ];?> <?= \S::lang( 'szt' );?>.</span>
<?= \S::decimal( \S::normalize_decimal( $price_product['price_new'] * $position[ 'quantity' ] ) );?> zł
</div>
</div>
</div>
<? $summary += \S::normalize_decimal( $price_product['price'] * $position[ 'quantity' ] );?>
<?
if ( $begin_checkout_items )
$begin_checkout_items .= ',';
$begin_checkout_items .= '{';
$begin_checkout_items .= '"id": "' . $product['id'] . '",';
$begin_checkout_items .= '"name": "' . $product['language']['name'] . '",';
$begin_checkout_items .= '"price": ' . \S::normalize_decimal( $price_product['price_new'] ) . ',';
$begin_checkout_items .= '"quantity": ' . $position['quantity'];
$begin_checkout_items .= '}';
?>
<? endforeach;?>
<div class="hr"></div>
<div class="basket-summary">
Wartość koszyka:
<span>
<?= \S::decimal( $summary );?> zł
</span>
</div>
<? if ( $discount ):?>
<div class="basket-summary">
Rabat:
<span class="text-danger">-<?= \S::decimal( $discount ); ?> zł</span>
</div>
<? endif;?>
<div class="basket-summary">
<?= $this -> transport[ 'name_visible' ];?>:
<span>
<?= $summary >= $this -> settings[ 'free_delivery' ] ? '0,00' : \S::decimal( $this -> transport[ 'cost' ] );?> zł
</span>
</div>
<div class="basket-summary big">
Razem:
<?
if ( $discount )
$summary -= $discount;
?>
<span id="order-summary"><?= $summary >= $this -> settings[ 'free_delivery' ] ? \S::decimal( $summary ) : \S::decimal( $summary + $this -> transport[ 'cost' ] );?> zł</span>
</div>
<div class="basket-summary">
<?= $this -> payment_method[ 'name' ];?>
</div>
<? if ( $this -> basket_message ):?>
<div class="basket-summary">
Wiadomość:
<span><?= $this -> basket_message;?></span>
</div>
<? endif;?>
<div class="hr"></div>
<? else:?>
<div class="alert alert-danger">Brak produktów w koszyku</div>
<? endif;?>
</div>
<? if ( is_array( $this -> basket ) and count( $this -> basket ) ):?>
<div class="basket-options">
<div class="content">
<? if ( !$this -> client ):?>
<div class="left">
<?=
\front\view\ShopClient::login_form( [
'long' => true
] );
?>
</div>
<div class="right">
<?= \Tpl::view( 'shop-basket/address-form', [
'transport_method' => $this -> transport
] );?>
</div>
<? else:?>
<?= \Tpl::view( 'shop-basket/address-form', [
'client' => $this -> client,
'addresses' => $this -> addresses,
'transport_method' => $this -> transport
] );?>
<? endif;?>
</div>
<a href="/koszyk" class="btn btn-dark"><?= \S::lang( 'wroc-do-koszyka' );?></span></a>
</div>
<? endif;?>
</div>
<script class="footer" type="text/javascript">
document.getElementById('order-send').addEventListener('click', function() {
var form = document.getElementById('form-order'); // Zastąp 'form-id' rzeczywistym ID Twojego formularza
if (form.checkValidity()) {
this.classList.add('loading-button');
this.disabled = true;
form.submit();
} else {
// Opcjonalnie: wywołaj funkcję reportValidity(), aby wyświetlić komunikaty o błędach formularza
form.reportValidity();
}
});
<? if ( $this -> settings['google_tag_manager_id'] ):?>
dataLayer.push({
event: "begin_checkout",
ecommerce: {
currency: "PLN",
value: <?= \S::normalize_decimal( \front\factory\ShopBasket::summary_price( $this -> basket, $this -> coupon ) );?>,
items: [
<?= $begin_checkout_items;?>
]
}
});
<? endif;?>
</script>