Add a gift wrap option to your cart page
You can offer a gift wrapping service to your customers on the cart page of your online store. For customers who want their order wrapped, you can charge either a flat rate, or charge on a per product basis.

On this page
Create a gift-wrap product
First, you will create your gift-wrap option as a product:
From your Shopify admin, go to<一个href="//www.theturtleeffect.com/admin/products">Products.
ClickAdd product.
Create a gift-wrap product<一个href="//www.theturtleeffect.com/help/en/manual/products/add-update-products" target="_self">just as you would create any other product:
- You can use your product description to explain what materials will be used to gift-wrap the items.
- Give your gift-wrap product the price that you want to charge for the service. If you want gift wrapping to be free, then set the price of your gift-wrap product to be
0
. - You can upload an image for the product to show your customers what a gift-wrapped order will look like.
- Make sure your gift-wrap product includes inventory, or else adjust the settings so that Shopify doesn't track inventory for the gift-wrap product. If your store has multiple locations, then uncheckTrack quantityto prevent Shopify from tracking inventory for the gift-wrap product.
- ClickSave.
Create a menu
Next, create a menu that points to your gift-wrap product:
Create a code snippet
Add a flat rate charge for gift wrapping
Paste the following code andSave:
{% if linklists.gift-wrapping.links.size > 0 and linklists.gift-wrapping.links.first.type == 'product_link' %}id="is-a-gift"style="clear: left; margin: 30px 0"class="clearfix rte">id="gift-wrapping"type="checkbox"name="attributes[gift-wrapping]"value="yes"{%ifcart.attributes.gift-wrapping%}checked="checked"{%endif%}style="float: none"/>>>{% assign id = linklists.gift-wrapping.links.first.object.variants.first.id %} {% assign gift_wraps_in_cart = 0 %} {% for item in cart.items %} {% if item.id == id %} {% assign gift_wraps_in_cart = item.quantity %} {% endif %} {% endfor %}#updates_{{id}}{display:none;}Shopify.Cart=Shopify.Cart||{};Shopify.Cart.GiftWrap={};Shopify.Cart.GiftWrap.set=function(){varheaders=新Headers({'Content-Type':'application/json'});varrequest={method:'POST',headers:headers,body:JSON.stringify({updates:{{{id}}:1},attributes:{'礼品包装服务':true}})};fetch('/cart/update.js',request).then(function(){location.href='/cart';});}Shopify.Cart.GiftWrap.remove=function(){varheaders=新Headers({'Content-Type':'application/json'});varrequest={method:'POST',headers:headers,body:JSON.stringify({updates:{{{id}}:0},attributes:{'礼品包装服务':'','gift-note':''}})};fetch('/cart/update.js',request).then(function(){location.href='/cart';});}// If we have nothing but gift-wrap items in the cart.{%ifcart.items.size==1andgift_wraps_in_cart>0%}document.addEventListener("DOMContentLoaded",function(){Shopify.Cart.GiftWrap.remove();});// If we have more than one gift-wrap item in the cart.{%elsifgift_wraps_in_cart>1%}document.addEventListener("DOMContentLoaded",function(){Shopify.Cart.GiftWrap.set();});// If we have a gift-wrap item in the cart but our gift-wrapping cart attribute has not been set.{%elsifgift_wraps_in_cart>0andcart.attributes.gift-wrapping==blank%}document.addEventListener("DOMContentLoaded",function(){Shopify.Cart.GiftWrap.set();});// If we have no gift-wrap item in the cart but our gift-wrapping cart attribute has been set.{%elsifgift_wraps_in_cart==0andcart.attributes.gift-wrapping!=blank%}document.addEventListener("DOMContentLoaded",function(){Shopify.Cart.GiftWrap.set();});{%endif%}// When the gift-wrapping checkbox is checked or unchecked.document.addEventListener("DOMContentLoaded",function(){document.querySelector('[name="attributes[gift-wrapping]"]').addEventListener("change",function(event){if(event.target.checked){Shopify.Cart.GiftWrap.set();}else{Shopify.Cart.GiftWrap.remove();}});document.querySelector('#gift-note').addEventListener("change",function(evt){varnote=evt.target.value;varheaders=新Headers({'Content-Type':'application/json'});varrequest={method:'POST',headers:headers,body:JSON.stringify({attributes:{'gift-note':note}})};fetch('/cart/update.js',request);});});{% else %}style="clear: left; margin: 30px 0"class="rte">You attempted to add a gift-wrapping script to your shopping cart, but it won't work because you don't have a link list with handle
礼品包装服务
which, in turn, contains a link to your gift-wrapping product. Please review the steps outlined<一个href="https://help.shopify.com/manual/online-store/themes/os/customize/add-gift-wrap-option"target="_blank"rel="noopener noreferrer nofollow">here>.{% endif %}
Add a charge that is multiplied by the number of products in the order
With this option, if there are three products in the order, then the gift wrap charge will be multiplied by three. Paste the following code andSave:
{% if linklists.gift-wrapping.links.size > 0 and linklists.gift-wrapping.links.first.type == 'product_link' %}id="is-a-gift"style="clear: left; margin: 30px 0"class="clearfix rte">id="gift-wrapping"type="checkbox"name="attributes[gift-wrapping]"value="yes"{%ifcart.attributes.gift-wrapping%}checked="checked"{%endif%}style="float: none"/>>>{% assign id = linklists.gift-wrapping.links.first.object.variants.first.id %} {% assign gift_wraps_in_cart = 0 %} {% for item in cart.items %} {% if item.id == id %} {% assign gift_wraps_in_cart = item.quantity %} {% endif %} {% endfor %} {% assign items_in_cart = cart.item_count | minus: gift_wraps_in_cart %}#updates_{{id}}{display:none;}Shopify.Cart=Shopify.Cart||{};Shopify.Cart.GiftWrap={};Shopify.Cart.GiftWrap.set=function(){varheaders=新Headers({'Content-Type':'application/json'});varrequest={method:'POST',headers:headers,body:JSON.stringify({updates:{{{id}}:{{items_in_cart}}},attributes:{'礼品包装服务':true}})};fetch('/cart/update.js',request).then(function(){location.href='/cart';});}Shopify.Cart.GiftWrap.remove=function(){varheaders=新Headers({'Content-Type':'application/json'});varrequest={method:'POST',headers:headers,body:JSON.stringify({updates:{{{id}}:0},attributes:{'礼品包装服务':'','gift-note':''}})};fetch('/cart/update.js',request).then(function(){location.href='/cart';});}// If we have nothing but gift-wrap items in the cart.{%ifcart.items.size==1andgift_wraps_in_cart>0%}document.addEventListener("DOMContentLoaded",function(){Shopify.Cart.GiftWrap.remove();});// If we don't have the right amount of gift-wrap items in the cart.{%elsifgift_wraps_in_cart>0andgift_wraps_in_cart!=items_in_cart%}document.addEventListener("DOMContentLoaded",function(){Shopify.Cart.GiftWrap.set();});// If we have a gift-wrap item in the cart but our gift-wrapping cart attribute has not been set.{%elsifgift_wraps_in_cart>0andcart.attributes.gift-wrapping==blank%}document.addEventListener("DOMContentLoaded",function(){Shopify.Cart.GiftWrap.set();});// If we have no gift-wrap item in the cart but our gift-wrapping cart attribute has been set.{%elsifgift_wraps_in_cart==0andcart.attributes.gift-wrapping!=blank%}document.addEventListener("DOMContentLoaded",function(){Shopify.Cart.GiftWrap.set();});{%endif%}// When the gift-wrapping checkbox is checked or unchecked.document.addEventListener("DOMContentLoaded",function(){document.querySelector('[name="attributes[gift-wrapping]"]').addEventListener("change",function(event){if(event.target.checked){Shopify.Cart.GiftWrap.set();}else{Shopify.Cart.GiftWrap.remove();}});document.querySelector('#gift-note').addEventListener("change",function(evt){varnote=evt.target.value;varheaders=新Headers({'Content-Type':'application/json'});varrequest={method:'POST',headers:headers,body:JSON.stringify({attributes:{'gift-note':note}})};fetch('/cart/update.js',request);});});{% else %}style="clear: left; margin: 30px 0"class="rte">You attempted to add a gift-wrapping script to your shopping cart, but it won't work because you don't have a link list with handle
礼品包装服务
which, in turn, contains a link to your gift-wrapping product. Please review the steps outlined<一个href="https://help.shopify.com/manual/online-store/themes/os/customize/add-gift-wrap-option"target="_blank"rel="noopener noreferrer nofollow">here>.{% endif %}
Include the snippet in your cart template
To include the gift-wrapping snippet in your cart template:
在Sectionsdirectory, click
cart-template.liquid
. If your theme doesn't have acart-template.liquid
, then clickcart.liquid
in theTemplatesdirectory.Findthe closing
tag in the code. On a new line above the closing
tag, paste the following code:
{%render'gift-wrapping'%}
- ClickSave.