Call Us at: +1(316) 444-3132

14 days free trial - No Card Details Needed (This is a non-refundable purchase)

Add A Gift Wrap Option To Your Shopify Website Cart Page

03 Apr 2023
FeaturesTutorials
how-to-add-gift-wrapping-option-on-your-shopify-store

You can offer a present wrapping provider to your clients at the Gift Wrap Option of your online shop. For customers who want their order wrapped, you could rate either a flat price, or fee in line with product foundation.

Create a Gift Wrap Option

Below are the Steps of How to Create a Gift Wrap Option:

  • Click product in the Shopify admin.
  • Add product by clicking.
  • Produce a gift-wrapped item in the same manner as you would any other product.
  • You can describe the materials that could be used to present-wrap the items in your product description.
  • Specify the price you want to charge for the service on your gift-wrapped item. Set the price of your present-wrap goods to $0 if you require gift wrapping to be unfastened.
  • To show your customers what a gift-wrapped item would look like, you can upload a product photo.
  •  Make sure your gift-wrap product is in stock, or change the settings so that Shopify does not keep track of the product’s inventory. Uncheck Monitor quantity if your savings spans many locations to stop Shopify from keeping track of the stock for the gift-wrap item.
  • Click Save.

After Creating a Gift Wrap Option, Now it’s Turn to Create the Menu Bar.

Create A Menu

The Following is a Sample Menu That Considers Your Gift Wrap Option:

  • From your Shopify admin, visit Online Store > Navigation.
  • Click Add menu.
  • Name your menu Gift wrapping, so that the deal with it truly is assigned to the menu is present-wrapping.
  • Add the present-wrap product to the menu:
  • Click Add menu object, and then input a Name for the hyperlink to the gift-wrap product.
  • In the Link area, choose Products, after which pick out the present-wrap product from the drop-down menu.
  • Click Add.
  • Click the Save menu.

Create A Code Snippet

To create a code snippet for the present-wrap option,you can use the following steps:

  • From your Shopify admin, go to the Online Store then Themes.
  • Find the theme you want to edit, click on the … button to open the moves menu, and then click on Edit code.
  • In the Snippets directory, click Add a new snippet.
  • Name your snippet gift-wrapping and click on Create snippet. Your snippet record will open within the code editor.
  • In this step, you will paste some code into your new gift-wrapping snippet record. The code you paste relies upon on how you need to rate your clients for the present wrapping provider:

Add a flat fee for gift wrapping.

Add the following code, then click “Save“:

{% if linklists.gift-wrapping.links.size > 0 and
linklists.gift-wrapping.links.first.type == 'product_link' %}

<div
  id="is-a-gift"
  style="clear: left; margin: 30px 0"
  class="clearfix rte">
  <p>
    <input
      id="gift-wrapping"
      type="checkbox"
      name="attributes[gift-wrapping]"
      value="yes"
      {% if cart.attributes.gift-wrapping %}
      checked="checked"
      {% endif %}
      style="float: none"/>
    <label
      for="gift-wrapping"
      style="display:inline; padding-left: 5px; float: none;">
      For {{ linklists.gift-wrapping.links.first.object.price | money }}
      please wrap the products in this order.
    </label>
  </p>
  <p>
    <label style="display:block" for="gift-note"
      >Gift message (free and optional):</label>
    <textarea name="attributes[gift-note]" id="gift-note">
{{ cart.attributes.gift-note }}</textarea>
  </p>
</div>

{% 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 %}

<style>
  #updates_{{ id }} { display: none; }
</style>

<script>

  Shopify.Cart = Shopify.Cart || {};

  Shopify.Cart.GiftWrap = {};

  Shopify.Cart.GiftWrap.set = function() {
    var headers = new Headers({ 'Content-Type': 'application/json' });

    var request = {
      method: 'POST',
      headers: headers,
      body: JSON.stringify({ updates: { {{ id }}: 1 }, attributes: { 'gift-wrapping': true } })
    };
    fetch('/cart/update.js', request)
    .then(function() {
      location.href = '/cart';
    });
  }

  Shopify.Cart.GiftWrap.remove = function() {
    var headers = new Headers({ 'Content-Type': 'application/json' });

    var request = {
      method: 'POST',
      headers: headers,
      body: JSON.stringify({ updates: { {{ id }}: 0 }, attributes: { 'gift-wrapping': '', 'gift-note': '' } })
    };
    fetch('/cart/update.js', request)
    .then(function() {
      location.href = '/cart';
    });
  }

  // If we have nothing but gift-wrap items in the cart.
  {% if cart.items.size == 1 and gift_wraps_in_cart > 0 %}
  document.addEventListener("DOMContentLoaded", function(){
    Shopify.Cart.GiftWrap.remove();
  });
  // If we have more than one gift-wrap item in the cart.
  {% elsif gift_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.
  {% elsif gift_wraps_in_cart > 0 and cart.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.
  {% elsif gift_wraps_in_cart == 0 and cart.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) {
      var note = evt.target.value;
      var headers = new Headers({ 'Content-Type': 'application/json' });

      var request = {
        method: 'POST',
        headers: headers,
        body: JSON.stringify({ attributes: { 'gift-note': note } })
      };

      fetch('/cart/update.js', request);
    });
  });
</script>

{% else %}

<p 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
  <code>gift-wrapping</code> which, in turn, contains a link to your
  gift-wrapping product. Please review the steps outlined
  <a
    href="https://help.shopify.com/manual/online-store/themes/os/customize/add-gift-wrap-option"
    target="_blank"
    rel="noopener noreferrer nofollow"
    >here</a>.
</p>

{% endif %}

A charge multiplied by the number of the order’s products should be added.


If you choose this option, the gift-wrapping fee will be three times what the order’s total number of products is. Copy the code below, then hit “Save“:

{% if linklists.gift-wrapping.links.size > 0 and
linklists.gift-wrapping.links.first.type == 'product_link' %}

<div
  id="is-a-gift"
  style="clear: left; margin: 30px 0"
  class="clearfix rte"
>
  <p>
    <input
      id="gift-wrapping"
      type="checkbox"
      name="attributes[gift-wrapping]"
      value="yes"
      {% if cart.attributes.gift-wrapping %}
      checked="checked"
      {% endif %}
      style="float: none"
    />
    <label
      for="gift-wrapping"
      style="display:inline; padding-left: 5px; float: none;"
    >
      For {{ linklists.gift-wrapping.links.first.object.price | money }} per
      item, please wrap the products in this order.
    </label>
  </p>
  <p>
    <label style="display:block" for="gift-note"
      >Gift message (free and optional):</label
    >
    <textarea name="attributes[gift-note]" id="gift-note">
{{ cart.attributes.gift-note }}</textarea
    >
  </p>
</div>

{% 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 %}

<style>
  #updates_{{ id }} { display: none; }
</style>

<script>

  Shopify.Cart = Shopify.Cart || {};

  Shopify.Cart.GiftWrap = {};

  Shopify.Cart.GiftWrap.set = function() {
    var headers = new Headers({ 'Content-Type': 'application/json' });

    var request = {
      method: 'POST',
      headers: headers,
      body: JSON.stringify({ updates: { {{ id }}: {{ items_in_cart }} }, attributes: { 'gift-wrapping': true } })
    };
    fetch('/cart/update.js', request)
    .then(function() {
      location.href = '/cart';
    });
  }

  Shopify.Cart.GiftWrap.remove = function() {
    var headers = new Headers({ 'Content-Type': 'application/json' });

    var request = {
      method: 'POST',
      headers: headers,
      body: JSON.stringify({ updates: { {{ id }}: 0 }, attributes: { 'gift-wrapping': '', 'gift-note': '' } })
    };
    fetch('/cart/update.js', request)
    .then(function() {
      location.href = '/cart';
    });
  }

  // If we have nothing but gift-wrap items in the cart.
  {% if cart.items.size == 1 and gift_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.
  {% elsif gift_wraps_in_cart > 0 and gift_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.
  {% elsif gift_wraps_in_cart > 0 and cart.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.
  {% elsif gift_wraps_in_cart == 0 and cart.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) {
      var note = evt.target.value;
      var headers = new Headers({ 'Content-Type': 'application/json' });

      var request = {
        method: 'POST',
        headers: headers,
        body: JSON.stringify({ attributes: { 'gift-note': note } })
      };

      fetch('/cart/update.js', request);
    });
  });
</script>

{% else %}

<p 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
  <code>gift-wrapping</code> which, in turn, contains a link to your
  gift-wrapping product. Please review the steps outlined
  <a
    href="https://help.shopify.com/manual/online-store/themes/os/customize/add-gift-wrap-option"
    target="_blank"
    rel="noopener noreferrer nofollow"
    >here</a
  >.
</p>

{% endif %}

Add the snippet to your template for the cart.

For your cart template to include the gift-wrapping snippet:

  • The cart-template.liquid file is located in the Sections directory. Click cart.liquid in the Templates directory if your theme doesn’t already include a cart-template.liquid.
  • Look in the code for the </form> closing tag. The following code should be pasted on a new line above the ending< /form> tag:
{% render 'gift-wrapping' %}
  • Click Save.

Letā€™s Add Gift Wrap Option on Your Shopify Store with Us.

Want to make your Shopify store’s user experience better? With our assistance, think about including a gift-wrapping choice. Our staff can make it simple for customers to add the gift wrapping option during checkout and can tailor the feature to match your branding. You can thrill your consumers and raise the likelihood of repeat business with this extra feature.

You can contact us via live chat if you have any problems or run into trouble while using the Gift Wrap Option code. Our Shopify developers are on chat around-the-clock to help you.

Are you getting confused while doing this code?? Don’t worry only with one click you can buy this feature. Click Here and enjoy the feature.

By Hazel

Hazel is an experienced content writer with a passion for creating compelling stories that resonate with readers. She has a proven track record of producing high-quality content for websites, blogs, and social media platforms across a range of industries.

5 comments

  1. Providing gift wrap option can encourage customers to purchase items as gifts, increasing the potential for sales. I noticed itā€™s advantage on my store.

  2. Does the quantity of the gift wrap increase automatically as the quantity of the products increases in the cart?

Leave a comment

Your email address will not be published. Required fields are marked *

Are You Ready?

To Say Goodbye to the No-Sales Zone and Hello to a Thriving Business With Shopzila Shopify Theme!!

image

Please enter store password 3 to view live demo

SPIN TO WIN!

  • Try your luck to unlock discounts.
Try Your Luck
Never
Remind later
No thanks