This commit is contained in:
2026-04-30 01:43:17 +02:00
parent 2114254518
commit 1994f95183
14 changed files with 2153 additions and 1251 deletions

View File

@@ -26,28 +26,27 @@
});
var injectScripts = function injectScripts() {
// Google Analytics consent
// Example: Google Analytics
if (cookieNoticePro.isPreferenceAccepted("analytics") === true) {
gtag('consent', 'update', {
'analytics_storage': 'granted'
});
//console.log("Analytics Scripts Running....");
}
// Google Adwords, DoubleClick, Remarketing pixels, Social Media cookies
// Example: Google Adwords cookie, DoubleClick, Remarketing pixels, Social Media cookies
if (cookieNoticePro.isPreferenceAccepted("marketing") === true) {
gtag('consent', 'update', {
'ad_storage': 'granted',
'ad_user_data': 'granted',
'ad_personalization': 'granted'
'ad_personalization': 'granted',
'analytics_storage': 'granted',
'personalization_storage': 'granted',
'security_storage': 'granted',
'functionality_storage': 'granted',
"wait_for_update": 2000
});
}
// Example: Remember password, language, etc
if (cookieNoticePro.isPreferenceAccepted("preferences") === true) {
gtag('consent', 'update', {
'personalization_storage': 'granted',
'security_storage': 'granted',
'functionality_storage': 'granted'
});
//console.log("Preferences Scripts Running....");
}
}
</script>

View File

@@ -45,8 +45,7 @@
<hr>
<? endif; ?>
<?= \Shared\Tpl\Tpl::view( 'shop-basket/_partials/product-custom-fields', [
'custom_fields' => $position['custom_fields'],
'product_code' => $position_hash
'custom_fields' => $position['custom_fields']
] ); ?>
<? if ( $product['additional_message'] ):?>
<div class="basket-product-message">
@@ -113,4 +112,4 @@
<div class="alert alert-danger">Brak produktów w koszyku</div>
<? endif; ?>
</div>
</div>
</div>

View File

@@ -35,7 +35,6 @@
</div>
<? if ( $this -> settings['google_tag_manager_id'] && is_array( $this -> basket ) && count( $this -> basket ) ):?>
<script>
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: "view_cart",
ecommerce: {
@@ -50,7 +49,7 @@
if ( $view_cart_items ) $view_cart_items .= ',';
$view_cart_items .= '{';
$view_cart_items .= '"item_id": "' . $product['id'] . '",';
$view_cart_items .= '"item_name": "' . str_replace( '"', '', $product['language']['name'] ) . '",';
$view_cart_items .= '"item_name": "' . $product['language']['name'] . '",';
$view_cart_items .= '"price": ' . \Shared\Helpers\Helpers::normalize_decimal( $price_product['price_new'] ) . ',';
$view_cart_items .= '"quantity": ' . (int)$position['quantity'] . ',';
$view_cart_items .= '"google_business_vertical": "retail"';
@@ -538,62 +537,4 @@
console.warn('#orlen_point_id nie został znaleziony.');
}
});
// edycja personalizacji produktu w koszyku
$(document).on('click', '.btn-edit-custom-fields', function(e) {
e.preventDefault();
var $display = $(this).closest('.custom-fields-display');
var productCode = $display.data('product-code');
$display.hide();
$display.siblings('.custom-fields-edit[data-product-code="' + productCode + '"]').show();
});
$(document).on('click', '.btn-cancel-custom-fields', function(e) {
e.preventDefault();
var $edit = $(this).closest('.custom-fields-edit');
var productCode = $edit.data('product-code');
$edit.hide();
$edit.siblings('.custom-fields-display[data-product-code="' + productCode + '"]').show();
});
$(document).on('click', '.btn-save-custom-fields', function(e) {
e.preventDefault();
var $edit = $(this).closest('.custom-fields-edit');
var productCode = $edit.data('product-code');
var valid = true;
$edit.find('input[required]').each(function() {
if ($.trim($(this).val()) === '') {
$(this).css('border-color', 'red');
valid = false;
} else {
$(this).css('border-color', '');
}
});
if (!valid) {
alert('Wypełnij wszystkie wymagane pola');
return;
}
var formData = { product_code: productCode };
$edit.find('input[name^="custom_field"]').each(function() {
formData[$(this).attr('name')] = $(this).val();
});
$.ajax({
type: 'POST',
cache: false,
url: '/shopBasket/basket_update_custom_fields',
data: formData,
success: function(response) {
var data = jQuery.parseJSON(response);
if (data.result === 'ok') {
location.reload();
} else {
alert(data.message || 'Wystąpił błąd');
}
}
});
});
</script>
</script>

View File

@@ -163,7 +163,6 @@
<? if ( \Shared\Helpers\Helpers::get_session('google-analytics-purchase') ):?>
<? if ( $this -> settings['google_tag_manager_id'] ):?>
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: "purchase",
ecommerce: {
@@ -175,9 +174,9 @@
<? foreach ( $this -> order['products'] as $product ):?>
{
item_id: "<?= $product['product_id'];?>",
item_name: "<?= str_replace( '"', '', $product['name'] );?>",
item_name: '<?= $product['name'];?>',
quantity: <?= (int)$product['quantity'];?>,
price: <?= ((float)$product['price_brutto_promo'] > 0 && (float)$product['price_brutto_promo'] < (float)$product['price_brutto']) ? \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto_promo'] ) : \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto'] );?>,
price: <?= (float)$product['price_brutto_promo'] > 0 ? \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto_promo'] ) : \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto'] );?>,
google_business_vertical: 'retail'
}<? if ( $product != end( $this -> order['products'] ) ) echo ',';?>
<? endforeach;?>
@@ -195,7 +194,7 @@
}
});
<? endif;?>
<? unset( $_SESSION['google-analytics-purchase'] );?>
<? unset( $_SESSION['google-adwords-purchase'] );?>
<? endif;?>
});
</script>
</script>

View File

@@ -244,7 +244,6 @@
<script type="text/javascript">
$( function() {
<? if ( $this -> settings['google_tag_manager_id'] ):?>
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: "view_item",
ecommerce: {
@@ -565,7 +564,6 @@
<? if ( $this -> settings['google_tag_manager_id'] ):?>
var add_to_cart_value = <? if ( $this -> product['price_brutto_promo'] ): echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto_promo'] ); else: echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto'] ); endif;?> * quantity;
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: "add_to_cart",
ecommerce: {
@@ -667,4 +665,4 @@
});
return false;
}
</script>
</script>