Refactor CSS and JavaScript for product comparison and wishlist functionality

- Updated `dr_materac.scss` to hide the compare/wishlist button by default.
- Enhanced JavaScript in `detail1526395446.tpl` to safely add an event listener for the opinions section link, ensuring it only attaches if the element exists.
- Cleaned up the `product-add-to-cart.tpl` by uncommenting the compare/wishlist button section for better visibility in the UI.
This commit is contained in:
2025-12-21 18:48:15 +01:00
parent f862af960e
commit d43bfb49df
8 changed files with 18539 additions and 320 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -520,26 +520,21 @@ $(document).ready(function() {
});
// Transformer theme add to cart butons on product lists
$('body').on("click", ".ajax_add_to_cart_button", function(e) {
$('body').on("click", ".product-add-to-cart .add-to-cart", function(e) {
let a_button = $(this),
id_product = parseInt(a_button.attr('data-id-product')),
id_product_attribute = parseInt(a_button.attr('data-id-product-attribute')),
id_product = parseInt( $('.product-actions .leo-wishlist-button').attr('data-id-product')),
id_product_attribute = parseInt( $('.product-actions .leo-wishlist-button').attr('data-id-product-attribute')),
iso_code = prestashop.currency.iso_code;
setTimeout(function () {
document.location = product_url;
}, 500);
if (typeof(product_id) !== 'undefined' && typeof(product_id_product_attribute) !== 'undefined' && typeof(product_url) !== 'undefined') {
if (typeof(id_product) !== 'undefined' && typeof(id_product_attribute) !== 'undefined') {
$.ajax({
type: "POST",
url: pdgoogleanalytycs4pro_ajax_link,
data: {'action': 'updateCart', 'product_id': product_id, 'product_id_product_attribute' : product_id_product_attribute, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax : true},
data: {'action': 'updateCart', 'product_id': id_product, 'product_id_product_attribute' : id_product_attribute, 'secure_key': pdgoogleanalytycs4pro_secure_key, ajax : true},
dataType: "json",
success: function(data) {
console.log('Fired up event GA4: select_item');
gtag('event', 'select_item', {
gtag('event', 'add_to_cart', {
currency: iso_code,
items: [{
item_id: data.content_ids,
@@ -559,14 +554,16 @@ $(document).ready(function() {
item_variant: data.content_variant,
price: data.content_value_old,
currency: iso_code,
quantity: 1
quantity: $( '#quantity_wanted' ).val()
}],
item_list_name: pd_google_analitycs_controller,
item_list_id: pd_google_analitycs_controller
});
}
});
}
} else {
console.log( 'Cannot fire up Transformer select_item event - missing data' );
}
});

View File

@@ -48,47 +48,6 @@
});
{else if ($tagType === 'cart')}
console.log('Fired up event GA4: begin_checkout');
if (window.location.hostname === "lulandia.pl") {
gtag('event', 'conversion', {
'send_to': 'AW-11243281264/Gs-KCNqSsesYEPC2m_Ep',
'value': {$content_value|escape:'htmlall':'UTF-8'},
'currency': 'PLN'
});
console.log( 'Fired up event GADS begin_checkout conversion lulandia.pl' );
}
gtag('event', 'begin_checkout', {
coupon: '{$content_coupon|escape:'htmlall':'UTF-8'}',
currency: '{$currency|escape:'htmlall':'UTF-8'}',
items: [
{foreach from=$content_products item=product name=products}
{
item_id: '{$product.content_ids|escape:'htmlall':'UTF-8'}',
item_name: '{$product.name|escape:'htmlall':'UTF-8'}',
coupon: '{$product.content_coupon|escape:'htmlall':'UTF-8'}',
discount: {$product.discount|escape:'htmlall':'UTF-8'},
index: {$smarty.foreach.products.index},
item_list_name: 'Cart products',
item_list_id: 1,
affiliation: '{$http_referer|escape:'htmlall':'UTF-8'}',
item_brand: '{$product.manufacturer_name|escape:'htmlall':'UTF-8'}',
item_category: '{$product.content_category|escape:'htmlall':'UTF-8'}',
{if !empty($product.content_category2)}item_category2: '{$product.content_category2|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category3)}item_category3: '{$product.content_category3|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category4)}item_category4: '{$product.content_category4|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category5)}item_category5: '{$product.content_category5|escape:'htmlall':'UTF-8'}',{/if}
item_variant: '{if isset($product.variant)}{$product.variant}{/if}',
price: {$product.price|escape:'htmlall':'UTF-8'},
currency: '{$currency|escape:'htmlall':'UTF-8'}',
quantity: '{$product.cart_quantity|escape:'htmlall':'UTF-8'}'
},
{/foreach}
],
value: {$content_value|escape:'htmlall':'UTF-8'}
});
console.log('Fired up event GA4: view_cart');
gtag('event', 'view_cart', {
currency: '{$currency|escape:'htmlall':'UTF-8'}',
@@ -159,37 +118,6 @@
],
value: {$content_value|escape:'htmlall':'UTF-8'}
});
console.log('Fired up event GA4: view_cart');
gtag('event', 'view_cart', {
currency: '{$currency|escape:'htmlall':'UTF-8'}',
items: [
{foreach from=$content_products item=product name=products}
{
item_id: '{$product.content_ids|escape:'htmlall':'UTF-8'}',
item_name: '{$product.name|escape:'htmlall':'UTF-8'}',
coupon: '{$product.content_coupon|escape:'htmlall':'UTF-8'}',
discount: {$product.discount|escape:'htmlall':'UTF-8'},
index: {$smarty.foreach.products.index},
item_list_name: 'Cart products',
item_list_id: 1,
affiliation: '{$http_referer|escape:'htmlall':'UTF-8'}',
item_brand: '{$product.manufacturer_name|escape:'htmlall':'UTF-8'}',
item_category: '{$product.content_category|escape:'htmlall':'UTF-8'}',
{if !empty($product.content_category2)}item_category2: '{$product.content_category2|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category3)}item_category3: '{$product.content_category3|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category4)}item_category4: '{$product.content_category4|escape:'htmlall':'UTF-8'}',{/if}
{if !empty($product.content_category5)}item_category5: '{$product.content_category5|escape:'htmlall':'UTF-8'}',{/if}
item_variant: '{if isset($product.variant)}{$product.variant}{/if}',
price: {$product.price|escape:'htmlall':'UTF-8'},
currency: '{$currency|escape:'htmlall':'UTF-8'}',
quantity: '{$product.cart_quantity|escape:'htmlall':'UTF-8'}'
},
{/foreach}
],
value: {$content_value|escape:'htmlall':'UTF-8'}
});
{else if ($tagType === 'category')}
console.log('Fired up event GA4: view_item_list > Category products list page');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -5904,4 +5904,8 @@ body:not(#index) {
a {
font-size: 14px;
}
}
.leo-compare-wishlist-button {
display: none !important;
}

View File

@@ -500,8 +500,15 @@
{/if}
</div>
<script>
document.querySelector('a[href="#opinions-sections"]').addEventListener('click', function(e) {
e.preventDefault();
document.addEventListener('DOMContentLoaded', function() {
const opinionLink = document.querySelector('a[href="#opinions-sections"]');
// Nadal warto dodać sprawdzenie 'if', na wypadek gdyby elementu w ogóle nie było
if (opinionLink) {
opinionLink.addEventListener('click', function(e) {
e.preventDefault();
});
}
});
</script>
<a href="#opinions-sections" style="display:flex; gap:10px;">

View File

@@ -66,10 +66,10 @@
<i class="material-icons shopping-cart">&#xE547;</i>
{l s='Add to cart' d='Shop.Theme.Actions'}
</button>
<!-- <div class="leo-compare-wishlist-button">
<div class="leo-compare-wishlist-button">
{hook h='displayLeoWishlistButton' product=$product}
{hook h='displayLeoCompareButton' product=$product}
</div> -->
</div>
</div>
</div>
{/block}