first commit

This commit is contained in:
Axel
2026-04-30 03:13:31 +08:00
commit b9f58a20af
6 changed files with 2279 additions and 0 deletions
+173
View File
@@ -0,0 +1,173 @@
<!-- /snippets/product-buttons.liquid -->
{%- liquid
assign buybutton_setting = false
assign gift_card_recipient_feature_active = false
assign current_variant = product.selected_or_first_available_variant
if block.settings.enable_gift_card_recipient and product.gift_card?
assign gift_card_recipient_feature_active = true
endif
comment
Quick buy buttons are incompatable with gift card products and subscription products
endcomment
if block.settings.enable_payment_button and gift_card_recipient_feature_active == false
assign buybutton_setting = true
endif
if product.selling_plan_groups.size > 0
assign buybutton_setting = false
endif
-%}
<div class="product__block__buttons" style="--PB: {{ block.settings.padding_bottom }}px;" {{ block.shopify_attributes }} >
<div data-product-form-outer>
{% comment %} The [data-product-form] tag distinguishes the product form from upsell instant-add-buttons. {% endcomment %}
{%- form 'product', product, id: uniq_id, data-product-form: '', data-product-handle: product.handle -%}
{%- unless hidden -%}
<div class="product__form__inner" data-form-inner>
{% comment %}
Note: the gift card recipient form is controlled in Checkout and must contain these undocumented line item propeties:
* properties[__shopify_send_gift_card_to_recipient] - Hidden - Toggles the feature on/off in checkout, following properties have no effect without it
* properties[Recipient email] - The email of the gift card recipient
* properties[Recipient name] - The name of the gift card recipient
* properties[Message] - Shopify chose a highly generic name for the gift card message, this could easily conflict with an app or custom code
{% endcomment %}
{%- if gift_card_recipient_feature_active -%}
{%- render 'gift-card-recipient-form', product: product, form: form, section: section -%}
{%- endif -%}
<div class="product__submit" data-buttons-wrapper data-add-action-wrapper data-error-boundary>
<div data-error-display role='alert' class="add-action-errors"></div>
{%- assign button_text = 'products.product.add_to_cart' | t -%}
{%- if product.metafields.theme.preorder.value == true -%}
{% comment %} Add a line item property with 'Sale type: Pre-order' and make the button say 'Pre-order'{% endcomment %}
<input type="hidden" data-product-preorder name="properties[{{ 'products.product.sale_type' | t }}]" value="{{ 'products.product.pre_order' | t }}">
{%- assign button_text = 'products.product.pre_order' | t -%}
{%- endif -%}
{%- render 'sibling-color-as-line-prop' product: product -%}
{%- if current_variant == null -%}
{%- assign button_text = 'products.product.unavailable' | t -%}
{%- endif -%}
{%- if current_variant.available == false -%}
{%- assign button_text = 'products.product.sold_out' | t -%}
{%- endif -%}
<div class="product__submit__buttons{% if product.has_only_default_variant %} product__submit__buttons--clear{% endif %}">
<span class="sr-only" aria-live="polite" x-show="isLoading">
{{ 'products.product.adding_to_cart' | t }}
</span>
<span class="sr-only" aria-live="polite" x-show="isSuccess">
{{ 'products.product.added_to_cart' | t }}
</span>
<button
type="submit"
name="add"
class="btn--outline btn--full btn--primary btn--add-to-cart"
data-add-to-cart
{% comment %} Explicitly add aria label so that button text isn't read out in screen readers in uppercase {% endcomment %}
aria-label="{{ button_text }}"
:class="{
'has-success': isSuccess,
'loading': isLoading
}"
{% unless current_variant.available %} disabled="disabled" {% endunless %}
>
<span class="btn-state-ready flex justify-center">
<span data-add-to-cart-text>
{{ button_text }}
</span>
{% if current_variant %}
{% liquid
comment
start Yagi app code
endcomment
assign current_variant_price = current_variant.price
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 current_variant_price = current_variant.metafields.app--168074346497.auto_discounted_price.value | default: current_variant.price
if current_variant.metafields.app--168074346497.discount_type.value != nil and current_variant.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 current_variant.metafields.app--168074346497.discount_percentage.value > 0.01
assign deducted_percentage = 1.0 | minus: current_variant.metafields.app--168074346497.discount_percentage.value
endif
assign current_variant_price = current_variant.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil
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 current_variant_price = current_variant.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil
endif
endif
comment
end Yagi app code
endcomment
%}
<span class="cta__dot opacity-50">•</span>
<span
data-button-price
{% if public_or_tags_matched %}data-yagi-matched{% endif %}
data-yagi-price="{{ current_variant_price }}"
x-text="$formatCurrency({{- current_variant_price -}} * Math.max(quantity, 1), { form: 'short', currency: '{{ cart.currency.iso_code }}' })"
>
{%- if settings.currency_code_enable -%}
{{ current_variant_price | money_with_currency }}
{%- else -%}
{{ current_variant_price | money }}
{%- endif -%}
</span>
{% endif %}
</span>
<span class="btn-state-loading">
<svg height="18" width="18" class="svg-loader">
<circle r="7" cx="9" cy="9" />
<circle stroke-dasharray="87.96459430051421 87.96459430051421" r="7" cx="9" cy="9" />
</svg>
</span>
<span class="btn-state-complete">&nbsp;</span>
</button>
{%- if buybutton_setting -%}
<div class="product__submit__quick">
{{ form | payment_button }}
</div>
{%- endif -%}
</div>
</div>
</div>
{% comment %} Shop pay split payment terms {% endcomment %}
<div class="shop-pay-terms">{{- form | payment_terms -}}</div>
{%- endunless -%}
{% comment %} The input with name="id" indicates the variant to add to cart {% endcomment %}
<input type="hidden" name="id" x-model.fill="variantId" value="{{ current_variant.id }}">
{%- endform -%}
</div>
</div>