Dodaj obsługę punktów Orlen w zamówieniach oraz popraw styl i logikę w szablonach
This commit is contained in:
@@ -76,6 +76,9 @@
|
||||
$min = (int) $this -> sales_grid[$j][$i];
|
||||
}
|
||||
}
|
||||
|
||||
if ( $max == 0 )
|
||||
$max = 1;
|
||||
?>
|
||||
<div class="table-responsive">
|
||||
<table class="sales-grid table">
|
||||
|
||||
@@ -131,13 +131,12 @@ ob_start();
|
||||
'id' => 'free_delivery',
|
||||
'value' => $this -> settings['free_delivery']
|
||||
] );?>
|
||||
<?= \Html::textarea( [
|
||||
'label' => 'Ankieta Ekomi',
|
||||
'name' => 'ekomi_survey',
|
||||
'id' => 'ekomi_survey',
|
||||
'value' => $this -> settings['ekomi_survey'],
|
||||
'rows' => 10
|
||||
] );?>
|
||||
<?= \Html::input( [
|
||||
'label' => 'Orlen Paczka map token',
|
||||
'name' => 'orlen_paczka_map_token',
|
||||
'id' => 'orlen_paczka_map_token',
|
||||
'value' => $this -> settings['orlen_paczka_map_token']
|
||||
] );?>
|
||||
</div>
|
||||
<div>
|
||||
<div id="languages-main">
|
||||
|
||||
@@ -42,6 +42,10 @@ ob_start();
|
||||
<? $paczkomat = explode( '|', $this -> order[ 'inpost_paczkomat' ] );?>
|
||||
<div>Paczkomat: <b id="order-paczkomat"><?= $paczkomat[0];?></b> | <?= $paczkomat[1];?> <i class="fa fa-copy" onclick="copyToClipboard( 'order-paczkomat' ); return false;"></i></div>
|
||||
<? endif;?>
|
||||
<? if ( $this -> order['transport_id'] == 9 and $this -> order[ 'orlen_point' ] ):?>
|
||||
<? $orlen = explode( '|', $this -> order[ 'orlen_point' ] );?>
|
||||
<div>Punkt Orlen: <b id="order-orlen"><?= $orlen[0];?></b> | <?= $orlen[1];?> <i class="fa fa-copy" onclick="copyToClipboard( 'order-orlen' ); return false;"></i></div>
|
||||
<? endif;?>
|
||||
<br/>
|
||||
<div>
|
||||
<b><?= $this -> order[ 'payment_method' ];?> </b>
|
||||
|
||||
@@ -29,7 +29,7 @@ class Settings
|
||||
\admin\factory\Settings::settings_update( 'piksel', $values['piksel'] );
|
||||
\admin\factory\Settings::settings_update( 'generate_webp', $values['generate_webp'] == 'on' ? 1 : 0 );
|
||||
\admin\factory\Settings::settings_update( 'lazy_loading', $values['lazy_loading'] == 'on' ? 1 : 0 );
|
||||
\admin\factory\Settings::settings_update( 'ekomi_survey', $values['ekomi_survey'] );
|
||||
\admin\factory\Settings::settings_update( 'orlen_paczka_map_token', $values['orlen_paczka_map_token'] );
|
||||
\admin\factory\Settings::settings_update( 'google_tag_manager_id', $values['google_tag_manager_id'] );
|
||||
\admin\factory\Settings::settings_update( 'infinitescroll', $values['infinitescroll'] == 'on' ? 1 : 0 );
|
||||
// own_gtm_js
|
||||
|
||||
@@ -190,7 +190,6 @@ class ShopCategory
|
||||
foreach ( $title as $key => $val )
|
||||
{
|
||||
if ( $translation_id = $mdb -> get( 'pp_shop_categories_langs', 'id', [ 'AND' => [ 'category_id' => $category_id, 'lang_id' => $key ] ] ) )
|
||||
{
|
||||
$mdb -> update( 'pp_shop_categories_langs', [
|
||||
'lang_id' => $key,
|
||||
'title' => $title[$key] != '' ? $title[$key] : null,
|
||||
@@ -206,7 +205,6 @@ class ShopCategory
|
||||
], [
|
||||
'id' => $translation_id
|
||||
] );
|
||||
}
|
||||
else
|
||||
$mdb -> insert( 'pp_shop_categories_langs', [
|
||||
'category_id' => (int)$category_id,
|
||||
|
||||
@@ -4,7 +4,7 @@ class ShopTransport
|
||||
{
|
||||
public static function lowest_transport_price( $wp ) {
|
||||
global $mdb;
|
||||
return $mdb -> get( 'pp_shop_transports', 'cost', [ 'AND' => [ 'status' => 1, 'id' => [ 2, 4, 6, 8 ], 'max_wp[>=]' => $wp ], 'ORDER' => [ 'cost' => 'ASC' ] ] );
|
||||
return $mdb -> get( 'pp_shop_transports', 'cost', [ 'AND' => [ 'status' => 1, 'id' => [ 2, 4, 6, 8, 9 ], 'max_wp[>=]' => $wp ], 'ORDER' => [ 'cost' => 'ASC' ] ] );
|
||||
}
|
||||
|
||||
public static function transport_save( $transport_id, $name, $name_visible, $description, $status, $cost, $payment_methods, $max_wp, $default, $apilo_carrier_account_id, $sellasist_shipment_method_id, $delivery_free )
|
||||
|
||||
@@ -1,30 +1,53 @@
|
||||
<?
|
||||
class RedisConnection {
|
||||
<?php
|
||||
class RedisConnection
|
||||
{
|
||||
private static $instance = null;
|
||||
private $redis;
|
||||
|
||||
private function __construct() {
|
||||
private function __construct()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$this -> redis = new \Redis();
|
||||
if ( !$this -> redis -> connect( $config['redis']['host'], $config['redis']['port'] ) ) {
|
||||
throw new Exception("Nie udało się połączyć z serwerem Redis.");
|
||||
$this->redis = new \Redis();
|
||||
|
||||
try
|
||||
{
|
||||
// Próba połączenia z serwerem Redis
|
||||
if (!$this->redis->connect($config['redis']['host'], $config['redis']['port']))
|
||||
{
|
||||
// Logowanie błędu bez rzucania wyjątku
|
||||
error_log("Nie udało się połączyć z serwerem Redis.");
|
||||
$this->redis = null;
|
||||
return;
|
||||
}
|
||||
|
||||
// Autentykacja za pomocą hasła
|
||||
if ( !$this -> redis -> auth( $config['redis']['password'] ) ) {
|
||||
|
||||
// Próba autoryzacji
|
||||
if (!$this->redis->auth($config['redis']['password']))
|
||||
{
|
||||
error_log("Autoryzacja do serwera Redis nie powiodła się.");
|
||||
$this->redis = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
// Obsługa wyjątków, bez rzucania błędu
|
||||
error_log("Błąd podczas połączenia z Redis: " . $e->getMessage());
|
||||
$this->redis = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getInstance() {
|
||||
if ( self::$instance === null ) {
|
||||
public static function getInstance()
|
||||
{
|
||||
if (self::$instance === null)
|
||||
{
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function getConnection() {
|
||||
public function getConnection()
|
||||
{
|
||||
return $this->redis;
|
||||
}
|
||||
}
|
||||
@@ -394,9 +394,15 @@ class S
|
||||
if ( $version = \S::get_session( 'new-version' ) )
|
||||
return $version;
|
||||
|
||||
$version = 0;
|
||||
$versions = file_get_contents( 'http://www.shoppro.project-dc.pl/updates/versions.php?key=' . $settings['update_key'] );
|
||||
$versions = explode( PHP_EOL, $versions );
|
||||
$version = (float)max( $versions );
|
||||
foreach ( $versions as $key => $version_tmp )
|
||||
{
|
||||
$version_tmp = floatval( $version_tmp );
|
||||
if ( $version_tmp > $version and $version_tmp )
|
||||
$version = $version_tmp;
|
||||
}
|
||||
|
||||
\S::set_session( 'new-version', $version );
|
||||
|
||||
|
||||
@@ -245,6 +245,18 @@ class ShopBasket
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if ( \S::get_session( 'basket-transport-method-id' ) === '9' )
|
||||
{
|
||||
if ( !\S::get_session( 'basket_orlen_point_id' ) )
|
||||
{
|
||||
echo json_encode( [
|
||||
'result' => 'bad'
|
||||
] );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode( [
|
||||
'result' => 'ok'
|
||||
] );
|
||||
@@ -264,6 +276,16 @@ class ShopBasket
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function orlen_save()
|
||||
{
|
||||
\S::set_session( 'basket_orlen_point_id', \S::get( 'orlen_point_id' ) );
|
||||
\S::set_session( 'basket_orlen_point_info', \S::get( 'orlen_point_name' ) );
|
||||
echo json_encode( [
|
||||
'result' => 'ok'
|
||||
] );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function inpost_save()
|
||||
{
|
||||
\S::set_session( 'basket-inpost-info', \S::get( 'paczkomat' ) );
|
||||
@@ -343,9 +365,23 @@ class ShopBasket
|
||||
}
|
||||
|
||||
if ( $order_id = \front\factory\ShopOrder::basket_save(
|
||||
$client[ 'id' ], \S::get_session( 'basket' ), \S::get_session( 'basket-transport-method-id' ), \S::get_session( 'basket-payment-method-id' ),
|
||||
\S::get( 'email', true ), \S::get( 'phone', true ), \S::get( 'name', true ), \S::get( 'surname', true ), \S::get( 'firm', true ), \S::get( 'street' ), \S::get( 'postal_code', true ), \S::get( 'city', true ),
|
||||
\S::get_session( 'basket-inpost-info' ), \S::get_session( 'coupon' ), \S::get_session( 'basket_message' )
|
||||
$client[ 'id' ],
|
||||
\S::get_session( 'basket' ),
|
||||
\S::get_session( 'basket-transport-method-id' ),
|
||||
\S::get_session( 'basket-payment-method-id' ),
|
||||
\S::get( 'email', true ),
|
||||
\S::get( 'phone', true ),
|
||||
\S::get( 'name', true ),
|
||||
\S::get( 'surname', true ),
|
||||
\S::get( 'firm', true ),
|
||||
\S::get( 'street' ),
|
||||
\S::get( 'postal_code', true ),
|
||||
\S::get( 'city', true ),
|
||||
\S::get_session( 'basket-inpost-info' ),
|
||||
\S::get_session( 'basket_orlen_point_id' ),
|
||||
\S::get_session( 'basket_orlen_point_info' ),
|
||||
\S::get_session( 'coupon' ),
|
||||
\S::get_session( 'basket_message' )
|
||||
) )
|
||||
{
|
||||
\S::alert( \S::lang( 'zamowienie-zostalo-zlozone-komunikat' ) );
|
||||
@@ -353,6 +389,8 @@ class ShopBasket
|
||||
\S::delete_session( 'basket-transport-method-id' );
|
||||
\S::delete_session( 'basket-payment-method-id' );
|
||||
\S::delete_session( 'basket-inpost-info' );
|
||||
\S::delete_session( 'basket_orlen_point_id' );
|
||||
\S::delete_session( 'basket_orlen_point_info' );
|
||||
\S::delete_session( 'coupon' );
|
||||
\S::delete_session( 'basket_message' );
|
||||
|
||||
@@ -362,7 +400,8 @@ class ShopBasket
|
||||
\S::set_session( 'ekomi-purchase', true );
|
||||
|
||||
$redis = \RedisConnection::getInstance() -> getConnection();
|
||||
$redis -> flushAll();
|
||||
if ( $redis )
|
||||
$redis -> flushAll();
|
||||
|
||||
header( 'Location: /zamowienie/' . \front\factory\ShopOrder::order_hash( $order_id ) );
|
||||
exit;
|
||||
|
||||
@@ -64,7 +64,24 @@ class ShopOrder
|
||||
return date( 'Y/m', strtotime( $date ) ) . '/' . $nr;
|
||||
}
|
||||
|
||||
public static function basket_save( $client_id, $basket, $transport_id, $payment_id, $email, $phone, $name, $surname, $firm, $street, $postal_code, $city, $inpost_info, $coupon, $basket_message )
|
||||
public static function basket_save(
|
||||
$client_id,
|
||||
$basket,
|
||||
$transport_id,
|
||||
$payment_id,
|
||||
$email,
|
||||
$phone,
|
||||
$name,
|
||||
$surname,
|
||||
$firm,
|
||||
$street,
|
||||
$postal_code,
|
||||
$city,
|
||||
$inpost_info,
|
||||
$orlen_point_id,
|
||||
$orlen_point_info,
|
||||
$coupon,
|
||||
$basket_message )
|
||||
{
|
||||
global $mdb, $lang_id, $settings;
|
||||
|
||||
@@ -103,6 +120,7 @@ class ShopOrder
|
||||
'transport' => $transport[ 'name_visible' ],
|
||||
'transport_cost' => $transport_cost,
|
||||
'transport_description' => $transport[ 'description' ],
|
||||
'orlen_point' => ( $orlen_point_id ) ? $orlen_point_id . ' | ' . $orlen_point_info : null,
|
||||
'inpost_paczkomat' => ( $transport_id == 1 or $transport_id == 2 ) ? $inpost_info : null,
|
||||
'payment_method' => $payment_method[ 'name' ],
|
||||
'payment_method_id' => $payment_id,
|
||||
|
||||
@@ -10,15 +10,22 @@ class Dashboard implements \ArrayAccess
|
||||
try
|
||||
{
|
||||
$redis = \RedisConnection::getInstance() -> getConnection();
|
||||
$objectData = $redis -> get( "summary_ordersd" );
|
||||
|
||||
if ( !$objectData )
|
||||
if ( $redis )
|
||||
{
|
||||
$summary = $mdb -> count( 'pp_shop_orders', [ 'status' => 6 ] );
|
||||
$redis -> setex( "summary_ordersd", 60 * 5, serialize( $summary ) );
|
||||
$objectData = $redis -> get( "summary_ordersd" );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$summary = $mdb -> count( 'pp_shop_orders', [ 'status' => 6 ] );
|
||||
$redis -> setex( "summary_ordersd", 60 * 5, serialize( $summary ) );
|
||||
}
|
||||
else
|
||||
$summary = unserialize( $objectData );
|
||||
}
|
||||
else
|
||||
$summary = unserialize( $objectData );
|
||||
{
|
||||
$summary = $mdb -> count( 'pp_shop_orders', [ 'status' => 6 ] );
|
||||
}
|
||||
}
|
||||
catch ( \RedisException $e )
|
||||
{
|
||||
@@ -35,15 +42,22 @@ class Dashboard implements \ArrayAccess
|
||||
try
|
||||
{
|
||||
$redis = \RedisConnection::getInstance() -> getConnection();
|
||||
$objectData = $redis -> get( "summary_salesd" );
|
||||
|
||||
if ( !$objectData )
|
||||
if ( $redis )
|
||||
{
|
||||
$summary = $mdb -> sum( 'pp_shop_orders', 'summary', [ 'status' => 6 ] ) - $mdb -> sum( 'pp_shop_orders', 'transport_cost', [ 'status' => 6 ] );
|
||||
$redis -> setex( "summary_salesd", 60 * 5, serialize( $summary ) );
|
||||
$objectData = $redis -> get( "summary_salesd" );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$summary = $mdb -> sum( 'pp_shop_orders', 'summary', [ 'status' => 6 ] ) - $mdb -> sum( 'pp_shop_orders', 'transport_cost', [ 'status' => 6 ] );
|
||||
$redis -> setex( "summary_salesd", 60 * 5, serialize( $summary ) );
|
||||
}
|
||||
else
|
||||
$summary = unserialize( $objectData );
|
||||
}
|
||||
else
|
||||
$summary = unserialize( $objectData );
|
||||
{
|
||||
$summary = $mdb -> sum( 'pp_shop_orders', 'summary', [ 'status' => 6 ] ) - $mdb -> sum( 'pp_shop_orders', 'transport_cost', [ 'status' => 6 ] );
|
||||
}
|
||||
}
|
||||
catch ( \RedisException $e )
|
||||
{
|
||||
|
||||
@@ -112,41 +112,50 @@ class Product implements \ArrayAccess
|
||||
* @param string $permutation_hash The permutation hash of the product.
|
||||
* @return \shop\Product The product object.
|
||||
*/
|
||||
public static function getFromCache( $product_id, $lang_id, $permutation_hash = null )
|
||||
public static function getFromCache($product_id, $lang_id, $permutation_hash = null)
|
||||
{
|
||||
// Check if Redis extension is loaded
|
||||
if ( class_exists( 'Redis' ) )
|
||||
if (class_exists('Redis'))
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get the Redis connection instance
|
||||
$redis = \RedisConnection::getInstance() -> getConnection();
|
||||
$redis = \RedisConnection::getInstance()->getConnection();
|
||||
|
||||
// Try to retrieve the serialized product object from cache
|
||||
$objectData = $redis -> get( "shop\product:$product_id:$lang_id:$permutation_hash" );
|
||||
|
||||
if ( !$objectData )
|
||||
// Check if Redis connection is valid
|
||||
if ( $redis )
|
||||
{
|
||||
// Product not found in cache, create a new instance and store it in cache
|
||||
$object = new self( $product_id, $lang_id, $permutation_hash );
|
||||
$redis->setex( "shop\product:$product_id:$lang_id:$permutation_hash", 60 * 60 * 24, serialize( $object ) );
|
||||
// Try to retrieve the serialized product object from cache
|
||||
$objectData = $redis->get("shop\product:$product_id:$lang_id:$permutation_hash");
|
||||
|
||||
if (!$objectData)
|
||||
{
|
||||
// Product not found in cache, create a new instance and store it in cache
|
||||
$object = new self($product_id, $lang_id, $permutation_hash);
|
||||
$redis->setex("shop\product:$product_id:$lang_id:$permutation_hash", 60 * 60 * 24, serialize($object));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Product found in cache, unserialize it
|
||||
$object = unserialize($objectData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Product found in cache, unserialize it
|
||||
$object = unserialize( $objectData );
|
||||
// Redis connection failed, create a new instance
|
||||
$object = new self($product_id, $lang_id, $permutation_hash);
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch (\Exception $e)
|
||||
{
|
||||
// Log the exception if needed
|
||||
$object = new self( $product_id, $lang_id, $permutation_hash );
|
||||
$object = new self($product_id, $lang_id, $permutation_hash);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Redis extension not loaded, create a new instance
|
||||
$object = new self( $product_id, $lang_id, $permutation_hash );
|
||||
$object = new self($product_id, $lang_id, $permutation_hash);
|
||||
}
|
||||
|
||||
return $object;
|
||||
|
||||
@@ -20,16 +20,25 @@ class ProductCustomField implements \ArrayAccess
|
||||
try
|
||||
{
|
||||
$redis = \RedisConnection::getInstance() -> getConnection();
|
||||
$objectData = $redis -> get( "shop\ProductCustomField:$custom_field_id" );
|
||||
|
||||
if ( !$objectData )
|
||||
if ( $redis )
|
||||
{
|
||||
$object = new self( $custom_field_id );
|
||||
$redis -> setex( "shop\ProductCustomField:$custom_field_id", 60 * 60 * 24, serialize( $object ) );
|
||||
$objectData = $redis -> get( "shop\ProductCustomField:$custom_field_id" );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$object = new self( $custom_field_id );
|
||||
$redis -> setex( "shop\ProductCustomField:$custom_field_id", 60 * 60 * 24, serialize( $object ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$object = unserialize( $objectData );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$object = unserialize( $objectData );
|
||||
// Log the error if needed
|
||||
$object = new self( $custom_field_id );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
|
||||
93
cron.php
93
cron.php
@@ -52,7 +52,8 @@ $apilo_settings = \admin\factory\Integrations::apilo_settings();
|
||||
$baselinker_settings = \admin\factory\Integrations::baselinker_settings();
|
||||
$sellasist_settings = \admin\factory\Integrations::sellasist_settings();
|
||||
|
||||
function parsePaczkomatAddress($input) {
|
||||
function parsePaczkomatAddress($input)
|
||||
{
|
||||
$pattern = '/^(\w+)\s+\|\s+([^,]+),\s+(\d{2}-\d{3})\s+(.+)$/';
|
||||
|
||||
if (preg_match($pattern, $input, $matches)) {
|
||||
@@ -67,6 +68,21 @@ function parsePaczkomatAddress($input) {
|
||||
}
|
||||
}
|
||||
|
||||
function parseOrlenAddress( $input )
|
||||
{
|
||||
$pattern = '/^([^\|]+)\s*\|\s*([^,]+),\s*(.+?)\s+(\d{2}-\d{3})$/';
|
||||
if (preg_match($pattern, $input, $matches)) {
|
||||
return [
|
||||
'code' => trim($matches[1]),
|
||||
'address' => trim($matches[2]),
|
||||
'city' => trim($matches[3]),
|
||||
'postalCode' => trim($matches[4]),
|
||||
];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function getImageUrlById($id) {
|
||||
$apiUrl = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['SERVER_NAME'] . '/api/v1/product.php';
|
||||
|
||||
@@ -118,7 +134,7 @@ if ( $sellasist_settings['enabled'] and $sellasist_settings['sync_products'] and
|
||||
|
||||
$mdb -> update( 'pp_shop_products', [ 'price_netto' => \S::normalize_decimal( $price_netto, 2 ), 'price_brutto' => \S::normalize_decimal( $price_brutto, 2 ) ], [ 'sellasist_product_id' => $result['sellasist_product_id'] ] );
|
||||
|
||||
\admin\factory\ShopProduct::update_product_combinations_prices( $result['id'], $price_brutto, $vat, null );
|
||||
\admin\factory\ShopProduct::update_product_combinations_prices( (int)$result['id'], $price_brutto, $vat, null );
|
||||
}
|
||||
|
||||
// aktualizowanie stanu magazynowego
|
||||
@@ -190,7 +206,7 @@ if ( $apilo_settings['enabled'] and $apilo_settings['access-token'] and ( !$apil
|
||||
$mdb -> update( 'pp_shop_products', [ 'price_netto' => \S::normalize_decimal( $price_netto, 2 ), 'price_brutto' => \S::normalize_decimal( $price_brutto, 2 ) ], [ 'apilo_product_id' => $product_price['product'] ] );
|
||||
$product_id = $mdb -> get( 'pp_shop_products', 'id', [ 'apilo_product_id' => $product_price['product'] ] );
|
||||
|
||||
\admin\factory\ShopProduct::update_product_combinations_prices( $product_id, $price_brutto, $vat, null );
|
||||
\admin\factory\ShopProduct::update_product_combinations_prices( (int)$product_id, $price_brutto, $vat, null );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,7 +263,7 @@ if ( $baselinker_settings['enabled'] and $baselinker_settings['sync_products'] a
|
||||
$product_id = $mdb -> get( 'pp_shop_products', 'id', [ 'baselinker_product_id' => $baselinker_product_id ] );
|
||||
$vat = $mdb -> get( 'pp_shop_products', 'vat', [ 'baselinker_product_id' => $baselinker_product_id ] );
|
||||
|
||||
\admin\factory\ShopProduct::update_product_combinations_prices( $product_id, $price_brutto, $vat, $price_brutto_promo );
|
||||
\admin\factory\ShopProduct::update_product_combinations_prices( (int)$product_id, $price_brutto, $vat, $price_brutto_promo );
|
||||
}
|
||||
|
||||
// aktualizowanie wagi
|
||||
@@ -489,6 +505,29 @@ if ( $apilo_settings['enabled'] and $apilo_settings['sync_orders'] and $apilo_se
|
||||
$order_date = new DateTime( $order['date_order'] );
|
||||
|
||||
$paczkomatData = parsePaczkomatAddress( $order['inpost_paczkomat'] );
|
||||
$orlenPointData = parseOrlenAddress( $order['orlen_point'] );
|
||||
|
||||
$street = '';
|
||||
$city = '';
|
||||
$postal_code = '';
|
||||
if ( $order['client_street'] )
|
||||
{
|
||||
$street = $order['client_street'];
|
||||
$city = $order['client_city'];
|
||||
$postal_code = $order['client_postal_code'];
|
||||
}
|
||||
else if ( $paczkomatData )
|
||||
{
|
||||
$street = $paczkomatData['address'];
|
||||
$city = $paczkomatData['city'];
|
||||
$postal_code = $paczkomatData['postalCode'];
|
||||
}
|
||||
else if ( $orlenPointData )
|
||||
{
|
||||
$street = $orlenPointData['address'];
|
||||
$city = $orlenPointData['city'];
|
||||
$postal_code = $orlenPointData['postalCode'];
|
||||
}
|
||||
|
||||
$postData = [
|
||||
'idExternal' => $order['id'],
|
||||
@@ -503,17 +542,17 @@ if ( $apilo_settings['enabled'] and $apilo_settings['sync_orders'] and $apilo_se
|
||||
'name' => $order['client_name'] . ' ' . $order['client_surname'],
|
||||
'phone' => $order['client_phone'],
|
||||
'email' => $order['client_email'],
|
||||
'streetName' => $order['client_street'] ? $order['client_street'] : $paczkomatData['address'],
|
||||
'city' => $order['client_city'] ? $order['client_city'] : $paczkomatData['city'],
|
||||
'zipCode' => $order['client_postal_code'] ? $order['client_postal_code'] : $paczkomatData['postalCode']
|
||||
'streetName' => $street,
|
||||
'city' => $city,
|
||||
'zipCode' => $postal_code
|
||||
],
|
||||
'addressDelivery' => [
|
||||
'name' => $order['client_name'] . ' ' . $order['client_surname'],
|
||||
'phone' => $order['client_phone'],
|
||||
'email' => $order['client_email'],
|
||||
'streetName' => $order['client_street'] ? $order['client_street'] : $paczkomatData['address'],
|
||||
'city' => $order['client_city'] ? $order['client_city'] : $paczkomatData['city'],
|
||||
'zipCode' => $order['client_postal_code'] ? $order['client_postal_code'] : $paczkomatData['postalCode']
|
||||
'streetName' => $street,
|
||||
'city' => $city,
|
||||
'zipCode' => $postal_code
|
||||
],
|
||||
'carrierAccount' => (int)\front\factory\ShopTransport::get_apilo_carrier_account_id( $order['transport_id'] ),
|
||||
'orderNotes' => [ [
|
||||
@@ -544,6 +583,27 @@ if ( $apilo_settings['enabled'] and $apilo_settings['sync_orders'] and $apilo_se
|
||||
}
|
||||
}
|
||||
|
||||
// jeżeli orlen paczka
|
||||
if ( $order['orlen_point'] )
|
||||
{
|
||||
$postData['addressDelivery']['parcelName'] = $order['orlen_point'] ? 'Automat ORLEN ' . $order['orlen_point'] : null;
|
||||
$postData['addressDelivery']['parcelIdExternal'] = $order['orlen_point'] ? ( $parcelId = trim( explode( '-', $order['orlen_point'] )[1] ) ) : null;
|
||||
|
||||
if ( !$postData['addressDelivery']['zipCode'] or !$postData['addressDelivery']['city'] )
|
||||
{
|
||||
preg_match("/\b\d{2}-\d{3}\b/", $order['orlen_point'], $postalCodeMatches);
|
||||
$postalCode = $postalCodeMatches[0] ?? '';
|
||||
|
||||
$cityPattern = "/\d{2}-\d{3}\s+(.+)/";
|
||||
preg_match($cityPattern, $order['orlen_point'], $cityMatches);
|
||||
$city = $cityMatches[1] ?? '';
|
||||
|
||||
$postData['addressDelivery']['zipCode'] = $postalCode;
|
||||
$postData['addressDelivery']['city'] = $city;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $order['paid'] )
|
||||
{
|
||||
$payment_date = new DateTime( $order['date_order'] );
|
||||
@@ -769,11 +829,14 @@ if ( $baselinker_settings['enabled'] and $baselinker_settings['sync_orders'] an
|
||||
$results = $mdb -> select( 'pp_shop_products', [ 'id', 'price_brutto', 'price_brutto_promo' ], [ 'OR' => [ 'price_history_date[!]' => date( 'Y-m-d' ), 'price_history_date' => null ], 'ORDER' => [ 'price_history_date' => 'ASC' ], 'LIMIT' => 100 ] );
|
||||
foreach ( $results as $row )
|
||||
{
|
||||
$mdb -> insert( 'pp_shop_product_price_history', [
|
||||
'id_product' => $row['id'],
|
||||
'price' => $row['price_brutto_promo'] > 0 ? $row['price_brutto_promo'] : $row['price_brutto'],
|
||||
'date' => date( 'Y-m-d' )
|
||||
] );
|
||||
if ( $price )
|
||||
{
|
||||
$mdb -> insert( 'pp_shop_product_price_history', [
|
||||
'id_product' => $row['id'],
|
||||
'price' => $row['price_brutto_promo'] > 0 ? $row['price_brutto_promo'] : $row['price_brutto'],
|
||||
'date' => date( 'Y-m-d' )
|
||||
] );
|
||||
}
|
||||
|
||||
$mdb -> update( 'pp_shop_products', [ 'price_history_date' => date( 'Y-m-d' ) ], [ 'id' => $row['id'] ] );
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -2647,7 +2647,8 @@ ul.pager {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.inpost-info {
|
||||
.inpost-info,
|
||||
.orlen-info {
|
||||
margin-bottom: 10px;
|
||||
font-weight: 600;
|
||||
font-style: italic;
|
||||
@@ -2662,6 +2663,10 @@ ul.pager {
|
||||
margin-left: 15px;
|
||||
@include transition;
|
||||
|
||||
&.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
text-decoration: none;
|
||||
background: $cBlue;
|
||||
|
||||
@@ -57,15 +57,15 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" id="street" name="street" class="form-control" <? if ( !in_array( $this -> transport_method['id'], [ 1, 2, 3] ) ):?> required<? endif;?> placeholder="<?= ucfirst( \S::lang( 'ulica-i-nr-domu' ) );?> <? if ( in_array( $this -> transport_method['id'], [ 1, 2, 3] ) ):?> (<?= \S::lang( 'opcjonalnie' );?>)<? endif;?>" value="<?= htmlspecialchars( $address_current['street'] );?>">
|
||||
<input type="text" id="street" name="street" class="form-control" <? if ( !in_array( $this -> transport_method['id'], [ 1, 2, 3, 9] ) ):?> required<? endif;?> placeholder="<?= ucfirst( \S::lang( 'ulica-i-nr-domu' ) );?> <? if ( in_array( $this -> transport_method['id'], [ 1, 2, 3, 9] ) ):?> (<?= \S::lang( 'opcjonalnie' );?>)<? endif;?>" value="<?= htmlspecialchars( $address_current['street'] );?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-6">
|
||||
<input type="text" id="postal_code" name="postal_code" pattern="[0-9]{2}-[0-9]{3}" title="Format xx-xxx" class="form-control" <? if ( !in_array( $this -> transport_method['id'], [ 1, 2, 3] ) ):?> required<? endif;?> placeholder="<?= ucfirst( \S::lang( 'kod-pocztowy' ) );?><? if ( in_array( $this -> transport_method['id'], [ 1, 2, 3] ) ):?> (<?= \S::lang( 'opcjonalnie' );?>)<? endif;?>" " value="<?= htmlspecialchars( $address_current['postal_code'] );?>">
|
||||
<input type="text" id="postal_code" name="postal_code" pattern="[0-9]{2}-[0-9]{3}" title="Format xx-xxx" class="form-control" <? if ( !in_array( $this -> transport_method['id'], [ 1, 2, 3, 9] ) ):?> required<? endif;?> placeholder="<?= ucfirst( \S::lang( 'kod-pocztowy' ) );?><? if ( in_array( $this -> transport_method['id'], [ 1, 2, 3, 9] ) ):?> (<?= \S::lang( 'opcjonalnie' );?>)<? endif;?>" " value="<?= htmlspecialchars( $address_current['postal_code'] );?>">
|
||||
</div>
|
||||
<div class="col-12 col-md-6">
|
||||
<input type="text" id="city" name="city" class="form-control" <? if ( !in_array( $this -> transport_method['id'], [ 1, 2, 3] ) ):?> required<? endif;?> placeholder="<?= ucfirst( \S::lang( 'miasto' ) );?><? if ( in_array( $this -> transport_method['id'], [ 1, 2, 3] ) ):?> (<?= \S::lang( 'opcjonalnie' );?>)<? endif;?>" " value="<?= htmlspecialchars( $address_current['city'] );?>">
|
||||
<input type="text" id="city" name="city" class="form-control" <? if ( !in_array( $this -> transport_method['id'], [ 1, 2, 3, 9] ) ):?> required<? endif;?> placeholder="<?= ucfirst( \S::lang( 'miasto' ) );?><? if ( in_array( $this -> transport_method['id'], [ 1, 2, 3, 9] ) ):?> (<?= \S::lang( 'opcjonalnie' );?>)<? endif;?>" " value="<?= htmlspecialchars( $address_current['city'] );?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -36,14 +36,21 @@ if ( is_array( $this -> transports_methods ) )
|
||||
<? if ( $transport_method['id'] == 1 or $transport_method['id'] == 2 ):?>
|
||||
<div class="inpost-info inpost-info-<?= $transport_method['id'];?>">
|
||||
<? if ( $transport_method['id'] == $this -> transport_id ):?><?= \S::get_session( 'basket-inpost-info' );?>
|
||||
<? if ( \S::get_session( 'basket-inpost-info' ) ):?>
|
||||
<a href="#" onclick="inpost_map( <?= $transport_method['id'];?> ); return false;"><?= \S::lang( 'zmien' );?></a>
|
||||
<? else:?>
|
||||
<a href="#" onclick="inpost_map( <?= $transport_method['id'];?> ); return false;"><?= \S::lang( 'wybierz' );?></a>
|
||||
<? endif;?>
|
||||
<a href="#" onclick="inpost_map( <?= $transport_method['id'];?> ); return false;"><?= \S::lang( 'wybierz' );?></a>
|
||||
<? endif;?>
|
||||
</div>
|
||||
<? endif;?>
|
||||
<? if ( $transport_method['id'] == 9 ):?>
|
||||
<div class="orlen-info orlen-info-<?= $transport_method['id'];?>">
|
||||
<input type="hidden" name="orlen_point_id" id="orlen_point_id" value="<?= \S::get_session( 'basket_orlen_point_id' );?>">
|
||||
<?
|
||||
if ( \S::get_session( 'basket-transport-method-id' ) != 9 )
|
||||
$class = 'hidden';
|
||||
?>
|
||||
<span id="orlen_point_info" class="<?= $class;?>"><?= \S::get_session( 'basket_orlen_point_info' );?></span>
|
||||
<a href="#" class="orlen-widget <?= $class;?>" data-target="#orlen_point_id" data-label="#orlen_point_info" data-type="all" data-layout="tabs" onclick="return false;"><?= \S::lang( 'wybierz' );?></a>
|
||||
</div>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
<script class="footer" type="text/javascript">
|
||||
$( function() {
|
||||
|
||||
@@ -1,37 +1,48 @@
|
||||
<? global $settings; ?>
|
||||
<div id="basket-container">
|
||||
<div id="content">
|
||||
<?= $this -> basket_details;?>
|
||||
<?= $this->basket_details; ?>
|
||||
</div>
|
||||
<div id="paypo-promo">
|
||||
Chcesz skorzystać z odroczonych płatności <img src="/layout/images/paypo-logo.svg">? Wybierz jedną z form dostawy: <strong>odbiór osobisty, Paczkomaty InPost - przedpłata lub Kurier - przedpłata</strong>.<br/>
|
||||
Chcesz skorzystać z odroczonych płatności <img src="/layout/images/paypo-logo.svg">? Wybierz jedną z form dostawy: <strong>odbiór osobisty, Paczkomaty InPost - przedpłata lub Kurier - przedpłata</strong>.<br />
|
||||
Wartość zamówienia musi mieścić się w przedziale od 40 zł do 1000 zł.
|
||||
</div>
|
||||
<? if ( is_array( $this -> basket ) and count( $this -> basket ) ):?>
|
||||
<? 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 class="box-title"><?= ucfirst(\S::lang('dostawa')); ?>:</div>
|
||||
<div id="transport-methods">
|
||||
<?= $this -> 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>
|
||||
<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 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>
|
||||
<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;?>
|
||||
<? endif; ?>
|
||||
</div>
|
||||
<script>
|
||||
(function(o, r, l, e, n) {
|
||||
o[l] = o[l] || [];
|
||||
var f = r.getElementsByTagName('head')[0];
|
||||
var j = r.createElement('script');
|
||||
j.async = true;
|
||||
j.src = e + 'widget.js?token=' + n + '&v=1.0.0&t=' + Math.floor(new Date().getTime() / 1000);
|
||||
f.insertBefore(j, f.firstChild);
|
||||
})(window, document, 'orlenpaczka', 'https://mapa.orlenpaczka.pl/', '<?= $settings['orlen_paczka_map_token'];?>');
|
||||
</script>
|
||||
<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>
|
||||
@@ -48,59 +59,51 @@
|
||||
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>' );
|
||||
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();
|
||||
$('.inpost-map-container').hide();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function payment_checked( payment_method_id )
|
||||
{
|
||||
$.ajax(
|
||||
{
|
||||
function payment_checked(payment_method_id) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/shopBasket/basket_payment_method_set',
|
||||
data:
|
||||
{
|
||||
data: {
|
||||
payment_method_id: payment_method_id
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$( '#basket-container *' ).addClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'disable' );
|
||||
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' );
|
||||
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 )
|
||||
{
|
||||
function inpost_map(transport_method_id) {
|
||||
inpost_transport_method_id = transport_method_id;
|
||||
|
||||
window.easyPackAsyncInit = function () {
|
||||
window.easyPackAsyncInit = function() {
|
||||
easyPack.init({
|
||||
mapType: 'osm',
|
||||
searchType: 'osm',
|
||||
});
|
||||
|
||||
var map = easyPack.mapWidget( 'inpost-map', function(point)
|
||||
{
|
||||
$.ajax(
|
||||
{
|
||||
var map = easyPack.mapWidget('inpost-map', function(point) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/shopBasket/inpost_save',
|
||||
@@ -108,64 +111,104 @@
|
||||
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();
|
||||
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();
|
||||
$('.inpost-map-container').show();
|
||||
}
|
||||
|
||||
function transport_checked( transport_method_id, payment_method_id, event_click )
|
||||
{
|
||||
function transport_checked(transport_method_id, payment_method_id, event_click) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/shopBasket/basket_payments_methods',
|
||||
data:
|
||||
{
|
||||
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' );
|
||||
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({
|
||||
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' );
|
||||
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 );
|
||||
$('#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' ) )
|
||||
{
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/shopBasket/inpost_save',
|
||||
data: {
|
||||
paczkomat: null
|
||||
},
|
||||
beforeSend: function() {},
|
||||
success: function(response) {}
|
||||
});
|
||||
$( '#orlen_point_id' ).val( '' );
|
||||
$( '#orlen_point_info' ).addClass( 'hidden' );
|
||||
$( '.orlen-widget' ).addClass( 'hidden' );
|
||||
inpost_map( transport_method_id )
|
||||
}
|
||||
|
||||
if ( event_click && transport_method_id == '9' )
|
||||
{
|
||||
$( '.inpost-info' ).html( '' );
|
||||
$( '#orlen_point_info' ).removeClass( 'hidden' );
|
||||
$( '.orlen-widget' ).removeClass( 'hidden' );
|
||||
document.querySelectorAll('.orlen-widget').forEach(function(element) {
|
||||
element.click(); // Wywołuje kliknięcie na elemencie
|
||||
});
|
||||
}
|
||||
|
||||
if ( event_click && transport_method_id != 1 )
|
||||
{
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/shopBasket/inpost_save',
|
||||
data: {
|
||||
paczkomat: null
|
||||
},
|
||||
beforeSend: function() {},
|
||||
success: function(response) {}
|
||||
});
|
||||
$( '.inpost-info' ).html( '' );
|
||||
}
|
||||
|
||||
if ( event_click && transport_method_id != 9 )
|
||||
{
|
||||
$( '#orlen_point_id' ).val( '' );
|
||||
$( '#orlen_point_info' ).html( '' );
|
||||
$( '.orlen-widget' ).addClass( 'hidden' );
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
$( function()
|
||||
{
|
||||
$( 'body' ).on( 'change', '#basket .basket-product-message textarea', function()
|
||||
{
|
||||
var _this = $( this);
|
||||
$(function() {
|
||||
$('body').on('change', '#basket .basket-product-message textarea', function() {
|
||||
var _this = $(this);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
@@ -173,14 +216,14 @@
|
||||
url: '/shopBasket/product_message_change',
|
||||
data: {
|
||||
product_message: _this.val(),
|
||||
position_code: _this.attr( 'position' )
|
||||
position_code: _this.attr('position')
|
||||
},
|
||||
beforeSend: function() {},
|
||||
success: function() {}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( click_event, '#btn-basket-summary', function(e) {
|
||||
$('body').on(click_event, '#btn-basket-summary', function(e) {
|
||||
|
||||
e.preventDefault();
|
||||
$.ajax({
|
||||
@@ -189,33 +232,32 @@
|
||||
url: '/shopBasket/transport_method_inpost_check',
|
||||
data: {},
|
||||
beforeSend: function() {
|
||||
$( '#basket-container *' ).addClass( 'disabled' );
|
||||
$('#basket-container *').addClass('disabled');
|
||||
},
|
||||
success: function( response ) {
|
||||
success: function(response) {
|
||||
|
||||
data = jQuery.parseJSON( response );
|
||||
$( '#basket-container *' ).removeClass( 'disabled' );
|
||||
if ( data.result === 'bad' ) {
|
||||
data = jQuery.parseJSON(response);
|
||||
$('#basket-container *').removeClass('disabled');
|
||||
if (data.result === 'bad') {
|
||||
|
||||
$.alert({
|
||||
|
||||
title: '<?= ucfirst( \S::lang( 'uwaga' ) );?>',
|
||||
content: 'Proszę wybrać paczkomat.',
|
||||
title: '<?= ucfirst(\S::lang('uwaga')); ?>',
|
||||
content: 'Proszę wybrać punkt odbioru',
|
||||
type: 'blue',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fas fa-times',
|
||||
closeIconClass: 'fa fa-times',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
useBootstrap: false,
|
||||
theme: 'modern',
|
||||
autoClose: 'confirm|5000',
|
||||
icon: 'fas fa-exclamation',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: '<?= \S::lang( 'zamknij' );?>',
|
||||
text: '<?= \S::lang('zamknij'); ?>',
|
||||
btnClass: 'btn-blue',
|
||||
keys: ['enter'],
|
||||
action: function () {}
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -226,9 +268,8 @@
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'change', '#basket-message', function()
|
||||
{
|
||||
var _this = $( this);
|
||||
$('body').on('change', '#basket-message', function() {
|
||||
var _this = $(this);
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
@@ -237,62 +278,56 @@
|
||||
basket_message: _this.val()
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#basket-container *' ).addClass( 'disabled' );
|
||||
$('#basket-container *').addClass('disabled');
|
||||
},
|
||||
success: function( response ) {
|
||||
data = jQuery.parseJSON( response );
|
||||
success: function(response) {
|
||||
data = jQuery.parseJSON(response);
|
||||
|
||||
$( '#basket-container *' ).removeClass( 'disabled' );
|
||||
$('#basket-container *').removeClass('disabled');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'change', '.basket-product .int-format', function()
|
||||
{
|
||||
var product_hash = $( this ).attr( 'product-hash' );
|
||||
var quantity = $( this ).val();
|
||||
$('body').on('change', '.basket-product .int-format', function() {
|
||||
var product_hash = $(this).attr('product-hash');
|
||||
var quantity = $(this).val();
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/shopBasket/basket_change_quantity_product',
|
||||
data:
|
||||
{
|
||||
data: {
|
||||
product_hash: product_hash,
|
||||
quantity: quantity
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$( '#basket-container *' ).addClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'disable' );
|
||||
beforeSend: function() {
|
||||
$('#basket-container *').addClass('disabled');
|
||||
$('#payment-methods .icheck, #transport-methods .icheck').iCheck('disable');
|
||||
},
|
||||
success: function( response )
|
||||
{
|
||||
data = jQuery.parseJSON( response );
|
||||
success: function(response) {
|
||||
data = jQuery.parseJSON(response);
|
||||
|
||||
if ( data.products_count === 0 )
|
||||
{
|
||||
if (data.products_count === 0) {
|
||||
document.location.href = '/koszyk';
|
||||
$( '.mini-box' ).hide();
|
||||
$('.mini-box').hide();
|
||||
return false;
|
||||
}
|
||||
|
||||
$( '#basket-container *' ).removeClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'enable' );
|
||||
$( '#basket-container #content' ).html( data.basket );
|
||||
$('#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-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 );
|
||||
$('#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' );
|
||||
$('body').on(click_event, '.basket-product .btn-minus', function() {
|
||||
var product_hash = $(this).attr('product-hash');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
@@ -302,38 +337,36 @@
|
||||
product_hash: product_hash
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#basket-container *' ).addClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'disable' );
|
||||
$('#basket-container *').addClass('disabled');
|
||||
$('#payment-methods .icheck, #transport-methods .icheck').iCheck('disable');
|
||||
},
|
||||
success: function( response ) {
|
||||
success: function(response) {
|
||||
|
||||
data = jQuery.parseJSON( response );
|
||||
data = jQuery.parseJSON(response);
|
||||
|
||||
if ( data.products_count === 0 ) {
|
||||
if (data.products_count === 0) {
|
||||
document.location.href = '/koszyk';
|
||||
$( '.mini-box' ).hide();
|
||||
$('.mini-box').hide();
|
||||
return false;
|
||||
}
|
||||
|
||||
$( '#basket-container *' ).removeClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'enable' );
|
||||
$( '#basket-container #content' ).html( data.basket );
|
||||
$('#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-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 );
|
||||
$('#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' );
|
||||
$('body').on(click_event, '.basket-product .btn-plus', function() {
|
||||
var product_hash = $(this).attr('product-hash');
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/shopBasket/basket_increase_quantity_product',
|
||||
@@ -341,39 +374,37 @@
|
||||
product_hash: product_hash
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#basket-container *' ).addClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'disable' );
|
||||
$('#basket-container *').addClass('disabled');
|
||||
$('#payment-methods .icheck, #transport-methods .icheck').iCheck('disable');
|
||||
},
|
||||
success: function( response ) {
|
||||
data = jQuery.parseJSON( response );
|
||||
success: function(response) {
|
||||
data = jQuery.parseJSON(response);
|
||||
|
||||
if ( data.products_count === 0 )
|
||||
{
|
||||
if (data.products_count === 0) {
|
||||
document.location.href = '/koszyk';
|
||||
$( '.mini-box' ).hide();
|
||||
$('.mini-box').hide();
|
||||
return false;
|
||||
}
|
||||
|
||||
$( '#basket-container *' ).removeClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'enable' );
|
||||
$( '#basket-container #content' ).html( data.basket );
|
||||
$('#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-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 );
|
||||
$('#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' );
|
||||
$('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' );?>',
|
||||
title: '<?= ucfirst(\S::lang('potwierdz')); ?>',
|
||||
content: '<?= \S::lang('potwierdz-usuniecie-produktu-z-koszyka'); ?>',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fas fa-close',
|
||||
typeAnimated: true,
|
||||
@@ -383,7 +414,7 @@
|
||||
autoClose: 'cancel|10000',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: '<?= \S::lang( 'usun' );?>',
|
||||
text: '<?= \S::lang('usun'); ?>',
|
||||
btnClass: 'btn-orange',
|
||||
keys: ['enter'],
|
||||
action: function() {
|
||||
@@ -395,34 +426,32 @@
|
||||
product_hash: product_hash
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#basket-container *' ).addClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'disable' );
|
||||
$('#basket-container *').addClass('disabled');
|
||||
$('#payment-methods .icheck, #transport-methods .icheck').iCheck('disable');
|
||||
},
|
||||
success: function( response )
|
||||
{
|
||||
data = jQuery.parseJSON( response );
|
||||
success: function(response) {
|
||||
data = jQuery.parseJSON(response);
|
||||
|
||||
if ( data.products_count === 0 )
|
||||
{
|
||||
if (data.products_count === 0) {
|
||||
document.location.href = '/koszyk';
|
||||
$( '.mini-box' ).hide();
|
||||
$('.mini-box').hide();
|
||||
return false;
|
||||
}
|
||||
|
||||
$( '#basket-container *' ).removeClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'enable' );
|
||||
$( '#basket-container #content' ).html( data.basket );
|
||||
$('#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-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 );
|
||||
$('#basket-container #transport-methods').html(data.transport_methods);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
text: '<?= \S::lang( 'zamknij' );?>',
|
||||
text: '<?= \S::lang('zamknij'); ?>',
|
||||
btnClass: 'btn-blue',
|
||||
action: function() {}
|
||||
}
|
||||
@@ -431,4 +460,52 @@
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
// zapisywanie wybranego orlen punktu
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Znajdź element #orlen_point_id
|
||||
var orlenPointElement = document.querySelector('#transport-methods #orlen_point_id');
|
||||
|
||||
if (orlenPointElement) {
|
||||
// Utwórz observer, który będzie reagował na zmiany w atrybucie value
|
||||
var observer = new MutationObserver(function(mutations) {
|
||||
mutations.forEach(function(mutation) {
|
||||
if (mutation.type === 'attributes' && mutation.attributeName === 'value') {
|
||||
var orlen_point_id = orlenPointElement.value;
|
||||
var orlen_point_name = document.querySelector('#orlen_point_info').textContent;
|
||||
|
||||
// Przygotuj dane jako form-urlencoded
|
||||
var formData = new URLSearchParams();
|
||||
formData.append('orlen_point_id', orlen_point_id);
|
||||
formData.append('orlen_point_name', orlen_point_name);
|
||||
|
||||
// Wykonaj żądanie AJAX
|
||||
fetch('/shopBasket/orlen_save', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: formData,
|
||||
cache: 'no-cache'
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
// Obsługa odpowiedzi
|
||||
console.log('Odpowiedź serwera:', data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Błąd podczas wykonywania żądania:', error);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Konfiguracja observera do śledzenia zmian atrybutów
|
||||
observer.observe(orlenPointElement, {
|
||||
attributes: true
|
||||
});
|
||||
} else {
|
||||
console.warn('#orlen_point_id nie został znaleziony.');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -37,6 +37,9 @@ echo $this -> settings['newsletter_header'];
|
||||
<? if ( $this -> order['inpost_paczkomat'] ):?>
|
||||
<br /><br />Paczkomat: <b><?= $this -> order['inpost_paczkomat'];?>
|
||||
<? endif;?>
|
||||
<? if ( $this -> order['orlen_point'] ):?>
|
||||
<br /><br />Punkt Orlen: <b><?= $this -> order['orlen_point'];?>
|
||||
<? endif;?>
|
||||
</p>
|
||||
<div style="border-bottom: 1px solid #eee; margin-bottom: 15px;"></div>
|
||||
<p style="font-family: Arial; font-size: 14px; font-weight: 600; text-transform: uppercase;"><?= \S::lang( 'zamowione-produkty' );?>:</p>
|
||||
|
||||
73
templates/shop-product/products-new.php
Normal file
73
templates/shop-product/products-new.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<? $hash = md5( time() . rand( 0, 9999999999 ) );?>
|
||||
|
||||
<? if ($this -> products) : ?>
|
||||
<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>
|
||||
|
||||
<? endif; ?>
|
||||
73
templates/shop-product/products-top.php
Normal file
73
templates/shop-product/products-top.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<? $hash = md5( time() . rand( 0, 9999999999 ) );?>
|
||||
|
||||
<? if ($this -> products) : ?>
|
||||
<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>
|
||||
|
||||
<? endif; ?>
|
||||
@@ -1,33 +1,48 @@
|
||||
<? global $settings; ?>
|
||||
<div id="basket-container">
|
||||
<div id="content">
|
||||
<?= $this -> basket_details;?>
|
||||
<?= $this->basket_details; ?>
|
||||
</div>
|
||||
<? if ( is_array( $this -> basket ) and count( $this -> basket ) ):?>
|
||||
<div id="paypo-promo">
|
||||
Chcesz skorzystać z odroczonych płatności <img src="/layout/images/paypo-logo.svg">? Wybierz jedną z form dostawy: <strong>odbiór osobisty, Paczkomaty InPost - przedpłata lub Kurier - przedpłata</strong>.<br />
|
||||
Wartość zamówienia musi mieścić się w przedziale od 40 zł do 1000 zł.
|
||||
</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 class="box-title"><?= ucfirst(\S::lang('dostawa')); ?>:</div>
|
||||
<div id="transport-methods">
|
||||
<?= $this -> 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>
|
||||
<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 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>
|
||||
<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;?>
|
||||
<? endif; ?>
|
||||
</div>
|
||||
<script>
|
||||
(function(o, r, l, e, n) {
|
||||
o[l] = o[l] || [];
|
||||
var f = r.getElementsByTagName('head')[0];
|
||||
var j = r.createElement('script');
|
||||
j.async = true;
|
||||
j.src = e + 'widget.js?token=' + n + '&v=1.0.0&t=' + Math.floor(new Date().getTime() / 1000);
|
||||
f.insertBefore(j, f.firstChild);
|
||||
})(window, document, 'orlenpaczka', 'https://mapa.orlenpaczka.pl/', '<?= $settings['orlen_paczka_map_token'];?>');
|
||||
</script>
|
||||
<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>
|
||||
@@ -44,59 +59,51 @@
|
||||
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>' );
|
||||
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();
|
||||
$('.inpost-map-container').hide();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function payment_checked( payment_method_id )
|
||||
{
|
||||
$.ajax(
|
||||
{
|
||||
function payment_checked(payment_method_id) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/shopBasket/basket_payment_method_set',
|
||||
data:
|
||||
{
|
||||
data: {
|
||||
payment_method_id: payment_method_id
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$( '#basket-container *' ).addClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'disable' );
|
||||
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' );
|
||||
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 )
|
||||
{
|
||||
function inpost_map(transport_method_id) {
|
||||
inpost_transport_method_id = transport_method_id;
|
||||
|
||||
window.easyPackAsyncInit = function () {
|
||||
window.easyPackAsyncInit = function() {
|
||||
easyPack.init({
|
||||
mapType: 'osm',
|
||||
searchType: 'osm',
|
||||
});
|
||||
|
||||
var map = easyPack.mapWidget( 'inpost-map', function(point)
|
||||
{
|
||||
$.ajax(
|
||||
{
|
||||
var map = easyPack.mapWidget('inpost-map', function(point) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/shopBasket/inpost_save',
|
||||
@@ -104,64 +111,104 @@
|
||||
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();
|
||||
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();
|
||||
$('.inpost-map-container').show();
|
||||
}
|
||||
|
||||
function transport_checked( transport_method_id, payment_method_id, event_click )
|
||||
{
|
||||
function transport_checked(transport_method_id, payment_method_id, event_click) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/shopBasket/basket_payments_methods',
|
||||
data:
|
||||
{
|
||||
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' );
|
||||
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({
|
||||
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' );
|
||||
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 );
|
||||
$('#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' ) )
|
||||
{
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/shopBasket/inpost_save',
|
||||
data: {
|
||||
paczkomat: null
|
||||
},
|
||||
beforeSend: function() {},
|
||||
success: function(response) {}
|
||||
});
|
||||
$( '#orlen_point_id' ).val( '' );
|
||||
$( '#orlen_point_info' ).addClass( 'hidden' );
|
||||
$( '.orlen-widget' ).addClass( 'hidden' );
|
||||
inpost_map( transport_method_id )
|
||||
}
|
||||
|
||||
if ( event_click && transport_method_id == '9' )
|
||||
{
|
||||
$( '.inpost-info' ).html( '' );
|
||||
$( '#orlen_point_info' ).removeClass( 'hidden' );
|
||||
$( '.orlen-widget' ).removeClass( 'hidden' );
|
||||
document.querySelectorAll('.orlen-widget').forEach(function(element) {
|
||||
element.click(); // Wywołuje kliknięcie na elemencie
|
||||
});
|
||||
}
|
||||
|
||||
if ( event_click && transport_method_id != 1 )
|
||||
{
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/shopBasket/inpost_save',
|
||||
data: {
|
||||
paczkomat: null
|
||||
},
|
||||
beforeSend: function() {},
|
||||
success: function(response) {}
|
||||
});
|
||||
$( '.inpost-info' ).html( '' );
|
||||
}
|
||||
|
||||
if ( event_click && transport_method_id != 9 )
|
||||
{
|
||||
$( '#orlen_point_id' ).val( '' );
|
||||
$( '#orlen_point_info' ).html( '' );
|
||||
$( '.orlen-widget' ).addClass( 'hidden' );
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
$( function()
|
||||
{
|
||||
$( 'body' ).on( 'change', '#basket .basket-product-message textarea', function()
|
||||
{
|
||||
var _this = $( this);
|
||||
$(function() {
|
||||
$('body').on('change', '#basket .basket-product-message textarea', function() {
|
||||
var _this = $(this);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
@@ -169,14 +216,14 @@
|
||||
url: '/shopBasket/product_message_change',
|
||||
data: {
|
||||
product_message: _this.val(),
|
||||
position_code: _this.attr( 'position' )
|
||||
position_code: _this.attr('position')
|
||||
},
|
||||
beforeSend: function() {},
|
||||
success: function() {}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( click_event, '#btn-basket-summary', function(e) {
|
||||
$('body').on(click_event, '#btn-basket-summary', function(e) {
|
||||
|
||||
e.preventDefault();
|
||||
$.ajax({
|
||||
@@ -185,18 +232,18 @@
|
||||
url: '/shopBasket/transport_method_inpost_check',
|
||||
data: {},
|
||||
beforeSend: function() {
|
||||
$( '#basket-container *' ).addClass( 'disabled' );
|
||||
$('#basket-container *').addClass('disabled');
|
||||
},
|
||||
success: function( response ) {
|
||||
success: function(response) {
|
||||
|
||||
data = jQuery.parseJSON( response );
|
||||
$( '#basket-container *' ).removeClass( 'disabled' );
|
||||
if ( data.result === 'bad' ) {
|
||||
data = jQuery.parseJSON(response);
|
||||
$('#basket-container *').removeClass('disabled');
|
||||
if (data.result === 'bad') {
|
||||
|
||||
$.alert({
|
||||
|
||||
title: '<?= ucfirst( \S::lang( 'uwaga' ) );?>',
|
||||
content: 'Proszę wybrać paczkomat.',
|
||||
title: '<?= ucfirst(\S::lang('uwaga')); ?>',
|
||||
content: 'Proszę wybrać punkt odbioru',
|
||||
type: 'blue',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-times',
|
||||
@@ -205,13 +252,12 @@
|
||||
useBootstrap: false,
|
||||
theme: 'modern',
|
||||
autoClose: 'confirm|5000',
|
||||
icon: 'fa fa-exclamation',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: '<?= \S::lang( 'zamknij' );?>',
|
||||
text: '<?= \S::lang('zamknij'); ?>',
|
||||
btnClass: 'btn-blue',
|
||||
keys: ['enter'],
|
||||
action: function () {}
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -222,9 +268,8 @@
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'change', '#basket-message', function()
|
||||
{
|
||||
var _this = $( this);
|
||||
$('body').on('change', '#basket-message', function() {
|
||||
var _this = $(this);
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
@@ -233,62 +278,56 @@
|
||||
basket_message: _this.val()
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#basket-container *' ).addClass( 'disabled' );
|
||||
$('#basket-container *').addClass('disabled');
|
||||
},
|
||||
success: function( response ) {
|
||||
data = jQuery.parseJSON( response );
|
||||
success: function(response) {
|
||||
data = jQuery.parseJSON(response);
|
||||
|
||||
$( '#basket-container *' ).removeClass( 'disabled' );
|
||||
$('#basket-container *').removeClass('disabled');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'change', '.basket-product .int-format', function()
|
||||
{
|
||||
var product_hash = $( this ).attr( 'product-hash' );
|
||||
var quantity = $( this ).val();
|
||||
$('body').on('change', '.basket-product .int-format', function() {
|
||||
var product_hash = $(this).attr('product-hash');
|
||||
var quantity = $(this).val();
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/shopBasket/basket_change_quantity_product',
|
||||
data:
|
||||
{
|
||||
data: {
|
||||
product_hash: product_hash,
|
||||
quantity: quantity
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$( '#basket-container *' ).addClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'disable' );
|
||||
beforeSend: function() {
|
||||
$('#basket-container *').addClass('disabled');
|
||||
$('#payment-methods .icheck, #transport-methods .icheck').iCheck('disable');
|
||||
},
|
||||
success: function( response )
|
||||
{
|
||||
data = jQuery.parseJSON( response );
|
||||
success: function(response) {
|
||||
data = jQuery.parseJSON(response);
|
||||
|
||||
if ( data.products_count === 0 )
|
||||
{
|
||||
if (data.products_count === 0) {
|
||||
document.location.href = '/koszyk';
|
||||
$( '.mini-box' ).hide();
|
||||
$('.mini-box').hide();
|
||||
return false;
|
||||
}
|
||||
|
||||
$( '#basket-container *' ).removeClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'enable' );
|
||||
$( '#basket-container #content' ).html( data.basket );
|
||||
$('#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-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 );
|
||||
$('#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' );
|
||||
$('body').on(click_event, '.basket-product .btn-minus', function() {
|
||||
var product_hash = $(this).attr('product-hash');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
@@ -298,38 +337,36 @@
|
||||
product_hash: product_hash
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#basket-container *' ).addClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'disable' );
|
||||
$('#basket-container *').addClass('disabled');
|
||||
$('#payment-methods .icheck, #transport-methods .icheck').iCheck('disable');
|
||||
},
|
||||
success: function( response ) {
|
||||
success: function(response) {
|
||||
|
||||
data = jQuery.parseJSON( response );
|
||||
data = jQuery.parseJSON(response);
|
||||
|
||||
if ( data.products_count === 0 ) {
|
||||
if (data.products_count === 0) {
|
||||
document.location.href = '/koszyk';
|
||||
$( '.mini-box' ).hide();
|
||||
$('.mini-box').hide();
|
||||
return false;
|
||||
}
|
||||
|
||||
$( '#basket-container *' ).removeClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'enable' );
|
||||
$( '#basket-container #content' ).html( data.basket );
|
||||
$('#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-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 );
|
||||
$('#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' );
|
||||
$('body').on(click_event, '.basket-product .btn-plus', function() {
|
||||
var product_hash = $(this).attr('product-hash');
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/shopBasket/basket_increase_quantity_product',
|
||||
@@ -337,39 +374,37 @@
|
||||
product_hash: product_hash
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#basket-container *' ).addClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'disable' );
|
||||
$('#basket-container *').addClass('disabled');
|
||||
$('#payment-methods .icheck, #transport-methods .icheck').iCheck('disable');
|
||||
},
|
||||
success: function( response ) {
|
||||
data = jQuery.parseJSON( response );
|
||||
success: function(response) {
|
||||
data = jQuery.parseJSON(response);
|
||||
|
||||
if ( data.products_count === 0 )
|
||||
{
|
||||
if (data.products_count === 0) {
|
||||
document.location.href = '/koszyk';
|
||||
$( '.mini-box' ).hide();
|
||||
$('.mini-box').hide();
|
||||
return false;
|
||||
}
|
||||
|
||||
$( '#basket-container *' ).removeClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'enable' );
|
||||
$( '#basket-container #content' ).html( data.basket );
|
||||
$('#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-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 );
|
||||
$('#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' );
|
||||
$('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' );?>',
|
||||
title: '<?= ucfirst(\S::lang('potwierdz')); ?>',
|
||||
content: '<?= \S::lang('potwierdz-usuniecie-produktu-z-koszyka'); ?>',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fas fa-close',
|
||||
typeAnimated: true,
|
||||
@@ -379,7 +414,7 @@
|
||||
autoClose: 'cancel|10000',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: '<?= \S::lang( 'usun' );?>',
|
||||
text: '<?= \S::lang('usun'); ?>',
|
||||
btnClass: 'btn-orange',
|
||||
keys: ['enter'],
|
||||
action: function() {
|
||||
@@ -391,34 +426,32 @@
|
||||
product_hash: product_hash
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#basket-container *' ).addClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'disable' );
|
||||
$('#basket-container *').addClass('disabled');
|
||||
$('#payment-methods .icheck, #transport-methods .icheck').iCheck('disable');
|
||||
},
|
||||
success: function( response )
|
||||
{
|
||||
data = jQuery.parseJSON( response );
|
||||
success: function(response) {
|
||||
data = jQuery.parseJSON(response);
|
||||
|
||||
if ( data.products_count === 0 )
|
||||
{
|
||||
if (data.products_count === 0) {
|
||||
document.location.href = '/koszyk';
|
||||
$( '.mini-box' ).hide();
|
||||
$('.mini-box').hide();
|
||||
return false;
|
||||
}
|
||||
|
||||
$( '#basket-container *' ).removeClass( 'disabled' );
|
||||
$( '#payment-methods .icheck, #transport-methods .icheck' ).iCheck( 'enable' );
|
||||
$( '#basket-container #content' ).html( data.basket );
|
||||
$('#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-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 );
|
||||
$('#basket-container #transport-methods').html(data.transport_methods);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
text: '<?= \S::lang( 'zamknij' );?>',
|
||||
text: '<?= \S::lang('zamknij'); ?>',
|
||||
btnClass: 'btn-blue',
|
||||
action: function() {}
|
||||
}
|
||||
@@ -427,4 +460,52 @@
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
// zapisywanie wybranego orlen punktu
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Znajdź element #orlen_point_id
|
||||
var orlenPointElement = document.querySelector('#transport-methods #orlen_point_id');
|
||||
|
||||
if (orlenPointElement) {
|
||||
// Utwórz observer, który będzie reagował na zmiany w atrybucie value
|
||||
var observer = new MutationObserver(function(mutations) {
|
||||
mutations.forEach(function(mutation) {
|
||||
if (mutation.type === 'attributes' && mutation.attributeName === 'value') {
|
||||
var orlen_point_id = orlenPointElement.value;
|
||||
var orlen_point_name = document.querySelector('#orlen_point_info').textContent;
|
||||
|
||||
// Przygotuj dane jako form-urlencoded
|
||||
var formData = new URLSearchParams();
|
||||
formData.append('orlen_point_id', orlen_point_id);
|
||||
formData.append('orlen_point_name', orlen_point_name);
|
||||
|
||||
// Wykonaj żądanie AJAX
|
||||
fetch('/shopBasket/orlen_save', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: formData,
|
||||
cache: 'no-cache'
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
// Obsługa odpowiedzi
|
||||
console.log('Odpowiedź serwera:', data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Błąd podczas wykonywania żądania:', error);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Konfiguracja observera do śledzenia zmian atrybutów
|
||||
observer.observe(orlenPointElement, {
|
||||
attributes: true
|
||||
});
|
||||
} else {
|
||||
console.warn('#orlen_point_id nie został znaleziony.');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user