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

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' );
}
});