Skip to content

Instantly share code, notes, and snippets.

View bilalnaseer's full-sized avatar

Bilal Naseer bilalnaseer

View GitHub Profile
<!--Lazy Loading -->
{{ "lazysizes.min.js" | asset_url | script_tag }}
<style>.lazyload,.lazyloading{opacity:0}.lazyloaded{opacity:1;transition:opacity.3s}</style>
<!--Lazy Loading -->
@bilalnaseer
bilalnaseer / datalayer code for shopify
Created January 6, 2022 13:33
data layer code for shopify
{% if first_time_accessed %}<script>
window.dataLayer = window.dataLayer || [];
var shipping_price = '{{shipping_price | money_without_currency }}';
shipping_price = shipping_price.replace(",", ".");
var total_price = '{{total_price | money_without_currency }}';
total_price = total_price.replace(",", ".");
var tax_price = '{{tax_price | money_without_currency }}';
tax_price = tax_price.replace(",", ".");
window.dataLayer.push({
'page_type': 'purchase',
@bilalnaseer
bilalnaseer / theme.css
Created September 12, 2021 09:15
Add Custom Font In Shopify Store
/* My custom css */
@font-face {
font-family: "bubbleshine";
src: url("BubbleShine.woff2") format("woff2"),
url("BubbleShine.woff2") format("woff2");
}
.mega-title--large {
@bilalnaseer
bilalnaseer / header.liquid
Created September 8, 2021 11:27
Shopify Add SVG Logo
<a href="{{ routes.root_url }}" class="site-header__logo-image{% if section.settings.align_logo == 'center' %} site-header__logo-image--centered{% endif %}">
{% capture image_size %}{{ section.settings.logo_max_width | escape }}{% endcapture %}
<img src="{{ 'logo.svg' | asset_url }}"
alt="{{ shop.name }}"
style="max-width: {{ image_size }}px;">
</a>
@bilalnaseer
bilalnaseer / product.liquid
Created June 1, 2021 11:14
Adding custom field to product page in Shopify
//Copy and paste the code below into your product.liquid
// Following code will display field as required + Will show in checkout page
<p class="line-item-property__field">
<label for="your-name">Your name</label>
<input required class="required" id="your-name" type="text" name="properties[Your name]">
</p>
@bilalnaseer
bilalnaseer / code.html
Created January 14, 2021 15:28
Hide Sold Out Variations In Shopify Products
At bottom of the product.liquid file, paste the following code:
{% if product.options.size == 1 %}
<script>
var product_variants_removed = [
{%- for variant in product.variants -%}
{%- unless variant.available -%}
`{{ variant.title }}`,
{%- endunless -%}
{%- endfor -%}