Skip to content

Instantly share code, notes, and snippets.

@hsleonis
Last active October 15, 2020 14:17
Show Gist options
  • Save hsleonis/254b926f79575b7bbf93e02989b6f483 to your computer and use it in GitHub Desktop.
Save hsleonis/254b926f79575b7bbf93e02989b6f483 to your computer and use it in GitHub Desktop.
Shopify Debut hide cart and checkout
<script type="text/javascript">
(function() {
{% if request.page_type=='collection' %}
{% assign tmp = "tmx-collection-" | append: collection.handle %}
{% elsif request.page_type=='page' %}
{% assign tmp = "tmx-page-" | append: page.handle %}
{% elsif request.page_type=='product' %}
{% assign tmp = "tmx-product-" | append: product.handle %}
{% elsif request.page_type=='article' %}
{% assign tmp = "tmx-article-" | append: article.handle %}
{% else %}
{% assign tmp = "" %}
{% endif %}
var template_handle = "{{ tmp }}";
var body = document.body;
body.classList.add(template_handle);
})();
</script>
<style>
{% if section.settings.hide_all %}
.site-nav .cart, .site-nav .checkout, .site-header__cart,
.btn.product-form__cart-submit,
.shopify-payment-button, .cart__buttons-container,
.cart-popup,
.template-cart,
.price__regular, .price__sale, .price__unit, .price__badges,
.price__pricing-group, .price__unit, .product__policies {
display: none !important;
}
{% endif %}
{% if section.settings.hide_cart_btn_head %}
.site-nav .cart, .site-nav .checkout, .site-header__cart,
.cart-popup {
display: none !important;
}
{% endif %}
{% if section.settings.hide_cart_btn %}
.btn.product-form__cart-submit {
display: none !important;
}
{% endif %}
{% if section.settings.hide_checkout_btn %}
.shopify-payment-button, .cart__buttons-container {
display: none !important;
}
{% endif %}
{% if section.settings.hide_cart_page %}
.template-cart {
display: none !important;
}
{% endif %}
{% if section.settings.hide_price %}
.price__regular, .price__sale, .price__unit, .price__badges,
.price__pricing-group, .price__unit, .product__policies {
display: none !important;
}
{% endif %}
{% if template contains 'product' or template contains 'collection' %}
{% for block in section.blocks %}
{% assign col = block.settings.collection %}
.tmx-collection-{{ col }} .btn.product-form__cart-submit,
.tmx-collection-{{ col }} .shopify-payment-button,
.tmx-collection-{{ col }} .price__regular,
.tmx-collection-{{ col }} .price__sale,
.tmx-collection-{{ col }} .price__unit,
.tmx-collection-{{ col }} .price__badges,
.tmx-collection-{{ col }} .price__pricing-group,
.tmx-collection-{{ col }} .price__unit,
.tmx-collection-{{ col }} .product__policies {
display: none !important;
}
{% endfor %}
{% endif %}
</style>
{% schema %}
{
"name": "Cart and price Settings",
"settings": [
{
"type": "header",
"content": "Cart and Checkout Options"
},
{
"type": "checkbox",
"id": "hide_all",
"default": false,
"label": "Hide All",
"info": "Hide all cart and checkout button or links"
},
{
"type": "checkbox",
"id": "hide_cart_btn_head",
"default": false,
"label": "Header Cart",
"info": "Hide cart from header"
},
{
"type": "checkbox",
"id": "hide_cart_btn",
"default": false,
"label": "Cart Button",
"info": "Hide Cart button on products"
},
{
"type": "checkbox",
"id": "hide_checkout_btn",
"default": false,
"label": "Checkout Button",
"info": "Hide cheeckout button on products"
},
{
"type": "checkbox",
"id": "hide_cart_page",
"default": false,
"label": "Cart Page",
"info": "Hide cart page contents"
},
{
"type": "checkbox",
"id": "hide_price",
"default": false,
"label": "Price",
"info": "Hide product prices, sale badge and tax information"
},
{
"type": "header",
"content": "Product Collections",
"info": "Hide cart buttons and price only on selected collections"
}
],
"blocks": [
{
"type": "collection",
"name": "Collection",
"settings": [
{
"label": "Collection",
"id": "collection",
"type": "collection"
}
]
}
]
}
{% endschema %}
{% stylesheet %}
{% endstylesheet %}
{% javascript %}
{% endjavascript %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment