Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

track sold out products INREL-3676 #101

Open
wants to merge 1 commit into
base: 8.x-3.x-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions infinite.theme
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we leave it clean without transforming the data? Something like: ->setAttribute('data-sold-out', (string)$product->product_sold_out->value


$tracking_url = $product->product_url->uri;
// This is needed only for tracdelight products
Expand Down Expand Up @@ -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]);
Expand Down
8 changes: 2 additions & 6 deletions js/infinite/views/products/product-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
initialize: function (pOptions) {
BaseView.prototype.initialize.call(this, pOptions);

if (this.$el.hasClass('item-product--sold-out')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this has to be removed. Can you clarify?

this.model.set('disabled', true);
return;
}

this.delegateInview();
this.addListener();
this.createModel();
Expand Down Expand Up @@ -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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of getting the data here we could set the data on the model directly (and also transform data there):
this.model.set('sold-out', this.$el.data('sold-out') === 1 ? 'true' : 'false'). See Line 85.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afterwards it's just a simple soldOut: this.model.get('sold-out')

};

if (this.model.has('productIndex')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down