Add warning about missing customization on Cart page
To avoid orders placed without a customization, you can show a warning right on your Cart page when the item added to cart doesn't have a customization. Then your customers can notice and go back to the product to add to cart again.
Please follow the instruction below to add this warning message.
- Go to your Shopify admin -> Themes -> Edit code (of the published theme)
- Open a file that build Cart Page contents. It can be in
Sections
orSnippets
folder. Example:cart.liquid
,cart-items.liquid
,main-cart-items.liquid
,...
- Find a block code starting like
{% for item in cart.items %}
- Inside the block code, add the codes below into where you want to show warning message:
<!-- Teeinblue no custom notification -->
{% assign product = item.product %}
{% assign version = product.metafields.teeinblue.campaign_version %}
{% assign platformProduct = product.metafields.teeinblue.platform_product %}
{% assign isPlatformProduct = false %}
{% assign teeProduct = false %}
{% assign startDate = '2020-03-31 23:59:59' | date: '%s' %}
{% assign endDate = '2020-10-20 00:00:00' | date: '%s' %}
{% assign productCreatedDate = product.created_at | date: '%s' %}
{% assign productVendor = product.vendor | downcase %}
{% assign addonVariants = product.metafields.teeinblue.addon_variants.value %}
{% if platformProduct %}
{% assign isPlatformProduct = true %}
{% assign version = platformProduct.value.published_at | date: '%s' %}
{% endif %}
{% if version
or isPlatformProduct
or productVendor == 'teeinblue'
and productCreatedDate > startDate
and productCreatedDate < endDate
%}
{% assign teeProduct = true %}
{% endif %}
{% if teeProduct == true %}
{% for property in item.properties %}
{% if property.first contains '_customization_id' %}
{% assign hasCustomizationId = true %}
{% break %}
{% endif %}
{% endfor %}
{% if hasCustomizationId != true %}
<div class="teeinblue-warning-no-customization" style="color: #EC0101; border-style: solid; border-width: 2px; padding: 10px;">
Error! Personalization lost. Kindly remove this item from cart and add the item to cart again. We apologize for this inconvenience!
</div>
{% endif %}
{% endif %}
<!-- End Teeinblue no custom notification -->
For example, under cart-item__details
:
- Change the warning message if you want.
The default warning message is "Error! No customization created. Please add to cart again." In the above codes, you can find the line<div class="teeinblue-warning-no-customization">Error! No customization created. Please add to cart again.</div>
and change the message.
- Save and Done.
Then, when some errors happen and the customization can't be created, a warning message will show up like this:
Updated on: 01/10/2024
Thank you!