Skip to content

Commit

Permalink
Merge pull request #113 from findify/feature/product-batching
Browse files Browse the repository at this point in the history
product batching new files
  • Loading branch information
wolff95 authored Sep 16, 2024
2 parents 66e28ff + a606582 commit 559f259
Show file tree
Hide file tree
Showing 7 changed files with 250 additions and 70 deletions.
20 changes: 20 additions & 0 deletions sections/findify-product-card-old.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{%- liquid
assign page_url = content_for_header | split: '"pageurl":"' | last | split: '"' | first | split: request.host | last | replace: "\/", "/" | replace: "\u0026", "&"
assign findify_product = page_url | split: "sections=findify-product-card&" | last
include 'findify-product-card-params'
-%}

{%- render 'findify-product-card'
, id: id
, class: class
, widget: widget
, page: page
, product_url: product_url
, current_variant: current_variant,
, product: product,
, showHoverImage: showHoverImage
, brand: brand,
, reviews: reviews
, reviews_count: reviews_count
, selected_variant_id: selected_variant_id
-%}
88 changes: 20 additions & 68 deletions sections/findify-product-card.liquid
Original file line number Diff line number Diff line change
@@ -1,68 +1,20 @@
{%- include 'findify-product-card-connector' -%}

<div
id="{{ id }}"
product-id="product-{{ id }}"
class="findify-product-card {{ class }} {{ widget }}_{{ id }}"
{% if page != blank %}
page="{{ page }}"
{% endif %}>
<a class="findify-product-link" href={{ product_url }}>
<div class='findify-product-card__image'>
<div class='findify-image-container'>
{% if current_variant.featured_media != null %}
{% render 'findify-product-image'
, media: current_variant.featured_media
, class: 'first-image' %}
{% else %}
{% render 'findify-product-image'
, media: product.featured_media
, class: 'first-image' %}
{% endif %}
{%- if product.media[1] != null and showHoverImage == 'true' -%}
{% render 'findify-product-image'
, media: product.media[1]
, class: 'findify-second-image' %}
{%- endif -%}

{% comment %} <img width="100%" height="100%" class="findify-product-swatch-image" hidden /> {% endcomment %}
</div>
</div>
<div class="content-wrapper">
{% if brand %}
<div class="findify-product-brand">{{ brand }}</div>
{% endif %}

{% comment %} {% render 'findify-product-swatches-color',
product_url: product_url,
product: product,
colormap: colormap,
variants: variants,
%} {% endcomment %}


<div class='findify-product-title findify-cut-text'>
<label>{{ product.title }}</label>
</div>
{% render 'findify-product-price'
, product: product %}
{% if reviews %}
{% render 'findify-rating'
, value: reviews
, count: reviews_count %}
{% endif %}
</div>
</a>


<script>
/* IMPORTANT: Script tags are executed within this file element. */
const id = "{{id}}";
const selected_variant_id = "{{selected_variant_id}}";
const widget = "{{widget}}";
const page = "{{page}}"
initOnProductCardClick(id, page, { widget, selected_variant_id });
</script>

</div>
{%- liquid
assign page_url = content_for_header | split: '"pageurl":"' | last | split: '"' | first | split: request.host | last | replace: "\/", "/" | replace: "\u0026", "&"
assign findify_product = page_url | split: "sections=findify-product-card&" | last
include 'findify-product-card-params'
-%}

{%- render 'findify-product-card'
, id: id
, class: class
, widget: widget
, page: page
, product_url: product_url
, current_variant: current_variant,
, product: product,
, showHoverImage: showHoverImage
, brand: brand,
, reviews: reviews
, reviews_count: reviews_count
, selected_variant_id: selected_variant_id
-%}
25 changes: 25 additions & 0 deletions sections/findify-product-list.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{%- liquid
assign page_url = content_for_header | split: '"pageurl":"' | last | split: '"' | first | split: request.host | last | replace: "\/", "/" | replace: "\u0026", "&"
assign findify_product_list_params = page_url | split: "sections=findify-product-list&" | last | url_decode | replace: 'ç', '&'
assign findify_product_list = findify_product_list_params | split: "§"
-%}

<div>
{% for findify_product in findify_product_list %}
{% include 'findify-product-card-params' %}
{%- render 'findify-product-card'
, id: id
, class: class
, widget: widget
, page: page
, product_url: product_url
, current_variant: current_variant,
, product: product,
, showHoverImage: showHoverImage
, brand: brand,
, reviews: reviews
, reviews_count: reviews_count
, selected_variant_id: selected_variant_id
-%}
{% endfor %}
</div>
4 changes: 4 additions & 0 deletions sections/findify-product.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% liquid
assign page_url = content_for_header | split: '"pageurl":"' | last | split: '"' | first | split: request.host | last | replace: "\/", "/" | replace: "\u0026", "&" | replace: '%7C', '|' | replace: '%20', ' '
assign query_parameters = page_url | split: "sections=findify-product-list&" | last
%}
4 changes: 2 additions & 2 deletions snippets/findify-product-card-connector.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
if query_parameters contains "showHoverImage="
assign showHoverImage = query_parameters | split: "showHoverImage=" | last | split: "&" | first
endif

# Product metadata
assign colormap = query_parameters | split: "colormap=" | last | split: "&" | first | split: ';'
assign position = query_parameters | split: "position=" | last | split: "&" | first
Expand Down Expand Up @@ -113,4 +113,4 @@
# assign example_field = custom_fields | split: "example_field=" | last | split: "~" | first | url_decode
# endif
endif
-%}
-%}
113 changes: 113 additions & 0 deletions snippets/findify-product-card-params.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{%- liquid
# Product template settings
if findify_product contains "class="
assign class = findify_product | split: "class=" | last | split: "&" | first
endif
assign widget = findify_product | split: "widget=" | last | split: "&" | first

# Product Collection Slot
if findify_product contains "collectionSlot="
assign collection_slot = findify_product | split: "collectionSlot=" | last | split: "&" | first
endif
# Product Show Hover Image
if findify_product contains "showHoverImage="
assign showHoverImage = findify_product | split: "showHoverImage=" | last | split: "&" | first
endif

# Product metadata
assign colormap = findify_product | split: "colormap=" | last | split: "&" | first | split: ';'
assign position = findify_product | split: "position=" | last | split: "&" | first
assign page = page_url | split: 'page=' | last | split: '&' | first | plus: 0

if findify_product contains "handler="
assign handler = findify_product | split: "handler=" | last | split: "&" | first | url_decode
assign product = all_products[handler]
endif

# Product Findify variants fields
if findify_product contains "variants="
assign variants_parameters = findify_product | split: "variants=" | last | split: "&" | first
assign variants = variants_parameters | url_decode | split: "^"
# for variant in variants and then parse and assign values

# Variants may have same property as products, and so "regexes" may conflict picking wrong values, removing variants from here
assign variants_whole_block = "variants=" | append: variants_parameters
assign findify_product_splitted_by_variants = findify_product | split: variants_whole_block
assign findify_product_leftside = findify_product_splitted_by_variants[0]
assign findify_product_rightside = findify_product_splitted_by_variants[1] | replace_first: "&", ""
assign findify_product = findify_product_leftside | append: findify_product_rightside
endif

# Product Findify fields
if findify_product contains "availability="
assign availability = findify_product | split: "availability=" | last | split: "&" | first
endif
if findify_product contains "color="
assign colors = findify_product | split: "color=" | last | split: "&" | first | url_decode | split: ";"
endif
if findify_product contains "selected_variant_id="
assign selected_variant_id = findify_product | split: "selected_variant_id=" | last | split: "&" | first
for variant in product.variants
assign current_variant_id_number = selected_variant_id | plus: 0
if variant.id == current_variant_id_number
assign current_variant = variant
endif
endfor
endif
if findify_product contains "item_group_id="
assign item_group_id = findify_product | split: "item_group_id=" | last | split: "&" | first
endif
if findify_product contains "id="
assign id = findify_product | split: "id=" | last | split: "&" | first
endif
if findify_product contains "category="
assign category = findify_product | split: "category=" | last | split: "&" | first | url_decode
endif
if findify_product contains "price="
assign price = findify_product | split: "price=" | last | split: "&" | first
endif
# Manipulating product.url to add variant and collection awareness with locale awareness
if product.url contains "?"
assign product_url_dto = product.url | append: "&variant=" | append: selected_variant_id
else
assign product_url_dto = product.url | append: "?variant=" | append: selected_variant_id
endif
if product_url_dto contains routes.root_url and routes.root_url != '/'
assign product_url_dto = product_url_dto | replace: routes.root_url, ''
endif
assign product_url = routes.root_url | append: collection_slot | append: product_url_dto | replace: '//', '/'
if findify_product contains "quantity="
assign quantity = findify_product | split: "quantity=" | last | split: "&" | first
endif
if findify_product contains "size="
assign sizes = findify_product | split: "size=" | last | split: "&" | first | split: "^" | url_decode
endif
if findify_product contains "sku="
assign sku = findify_product | split: "sku=" | last | split: "&" | first
endif
if findify_product contains "tags="
assign tags = findify_product | split: "tags=" | last | split: "&" | first
endif
if findify_product contains "stickers="
assign stickers = findify_product | split: "stickers=" | last | split: "&" | first
endif
if findify_product contains "reviews.count="
assign reviews_count = findify_product | split: "reviews.count=" | last | split: "&" | first
endif
if findify_product contains "reviews.average_score="
assign reviews = findify_product | split: "reviews.average_score=" | last | split: "&" | first
endif
if findify_product contains "brand="
assign brand = findify_product | split: "brand=" | last | split: "&" | first | url_decode
endif
if findify_product contains "title="
assign title = findify_product | split: "title=" | last | split: "&" | first | url_decode
endif
# Product Findify custom fields
if findify_product contains "custom_fields="
assign custom_fields = findify_product | split: "custom_fields=" | last | split: "&" | first
# if custom_fields contains "example_field"
# assign example_field = custom_fields | split: "example_field=" | last | split: "~" | first | url_decode
# endif
endif
-%}
66 changes: 66 additions & 0 deletions snippets/findify-product-card.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<div
id="{{ id }}"
product-id="product-{{ id }}"
class="findify-product-card {{ class }} {{ widget }}_{{ id }}"
{% if page != blank %}
page="{{ page }}"
{% endif %}>
<a class="findify-product-link" href={{ product_url }}>
<div class='findify-product-card__image'>
<div class='findify-image-container'>
{% if current_variant.featured_media != null %}
{% render 'findify-product-image'
, media: current_variant.featured_media
, class: 'first-image' %}
{% else %}
{% render 'findify-product-image'
, media: product.featured_media
, class: 'first-image' %}
{% endif %}
{%- if product.media[1] != null and showHoverImage == 'true' -%}
{% render 'findify-product-image'
, media: product.media[1]
, class: 'findify-second-image' %}
{%- endif -%}

{% comment %} <img width="100%" height="100%" class="findify-product-swatch-image" hidden /> {% endcomment %}
</div>
</div>
<div class="content-wrapper">
{% if brand %}
<div class="findify-product-brand">{{ brand }}</div>
{% endif %}

{% comment %} {% render 'findify-product-swatches-color',
product_url: product_url,
product: product,
colormap: colormap,
variants: variants,
%} {% endcomment %}


<div class='findify-product-title findify-cut-text'>
<label>{{ product.title }}</label>
</div>
{% render 'findify-product-price'
, product: product %}
{% if reviews %}
{% render 'findify-rating'
, value: reviews
, count: reviews_count %}
{% endif %}
</div>
</a>


<script>
/* IMPORTANT: Script tags are executed within this file element. */
const id = "{{id}}";
const selected_variant_id = "{{selected_variant_id}}";
const widget = "{{widget}}";
const page = "{{page}}"
initOnProductCardClick(id, page, { widget, selected_variant_id });
</script>

</div>

0 comments on commit 559f259

Please sign in to comment.