Editing or deleting a Buy Button or embedded cart
Buy Buttons and carts are generated from the embed code that you add to your webpage's source HTML. If you want to change the appearance or behavior of a button or cart on a webpage, then you need to change the associated embed code.
删除一个购买按钮,嵌入式集合,或嵌入ded cart
To delete an existing Buy Button, collection, or embedded cart:
Open the source HTML of the webpage that contains the Buy Button, embedded collection, or embedded cart.
Delete the entire embed code from the source HTML. The embed code will look like the following code for a Buy Button:
- Save your changes.
Edit a Buy Button
To change the appearance or settings of an existing Buy Button, you must edit the contents of its maindiv
标签在嵌入代码出现在源HTML:
Each feature of the embedded Buy Button is controlled by a separate attribute in the maindiv
tag. You can add, remove, or update these attributes directly in the source HTML.
For example, if you want an existing Buy Button to direct the user to the product page instead of the checkout page:
Open the HTML of the page containing the Buy Button you want to change.
Find the
data-redirect_to
attribute within the maindiv
tag of the Buy Button's embed code:Change the value of the attribute to
product
:Save your changes.
A Buy Button's maindiv
tag has many attributes that you can edit:
Attribute | Value | Default |
---|---|---|
data-shop |
The myshopify domain (such asstorename.myshopify.com ) connected to the button. |
Your Shopify domain |
data-product_handle |
The featured product's handle, which is based on the product's title. Each of your products has a unique handle in Shopify. | The featured product's handle |
data-embed_type |
Distinguishes between embed code for Buy Buttons, embedded collections, and embedded carts. Possible values areproduct ,cart , andcollection . |
product |
data-display_size |
The maximum width of the entire embed (not of the button). Can becompact (230px) orregular (450px). Applies only to a single Product Buy Button. |
compact |
data-has_image |
Whether it's afull product embed(true ) orBuy Button only(false ). |
true |
data-redirect_to |
Where the Buy Buttonlinks to. Can becheckout ,product , orcart . If you want the Buy Button to connect with an embedded cart on the same page,data-redirect_to must becart . |
checkout |
data-product_modal |
Triggers the product modal to display when a product is clicked. If the value ofdata-redirect_to ismodal , this attribute must betrue , otherwise it should befalse . |
false |
data-buy_button_text |
The text displayed on the Buy Button. | Buy now |
data-button_background_color |
Thehex codeof the color of the Buy Button, without the# . Can be three hex characters or six. |
7db461 |
data-button_text_color |
Thehex codeof the color of the Buy Button's text, without the# . Can be three hex characters or six. |
ffffff |
data-background_color |
The background color of the area surrounding the Buy Button. It can be ahex code(per rules above), ortransparent . Iftransparent , no padding is applied to the embed's content. |
transparent |
data-show_product_price |
Override for whether or not to display the product price. Can betrue orfalse . |
The current value ofdata-has_image |
data-show_product_title |
Override for whether or not to display the product title. Can betrue orfalse . |
The current value ofdata-has_image |
data-buy_button_out_of_stock_text |
The text that appears when a product is out of stock. | Out of Stock |
data-buy_button_product_unavailable_text |
The text that appears when a product is unavailable. | Unavailable |
data-product_title_color |
Thehex codeof the color of the product title's text, without the# . Can be three hex characters or six. |
000000 |
Edit your website's cart
If you want to change the appearance or behavior of your website's cart, you need to add a separate snippet of HTML code and then edit its attributes. Each attribute controls a different part of what the cart looks like or how it works.
To edit your website's cart:
Open the HTML of the page containing the cart you want to edit.
Paste the following code:
Replace
your-shop-name.myshopify.com
with your store'smyshopify.com
address.Addthe relevant attributesto the cart's main
div
tag, and change it to include the value that you want. For example, if you want to change the text that appears at the top of the cart, then you need to adddata-cart_title="your text"
to the maindiv
tag in the code snippet. The result would look like this: