From 718f1a8bd1a40d4f6d1dc74c7b3b3266ae1784dd Mon Sep 17 00:00:00 2001 From: Markus Goedecke Date: Thu, 22 Mar 2018 10:30:22 +0100 Subject: [PATCH] track sold out products INREL-3676 --- infinite.theme | 8 ++++---- js/infinite/views/products/product-view.js | 8 ++------ .../product/advertising-product--single-product.html.twig | 1 - 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/infinite.theme b/infinite.theme index 6b786f20..b8054697 100644 --- a/infinite.theme +++ b/infinite.theme @@ -197,7 +197,8 @@ function infinite_preprocess_advertising_product(&$variables) { ->setAttribute('data-price', $product->product_price->value) ->setAttribute('data-currency', $product->product_currency->value) ->setAttribute('data-uuid', $product->uuid->value) - ->setAttribute('data-product-id', $product->product_id->value); + ->setAttribute('data-product-id', $product->product_id->value) + ->setAttribute('data-sold-out', (string)$product->product_sold_out->value === "1" ? 'true' : 'false'); $tracking_url = $product->product_url->uri; // This is needed only for tracdelight products @@ -226,10 +227,9 @@ function infinite_preprocess_advertising_product(&$variables) { if($price < $original_price){ $variables['show_strikethrough_price'] = TRUE; } - $variables['tracking_url'] = $tracking_url; - $data_attributes->setAttribute('data-external-url', $variables['tracking_url']); } - + $variables['tracking_url'] = $tracking_url; + $data_attributes->setAttribute('data-external-url', $variables['tracking_url']); $provider = explode("_", $product->product_provider->value); $data_attributes->setAttribute('data-provider', $provider[0]); diff --git a/js/infinite/views/products/product-view.js b/js/infinite/views/products/product-view.js index 7f7da82e..9ba6fb2b 100644 --- a/js/infinite/views/products/product-view.js +++ b/js/infinite/views/products/product-view.js @@ -9,11 +9,6 @@ initialize: function (pOptions) { BaseView.prototype.initialize.call(this, pOptions); - if (this.$el.hasClass('item-product--sold-out')) { - this.model.set('disabled', true); - return; - } - this.delegateInview(); this.addListener(); this.createModel(); @@ -198,7 +193,8 @@ brand: this.model.get('brand'), provider: this.model.get('provider'), productCategory: this.model.get('productCategory'), - containerType: this.model.get('containerType') || '' + containerType: this.model.get('containerType') || '', + soldOut: this.$el.attr('data-sold-out') === 'true' }; if (this.model.has('productIndex')) { diff --git a/templates/product/advertising-product--single-product.html.twig b/templates/product/advertising-product--single-product.html.twig index 0c24b07f..410a3163 100644 --- a/templates/product/advertising-product--single-product.html.twig +++ b/templates/product/advertising-product--single-product.html.twig @@ -32,7 +32,6 @@ {% if sold_out %} {% set attributes = attributes.addClass('item-product--sold-out') %} - {% set data_attributes = data_attributes.removeAttribute('data-external-url') %} {% endif %} {% if content.field_product_category_txt | render is not empty %}