Skip to content

Instantly share code, notes, and snippets.

View enamhasan's full-sized avatar

EnamHasan enamhasan

View GitHub Profile
@enamhasan
enamhasan / order-template.liquid
Created March 23, 2016 11:12
Shopify Order Printer Template with product image, variations and line item properties
<p style="float: right; text-align: right; margin: 0;">
{{ "now" | date: "%m/%d/%y" }}<br />
Invoice for {{ order_name }}
</p>
<div style="float: left; margin: 0 0 1.5em 0;" >
<strong style="font-size: 2em;">{{ shop_name }}</strong><br /><br />
{{ shop.address }}<br/>
{{ shop.city }} {{ shop.province_code }} {{ shop.zip | upcase }}<br/>
{{ shop.country }}
@enamhasan
enamhasan / product.liquid
Created October 21, 2023 02:05
Shopify Select First Variant On Stock When Product Page Loads
{%- comment -%}
If the product first varaiant inventory is 0 then find the variant with inventory and load the product page
{%- endcomment -%}
{%- assign current_variant = product.selected_or_first_available_variant -%}
{%- assign availableVariantId = '' -%}
{%- assign availableVariantFound = false -%}
{%- if current_variant.inventory_quantity <= 0 -%}
{%- for variant in product.variants -%}
@enamhasan
enamhasan / shopify-query-string
Created February 15, 2019 19:49
Get the querystring values with liquid in shopify
{%- capture contentForQuerystring -%}{{ content_for_header }}{%- endcapture -%}
{% comment %} Use string splitting to pull the value from content_for_header and apply some string clean up {% endcomment %}
{%- assign pageUrl = contentForQuerystring | split:'"pageurl":"' | last | split:'"' | first | split:'.myshopify.com' | last |
replace:'\/','/' |
replace:'%20',' ' |
replace:'\u0026','&'
-%}
{%- assign pageQuerystring = pageUrl | split:'?' | last -%}
@enamhasan
enamhasan / Country-redirect-popup-shopify
Last active May 2, 2023 03:18
Country Redirect Popup for Shopify
<script>
$(document).ready(function () {
//alert (tt);
$.getJSON('http://api.db-ip.com/v2/free/self', function (data) {
if (data.countryCode === 'CA') {
//alert("BD");
jQuery.fancybox.open(jQuery('#message'));
@enamhasan
enamhasan / related-article
Created May 2, 2023 03:14
Shopify Related Article By Tag
<div class="related-articles">
<h2 class="h3 text-center">{{ section.settings.related_article_heading }}</h2>
<div class="article_cols articles">
{% assign counter = 0 %}
{% for tag in article.tags %}
{% assign skip_articles = article.handle | split: '.....' %}
{% for related_article in blog.articles %}
{% if related_article.tags contains tag and counter < 3 %}
{% unless skip_articles contains related_article.handle %}
{% assign counter = counter | plus: 1 %}
@enamhasan
enamhasan / mailchimp-newsletter-ajax-signup
Last active July 13, 2022 15:30
Mailchimp-Shopify-Ajax-submission
<div class="success" style="display: none;">{{ settings.success_message }}</div>
{%- if settings.newsletter_form_action != "" -%}
<form id="mc4wp-form-footer" name="nlr" class="mc4wp-form mc4wp-form-{{block.id}} mc4wp-form-basic" method="get" action="{{ settings.newsletter_form_action }}" target="_blank" data-id="{{block.id}}">
<div class="mc4wp-form-fields">
<p class="mailchimp-input-icon">
<label>Email address: </label>
<input type="email" name="EMAIL" placeholder="{{ 'general.newsletter_form.email_placeholder' | t }}" value="{%- if customer -%}{{ customer.email }}{%- endif -%}" required="">
</p>
<p>
<input type="submit" value="{{ 'general.newsletter_form.submit' | t }}">
@enamhasan
enamhasan / gist:e1acfa404396a0f3e69186184a251837
Created June 24, 2022 13:49
SHOPIFY RESTRICTING ACCESS TO A PAGE / ARTICLE / PRODUCT / COLLECTION WITHOUT LOGIN
<html lang="{{ shop.locale }}">
{% if template contains "wholesale" %}
<!-- wholesale Content -->
{% unless customer %}
{% assign send_to_login = true %}
{% endunless %}
{% endif %}
{% if send_to_login and request.path != "/challenge" %}
@enamhasan
enamhasan / Show-inventory Quantity Shopify
Last active March 4, 2022 09:08
Display variant inventory quantiy on product page Shopify
# add this script in product liquid (Just before addtocart form)
<!-- Code added for Inventory in Pipeline -->
<script>
var inv_qty = {};
{% for var in product.variants %}
inv_qty[{{- var.id -}}] = {{ var.inventory_quantity | default: 0 }};
{% endfor %}
</script>
{% if current_variant.inventory_management == "shopify" %}
@enamhasan
enamhasan / scriptTag.js
Created January 11, 2022 13:45
Create ScriptTag via Shopify node react App via GraphQL
import gql from 'graphql-tag';
import { useQuery, useMutation } from '@apollo/react-hooks';
import { Button, Card, Layout, Page, ResourceList, Stack } from '@shopify/polaris';
const CREATE_SCRIPT_TAG = gql`
mutation scriptTagCreate($input: ScriptTagInput!) {
scriptTagCreate(input: $input) {
scriptTag {
id
@enamhasan
enamhasan / advance-product-descripton-shopify
Created February 5, 2021 10:48
Dynamic product description for ElectJet
{% include 'product-template',
description_style: section.settings.description_style,
image_container_width: section.settings.image_size,
section_id: product.id,
social: section.settings.social_enable,
thumbnail_position: section.settings.thumbnail_position,
thumbnail_arrows: section.settings.thumbnail_arrows
%}
{% if settings.enable_product_reviews and settings.reviews_layout == 'full' %}