spz-atc
Handle the behavior of the add, buy now, and PayPal buttons.
布局
Usage
跳转到“Usage”- Specifies an addToCart button with the
role="addToCart"
attribute. - Specifies a buy now button with the
role="buyNow"
attribute. - Specifies a text of the button with the
role="content"
attribute.
<script id="atc-locale-json" type="application/json">
{
<!-- ... -->
}
</script>
<spz-atc
id="product-info-atc-"
class="product-atc product-info-block"
layout="container"
locale-map="atc-locale-json"
variant="#product-info-variants"
quantity="#product-info-quantity"
product-id=""
variant-id=""
>
<button type="button"
role="addToCart"
class="button-primary"
data-track="click"
data-track-content="add_to_cart"
data-track-source="add_to_cart"
>
<span role="content" class="fade-in-opacity">Add to cart</span>
</button>
<button
role="buyNow"
type="button"
class="button-secondary"
data-track="click"
data-track-content="checkout"
data-track-source="buy_now"
>
<span role="content" class="fade-in-opacity">Buy now</span>
</button>
</spz-atc>
Attributes
跳转到“Attributes”variant
跳转到“variant”A spz-variant
id. For example variant="#product-info-variants"
.
quantity
跳转到“quantity”A spz-quantity
id. For example quantity="#product-info-quantity"
.
product-id
跳转到“product-id”A product id.
variant-id
跳转到“variant-id”A variant id that is selected by default.
locale-map
跳转到“locale-map”Specify the text to be prompted in different states.
status
跳转到“status”Indicates the state of the current variant selection. It has four values:
Status | Description |
---|---|
unselect | Indicates that the variant of the product isn’t selected |
available | Indicates that the currently selected variant is available for purchase |
soldout | Indicates that the currently selected variant is sold out |
unavailable | Indicates that the currently selected variant isn’t exist |
Actions
跳转到“Actions”update
跳转到“update”To update the status
of the element, no parameters required.
check
跳转到“check”To check selected variants. If no variant is selected, a message is displayed. No parameters required.
Events
跳转到“Events”event object data
跳转到“event object data”{
"quantity": 1,
"variants": {
"product": {
// ...
},
"productId": "c222663d-88ab-46bd-a21a-9584691aa744",
"variant": {
// ...
},
"originData": {
// ...
}
}
}
atcSuccess
跳转到“atcSuccess”Be automatically triggered when added to cart successfully.