diff --git a/snippets/card-product.liquid b/snippets/card-product.liquid
index 7bb9705..f6286d0 100644
--- a/snippets/card-product.liquid
+++ b/snippets/card-product.liquid
@@ -284,6 +284,63 @@
+ {% liquid
+ assign card_product_compare_at_price = card_product.compare_at_price
+ assign card_product_price = card_product.price
+
+ comment
+ start Yagi app code
+ endcomment
+ assign public_or_tags_matched = true
+
+ if product.metafields.app--168074346497.segment_tags.value.size > 0
+ assign public_or_tags_matched = false
+ endif
+
+ for etag in product.metafields.app--168074346497.segment_tags.value
+ if customer.tags contains etag
+ assign public_or_tags_matched = true
+ break
+ endif
+ endfor
+
+ if public_or_tags_matched
+ assign card_product_price = card_product.metafields.app--168074346497.min_auto_discounted_price.value | default: card_product.price
+
+ if card_product.metafields.app--168074346497.discount_percentage.value > 0.01
+ assign deducted_percentage = 1.0 | minus: card_product.metafields.app--168074346497.discount_percentage.value
+
+ assign card_product_price = card_product.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil
+
+ assign card_product_compare_at_price = card_product.price
+
+ if card_product.compare_at_price > card_product_compare_at_price
+ assign card_product_compare_at_price = card_product.compare_at_price
+ endif
+ endif
+
+ if shop.metafields.app--168074346497.discount_percentage.value > 0.005
+ assign discount_percentage = shop.metafields.app--168074346497.discount_percentage.value | times: 1.0
+ assign deducted_percentage = 1.0 | minus: discount_percentage
+
+ assign card_product_price = card_product.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil
+
+ assign card_product_compare_at_price = card_product.price
+
+ if card_product.compare_at_price > card_product_compare_at_price
+ assign card_product_compare_at_price = card_product.compare_at_price
+ endif
+ endif
+
+ if card_product_price < card_product.price and card_product_compare_at_price == blank
+ assign card_product_compare_at_price = card_product.price
+ endif
+ endif
+
+ comment
+ end Yagi app code
+ endcomment
+ %}
{%- if card_product.available == false -%}
{% unless show_sold_out_badge %}
{% endunless %}
- {%- elsif card_product.compare_at_price > card_product.price
+ {%- elsif card_product_compare_at_price > card_product_price
and card_product.available
and show_sale_badge == false
-%}
{% if settings.dbtfy_discount_saved and section.settings.custom_badge_label == blank %}
- {% liquid
- assign card_product_compare_at_price = card_product.compare_at_price
- assign card_product_price = card_product.price
-
- comment
- start Yagi app code
- endcomment
- assign public_or_tags_matched = true
-
- if product.metafields.app--168074346497.segment_tags.value.size > 0
- assign public_or_tags_matched = false
- endif
-
- for etag in product.metafields.app--168074346497.segment_tags.value
- if customer.tags contains etag
- assign public_or_tags_matched = true
- break
- endif
- endfor
-
- if public_or_tags_matched
- assign card_product_price = card_product.metafields.app--168074346497.min_auto_discounted_price.value | default: card_product.price
-
- if card_product.metafields.app--168074346497.discount_percentage.value > 0.01
- assign deducted_percentage = 1.0 | minus: card_product.metafields.app--168074346497.discount_percentage.value
-
- assign card_product_price = card_product.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil
-
- assign card_product_compare_at_price = card_product.price
-
- if card_product.compare_at_price > card_product_compare_at_price
- assign card_product_compare_at_price = card_product.compare_at_price
- endif
- endif
-
- if shop.metafields.app--168074346497.discount_percentage.value > 0.005
- assign discount_percentage = shop.metafields.app--168074346497.discount_percentage.value | times: 1.0
- assign deducted_percentage = 1.0 | minus: discount_percentage
-
- assign card_product_price = card_product.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil
-
- assign card_product_compare_at_price = card_product.price
-
- if card_product.compare_at_price > card_product_compare_at_price
- assign card_product_compare_at_price = card_product.compare_at_price
- endif
- endif
-
- if card_product_price < card_product.price and card_product_compare_at_price == blank
- assign card_product_compare_at_price = card_product.price
- endif
- endif
-
- comment
- end Yagi app code
- endcomment
- %}
{% render 'dbtfy-discount-saved',
product_compare_price: card_product_compare_at_price,
product_price: card_product_price
@@ -878,7 +878,7 @@
{%- endif -%}
{% endunless %}
- {%- elsif card_product.compare_at_price > card_product.price
+ {%- elsif card_product_compare_at_price > card_product_price
and card_product.available
and show_sale_badge == false
-%}