From 2a67aae9aebf7b5d16914854a8343a5b1d7f368d Mon Sep 17 00:00:00 2001 From: Axel Date: Thu, 5 Nov 2026 05:40:58 +0800 Subject: [PATCH] initial commit --- sections/main-product.liquid | 685 +++++++++++++++++++++++++++++++++++ snippets/product-info.liquid | 352 ++++++++++++++++++ 2 files changed, 1037 insertions(+) create mode 100644 sections/main-product.liquid create mode 100644 snippets/product-info.liquid diff --git a/sections/main-product.liquid b/sections/main-product.liquid new file mode 100644 index 0000000..b908b34 --- /dev/null +++ b/sections/main-product.liquid @@ -0,0 +1,685 @@ +{%- unless template.suffix contains 'quick-buy' -%} + + +
+ {%- if section.settings.show_sticky_add_to_cart and product.available -%} + {%- render 'product-sticky-form', product: product -%} + {%- endif -%} + +
+ + + +
+ {%- render 'product-media', product: product -%} + {%- render 'product-info', product: product, update_url: true -%} +
+
+
+{%- else -%} + {%- comment -%} + The quick shop HTML being very different, we render it here. On mobile and tablet/desktop, the product renders also + quite differently, as it is in a drawer on tablet/desktop, and a popover on mobile. + {%- endcomment -%} + + {%- capture quick_buy_product_info -%} +
+ {%- assign featured_media = product.selected_or_first_available_variant.featured_media | default: product.featured_media -%} + + {%- if template.suffix == 'quick-buy-drawer' -%} + {{- featured_media | image_url: width: featured_media.width | image_tag: loading: 'lazy', sizes: '114px', widths: '114,228,342', class: 'quick-buy-product__image' -}} + {%- else -%} + {{- featured_media | image_url: width: featured_media.width | image_tag: loading: 'lazy', sizes: '65px', widths: '65,130,195', class: 'quick-buy-product__image' -}} + {%- endif -%} + +
+ + {%- if section.settings.show_vendor -%} + {%- assign vendor_handle = product.vendor | handle -%} + {%- assign collection_for_vendor = collections[vendor_handle] -%} + + {%- unless collection_for_vendor.empty? -%} + {{ product.vendor }} + {%- else -%} + {{ product.vendor }} + {%- endunless -%} + {%- endif -%} + + {{ product.title }} + + {% liquid + # start Yagi app code + assign target = product.selected_or_first_available_variant + assign variant_price = product.selected_or_first_available_variant.price + assign variant_compare_at_price = product.selected_or_first_available_variant.compare_at_price + + assign active_discount = true + + assign empty_array = "" | split: "" + assign dormant_discounts = shop.metafields.app--168074346497.dormant_discounts.value | default: empty_array + assign target_discount_id = product.metafields.app--168074346497.applied_discount_id.value + for dormant_discount in dormant_discounts + if dormant_discount == target_discount_id + assign active_discount = false + endif + endfor + + if active_discount + assign variant_price = target.metafields.app--168074346497.auto_discounted_price.value | default: target.price + + if target.metafields.app--168074346497.discount_type.value != nil and target.metafields.app--168074346497.discount_type.value != "fixed" and product.metafields.app--168074346497.discount_percentage.value > 0.01 + assign deducted_percentage = 1.0 | minus: product.metafields.app--168074346497.discount_percentage.value + + if target.metafields.app--168074346497.discount_percentage.value > 0.01 + assign deducted_percentage = 1.0 | minus: target.metafields.app--168074346497.discount_percentage.value + endif + + assign variant_price = target.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil + + assign variant_compare_at_price = target.price + + if target.compare_at_price > variant_compare_at_price + assign variant_compare_at_price = target.compare_at_price + endif + endif + + if variant_price < target.price and variant_compare_at_price == blank + assign variant_compare_at_price = target.price + endif + endif + # end Yagi app code + %} +
+
+ {%- if variant_compare_at_price > variant_price -%} + + {{ 'product.general.sale_price' | t }} + + {%- if settings.currency_code_enabled -%} + {{- variant_price | money_with_currency -}} + {%- else -%} + {{- variant_price | money -}} + {%- endif -%} + + + + {{ 'product.general.regular_price' | t }} + + {%- if settings.currency_code_enabled -%} + {{- variant_compare_at_price | money_with_currency -}} + {%- else -%} + {{- variant_compare_at_price | money -}} + {%- endif -%} + + {%- else -%} + + {{ 'product.general.sale_price' | t }} + + {%- if settings.currency_code_enabled -%} + {{- variant_price | money_with_currency -}} + {%- else -%} + {{- variant_price | money -}} + {%- endif -%} + + {%- endif -%} + + {%- if product.selected_or_first_available_variant.unit_price_measurement -%} +
+
+ {{ product.selected_or_first_available_variant.unit_price | money }} + / + + {%- if product.selected_or_first_available_variant.unit_price_measurement.reference_value != 1 -%} + {{ product.selected_or_first_available_variant.unit_price_measurement.reference_value }} + {%- endif -%} + + {{ product.selected_or_first_available_variant.unit_price_measurement.reference_unit }} +
+
+ {%- endif -%} +
+ + {%- if template.suffix == 'quick-buy-popover' -%} + {{ 'product.general.view_details' | t }} + {%- endif -%} +
+ + {%- if section.settings.show_taxes_included -%} + {%- if cart.taxes_included or shop.shipping_policy.body != blank -%} +

+ {%- if cart.taxes_included -%} + {{ 'product.general.include_taxes' | t }} + {%- endif -%} + + {%- if shop.shipping_policy.body != blank -%} + {{ 'product.general.shipping_policy_html' | t: link: shop.shipping_policy.url }} + {%- endif -%} +

+ {%- endif -%} + {%- endif -%} +
+
+
+ {%- endcapture -%} + + {%- if template.suffix == 'quick-buy-drawer' -%} + + + + + +
+

{{ 'product.form.choose_options' | t }}

+ + +
+ +
+ {{- quick_buy_product_info -}} + {%- render 'product-form', product: product -%} +
+
+ {%- elsif template.suffix == 'quick-buy-popover' -%} + + + +
+ {{- quick_buy_product_info -}} + + +
+ +
+ {%- render 'product-form', product: product -%} +
+
+ {%- endif -%} +{%- endunless -%} + +{% schema %} +{ + "name": "Product page", + "class": "shopify-section--main-product", + "blocks": [ + { + "type": "@app" + }, + { + "type": "variant_picker", + "name": "Variant picker", + "limit": 1, + "settings": [ + { + "type": "checkbox", + "id": "hide_sold_out_variants", + "label": "Hide sold out variants", + "default": false + }, + { + "type": "select", + "id": "selector_mode", + "label": "Selector type", + "options": [ + { + "value": "block", + "label": "Block" + }, + { + "value": "dropdown", + "label": "Dropdown" + } + ], + "default": "block" + }, + { + "type": "select", + "id": "color_mode", + "label": "Color selector type", + "info": "Enable [swatches](https://help.shopify.com/en/manual/online-store/themes/theme-structure/theme-settings#options-with-swatches) on product options.", + "options": [ + { + "value": "swatch", + "label": "Swatch" + }, + { + "value": "none", + "label": "None" + } + ], + "default": "swatch" + }, + { + "type": "text", + "id": "variant_image_options", + "label": "Show variant image for options" + }, + { + "type": "page", + "id": "size_chart_page", + "label": "Size chart page", + "info": "Feature a page for size option" + } + ] + }, + { + "type": "quantity_selector", + "name": "Quantity selector", + "limit": 1 + }, + { + "type": "buy_buttons", + "name": "Buy buttons", + "limit": 1, + "settings": [ + { + "type": "checkbox", + "id": "show_payment_button", + "label": "Show dynamic checkout button", + "info": "Each customer will see their preferred payment method from those available on your store, such as PayPal or Apple Pay. [Learn more](https://help.shopify.com/manual/using-themes/change-the-layout/dynamic-checkout)", + "default": true + }, + { + "type": "checkbox", + "id": "show_gift_card_recipient", + "label": "Show recipient information form for gift card products", + "info": "Gift card products can optionally be sent directly to a recipient along with a personal message. [Learn more](https://help.shopify.com/manual/online-store/themes/customizing-themes/add-gift-card-recipient-fields)", + "default": true + }, + { + "type": "color", + "id": "atc_button_background", + "label": "Add to cart background", + "default": "rgba(0,0,0,0)" + }, + { + "type": "color", + "id": "atc_button_text_color", + "label": "Add to cart color", + "default": "rgba(0,0,0,0)" + }, + { + "type": "color", + "id": "buy_now_button_background", + "label": "Buy now background", + "default": "rgba(0,0,0,0)" + }, + { + "type": "color", + "id": "buy_now_button_text_color", + "label": "Buy now color", + "default": "rgba(0,0,0,0)" + } + ] + }, + { + "type": "description", + "name": "Description", + "limit": 1 + }, + { + "type": "inventory", + "name": "Inventory", + "limit": 1, + "settings": [ + { + "type": "range", + "id": "low_inventory_threshold", + "label": "Low inventory threshold", + "info": "Use low stock color when quantity is below the threshold. Choose 0 to always show in stock.", + "min": 0, + "max": 100, + "step": 1, + "default": 0 + } + ] + }, + { + "type": "text", + "name": "Text", + "settings": [ + { + "type": "richtext", + "id": "text", + "label": "Text" + } + ] + }, + { + "type": "image", + "name": "Image", + "settings": [ + { + "type": "image_picker", + "id": "image", + "label": "Image" + }, + { + "type": "select", + "id": "image_alignment", + "label": "Alignment", + "options": [ + { + "value": "left", + "label": "Left" + }, + { + "value": "center", + "label": "Center" + }, + { + "value": "right", + "label": "Right" + } + ], + "default": "left" + }, + { + "type": "range", + "id": "image_width", + "min": 50, + "max": 500, + "step": 10, + "unit": "px", + "label": "Width", + "default": 150 + } + ] + }, + { + "type": "button", + "name": "Button", + "settings": [ + { + "type": "paragraph", + "content": "Create link to your contact page, external marketplace..." + }, + { + "type": "url", + "id": "link", + "label": "Link" + }, + { + "type": "text", + "id": "text", + "label": "Text" + }, + { + "type": "checkbox", + "id": "stretch", + "label": "Stretch button", + "default": true + }, + { + "type": "color", + "id": "background", + "label": "Background", + "default": "rgba(0,0,0,0)" + }, + { + "type": "color", + "id": "text_color", + "label": "Text color", + "default": "rgba(0,0,0,0)" + } + ] + }, + { + "type": "liquid", + "name": "Custom Liquid", + "settings": [ + { + "type": "liquid", + "id": "liquid", + "label": "Liquid", + "info": "Add app snippets or other Liquid code to create advanced customizations." + } + ] + }, + { + "type": "line_item_property", + "name": "Line item property", + "settings": [ + { + "type": "paragraph", + "content": "Line item properties are used to collect customization information for an item added to the cart." + }, + { + "type": "text", + "id": "label", + "label": "Label", + "default": "Your label" + }, + { + "type": "select", + "id": "type", + "label": "Type", + "options": [ + { + "value": "text", + "label": "Text" + }, + { + "value": "checkbox", + "label": "Checkbox" + } + ], + "default": "text" + }, + { + "type": "header", + "content": "Text", + "info": "Only applicable for line item property of type Text." + }, + { + "type": "checkbox", + "id": "required", + "label": "Required", + "default": false + }, + { + "type": "checkbox", + "id": "allow_long_text", + "label": "Allow long text", + "default": false + }, + { + "type": "header", + "content": "Checkbox", + "info": "Only applicable for line item property of type Checkbox." + }, + { + "type": "text", + "id": "checked_value", + "label": "Checked value", + "default": "Yes" + }, + { + "type": "text", + "id": "unchecked_value", + "label": "Unchecked value", + "default": "No" + } + ] + } + ], + "settings": [ + { + "type": "checkbox", + "id": "show_vendor", + "label": "Show vendor", + "default": true + }, + { + "type": "checkbox", + "id": "show_sku", + "label": "Show SKU", + "default": false + }, + { + "type": "checkbox", + "id": "show_taxes_included", + "label": "Show taxes included", + "default": false + }, + { + "type": "checkbox", + "id": "show_product_rating", + "label": "Show product rating", + "info": "To display a rating, add a product rating app. [Learn more](https://help.shopify.com/en/manual/products/product-reviews/installation)", + "default": false + }, + { + "type": "checkbox", + "id": "show_sticky_add_to_cart", + "label": "Show sticky add to cart", + "info": "Will be hidden if no Buy buttons block is added onto the page.", + "default": true + }, + { + "type": "checkbox", + "id": "show_share_buttons", + "label": "Show share buttons", + "default": true + }, + { + "type": "page", + "id": "help_page", + "label": "Help page", + "info": "Feature a page to help your customers" + }, + { + "type": "header", + "content": "Media" + }, + { + "type": "paragraph", + "content": "Learn more about [media types](https://help.shopify.com/en/manual/products/product-media)" + }, + { + "type": "checkbox", + "id": "enable_video_autoplay", + "label": "Enable video autoplay", + "info": "Video are muted automatically to allow autoplay", + "default": true + }, + { + "type": "checkbox", + "id": "enable_video_looping", + "label": "Enable video looping", + "default": false + }, + { + "type": "checkbox", + "id": "enable_image_zoom", + "label": "Enable image zoom", + "info": "Zoom does not show video nor 3D models.", + "default": true + }, + { + "type": "checkbox", + "id": "show_thumbnails_on_mobile", + "label": "Show thumbnails on mobile", + "default": false + }, + { + "type": "select", + "id": "desktop_thumbnails_position", + "label": "Desktop thumbnails position", + "options": [ + { + "value": "left", + "label": "Left" + }, + { + "value": "bottom", + "label": "Bottom" + } + ], + "default": "bottom" + }, + { + "type": "select", + "id": "transition_effect", + "label": "Transition effect", + "options": [ + { + "value": "slide", + "label": "Slide" + }, + { + "value": "fade", + "label": "Fade" + } + ], + "default": "slide" + } + ] +} +{% endschema %} diff --git a/snippets/product-info.liquid b/snippets/product-info.liquid new file mode 100644 index 0000000..0b0d096 --- /dev/null +++ b/snippets/product-info.liquid @@ -0,0 +1,352 @@ +{%- capture product_form_id -%}product-form-{{ section.id }}-{{ product.id }}{%- endcapture -%} + +
+ + + {%- if section.settings.show_vendor -%} +

+ {%- assign vendor_handle = product.vendor | handle -%} + {%- assign vendor_collection = collections[vendor_handle] -%} + + {%- if vendor_collection != blank -%} + {{ product.vendor }} + {%- else -%} + {{ product.vendor }} + {%- endif -%} +

+ {%- endif -%} + + {% unless featured %} +

{{ product.title }}

+ {% else %} +

+ {{ product.title }} +

+ {% endunless %} + + {% liquid + # start Yagi app code + assign target = product.selected_or_first_available_variant + assign variant_price = product.selected_or_first_available_variant.price + assign variant_compare_at_price = product.selected_or_first_available_variant.compare_at_price + + assign active_discount = true + + assign empty_array = "" | split: "" + assign dormant_discounts = shop.metafields.app--168074346497.dormant_discounts.value | default: empty_array + assign target_discount_id = product.metafields.app--168074346497.applied_discount_id.value + for dormant_discount in dormant_discounts + if dormant_discount == target_discount_id + assign active_discount = false + endif + endfor + + if active_discount + assign variant_price = target.metafields.app--168074346497.auto_discounted_price.value | default: target.price + + if target.metafields.app--168074346497.discount_type.value != nil and target.metafields.app--168074346497.discount_type.value != "fixed" and product.metafields.app--168074346497.discount_percentage.value > 0.01 + assign deducted_percentage = 1.0 | minus: product.metafields.app--168074346497.discount_percentage.value + + if target.metafields.app--168074346497.discount_percentage.value > 0.01 + assign deducted_percentage = 1.0 | minus: target.metafields.app--168074346497.discount_percentage.value + endif + + assign variant_price = target.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil + + assign variant_compare_at_price = target.price + + if target.compare_at_price > variant_compare_at_price + assign variant_compare_at_price = target.compare_at_price + endif + endif + + if variant_price < target.price and variant_compare_at_price == blank + assign variant_compare_at_price = target.price + endif + endif + # end Yagi app code + %} +
+
+ {%- if variant_compare_at_price > variant_price -%} + + {{ 'product.general.sale_price' | t }} + + + {%- if settings.currency_code_enabled -%} + {{- variant_price | money_with_currency -}} + {%- else -%} + {{- variant_price | money -}} + {%- endif -%} + + + + + {{ 'product.general.regular_price' | t }} + + + {%- if settings.currency_code_enabled -%} + {{- variant_compare_at_price | money_with_currency -}} + {%- else -%} + {{- variant_compare_at_price | money -}} + {%- endif -%} + + + {%- else -%} + + {{ 'product.general.sale_price' | t }} + + {%- if settings.currency_code_enabled -%} + {{- variant_price | money_with_currency -}} + {%- else -%} + {{- variant_price | money -}} + {%- endif -%} + + + {%- endif -%} + + {%- if product.selected_or_first_available_variant.unit_price_measurement -%} +
+
+ {{ product.selected_or_first_available_variant.unit_price | money }} + / + + {%- if product.selected_or_first_available_variant.unit_price_measurement.reference_value != 1 -%} + {{ product.selected_or_first_available_variant.unit_price_measurement.reference_value }} + {%- endif -%} + + {{ product.selected_or_first_available_variant.unit_price_measurement.reference_unit }} +
+
+ {%- endif -%} + +
+ {{ product.metafields.judgeme.badge }} +
+ +
+ + +
+ {%- unless product.selected_or_first_available_variant.available -%} + {{ 'collection.product.sold_out' | t }} + {%- elsif product.selected_or_first_available_variant.compare_at_price > product.selected_or_first_available_variant.price -%} + {%- if settings.discount_mode == 'percentage' -%} + {%- assign savings = product.selected_or_first_available_variant.compare_at_price | minus: product.selected_or_first_available_variant.price | times: 100.0 | divided_by: product.selected_or_first_available_variant.compare_at_price | round | append: '%' -%} + {%- else -%} + {%- capture savings -%}{{ product.selected_or_first_available_variant.compare_at_price | minus: product.selected_or_first_available_variant.price | money }}{%- endcapture -%} + {%- endif -%} + + {{ 'collection.product.discount_html' | t: savings: savings }} + {%- endunless -%} +
+
+
+ + {%- if section.settings.show_taxes_included -%} + {%- if cart.taxes_included or shop.shipping_policy.body != blank -%} +

+ {%- if cart.taxes_included -%} + {{ 'product.general.include_taxes' | t }} + {%- endif -%} + + {%- if shop.shipping_policy.body != blank -%} + {{ 'product.general.shipping_policy_html' | t: link: shop.shipping_policy.url }} + {%- endif -%} +

+ {%- endif -%} + {%- endif -%} + + + {%- assign product_installment_form_id = 'product-installment-form-' | append: section.id | append: '-' | append: product.id -%} + + {%- form 'product', product, id: product_installment_form_id -%} + + {{- form | payment_terms -}} + {%- endform -%} + + + {%- if section.settings.show_product_rating or section.settings.show_sku -%} +
+ {%- if section.settings.show_product_rating -%} + {%- render 'product-rating', product: product -%} + {%- render 'product-rating', product: product -%} + {%- endif -%} + + {%- if section.settings.show_sku -%} + + {{- 'product.general.sku' | t }} + {{ product.selected_or_first_available_variant.sku }} + + {%- endif -%} +
+ {%- endif -%} +
+ + {%- render 'product-form', product: product, update_url: update_url -%} + + {%- assign help_page = section.settings.help_page -%} + + {%- if section.settings.show_share_buttons or help_page != blank -%} +
+ {%- if section.settings.show_share_buttons -%} + + {%- endif -%} + + {%- if help_page != blank -%} + + + {%- endif -%} +
+ {%- endif -%} + + {%- if help_page != blank -%} + {%- comment -%}Drawer for tablet and higher{%- endcomment -%} + + + +
+

{{ help_page.title }}

+ + +
+ +
+
+ {{- help_page.content -}} +
+
+
+ + {%- comment -%}Popover for mobile{%- endcomment -%} + + {%- endif -%} +
+ + + + \ No newline at end of file