Skip to content

Instantly share code, notes, and snippets.

.search-results {
position: absolute;
background: #fff;
left: -24px !important;
width: calc(100% + 48px) !important;
top: 100% !important;
margin: 0 !important;
list-style: none;
padding: 10px 24px 20px;
}
$(function() {
var currentAjaxRequest = null;
var searchForms = $('form[action="/search"]').each(function() {
var input = $(this).find('input[name="q"]');
$('<ul class="search-results"></ul>').appendTo($(this));
input.attr('autocomplete', 'off').bind('keyup change', function() {
var term = $(this).val();
$walink = $('#h5b_whatsapp_chat a');
$web_link = 'https://web.whatsapp.com/send?text='+window.location.href+'%0A%0A'+$walink.data('message')+'&phone='+$walink.data('number');
$api_link = 'https://api.whatsapp.com/send?text='+window.location.href+'%0A%0A'+$walink.data('message')+'&phone='+$walink.data('number');
if('ontouchstart' in document.documentElement){
$walink.attr("href", $api_link);
}else{
$walink.attr("href", $web_link);
}
<!-- Please replace [Message] and [Phone Number] with your welcome message and the phone number which is used for the Whatsapp account -->
<div id="h5b_whatsapp_chat">
<a href="https://api.whatsapp.com/send?text=[message]&phone=[Phone Number]" target="_blank" data-message="[message]" data-number="[Phone Number]">
<img src="https://cdn.shopify.com/s/files/1/0070/3666/5911/files/icon_only_old.png?465/" alt="Whatsapp Icon" /></a>
</div>
// media_coverages = Post Type
$archives_link = wp_get_archives(array('type' => 'yearly', 'post_type' => 'media_coverages', 'format' => 'option', 'echo' => 0));
$archives_link = str_replace('</option>', '</option>, ', $archives_link);
$archives_link = preg_replace('#<option.*?>#si', '', $archives_link);
$archives_link = preg_replace('#<\/option>#si', '', $archives_link);
$archives_links = explode(', ', $archives_link);
foreach($archives_links as $link){
$link = trim($link);
// media_coverages = Post Type
function media_coverages_rewrite_rules(){
// For year and month
add_rewrite_rule(
'media_coverages/([0-9]{4})/([0-9]{1,2})/?$',
'index.php?post_type=media_coverages&year=$matches[1]&monthnum=$matches[2]',
'top'
<script>
(function(){
var divisor = 25;
var videos_status = [];
function eventHandler(e) {
switch (e.type) {
case 'timeupdate':
videos_status[e.target.id].current = Math.round(e.target.currentTime);
var pct = Math.floor(100 * videos_status[e.target.id].current / e.target.duration);
for (var j in videos_status[e.target.id]._progress_markers) {
@vishalarora91
vishalarora91 / cart-addon.liquid
Created December 14, 2018 16:19
Automatically add Free Gift in Cart
{% comment %}
Replace the text below with the handle of your add-on product.
{% endcomment %}
{% assign product = all_products['PRODUCT-HANDLE'] %}
<!-- Replace Product Handle with the handle of your product -->
{% unless cart.item_count == 0 or product.empty %}
{% if product.variants.size > 1 %}
@vishalarora91
vishalarora91 / Percentage off least expensive item - Shopify Scripts
Last active October 24, 2018 22:38
Percentage off least expensive item / Buy One Get One Free - Shopify Scripts
DISCOUNT_AMOUNT = 100
# Counting quantity of products
$cartcount = 0
Input.cart.line_items.each do |item|
$cartcount = $cartcount + item.quantity
end
# Offering discount based on the quantity after sorting the array for getting the least expensive item
if ($cartcount > 1)
@vishalarora91
vishalarora91 / Minimum order amount validation on Checkout Page - Shopify
Last active June 12, 2020 21:46
Minimum order amount validation on Checkout Page - Shopify
{% if checkout.total_price < 20000%}
<style>
.step__footer{ position: relative; padding-top: 35px; }
.step__footer:before{
content: 'Minimum orders have to be over $200.00.';
position: absolute;
top: 0;
left: 0;
font-size: 16px;
text-align: center;