Skip to content

Instantly share code, notes, and snippets.

@odessy
odessy / index-instagram.liquid
Created November 17, 2018 16:56
add instagram username to generate URL in index-instagram.liquid
{% assign instagram_grid_width_large = 'large--one-sixth' %}
{% assign instagram_grid_width_medium = 'medium--one-third' %}
{% assign instagram_grid_width_small = 'small--one-half' %}
{% case section.settings.instagram_grid_setting_large %}
{% when 2 %}
{% assign instagram_grid_width_large = 'large--one-half' %}
{% when 3 %}
{% assign instagram_grid_width_large = 'large--one-third' %}
{% when 4 %}
@odessy
odessy / gist:4e95f2fc76ad64ffc0df8a2f685c2ad7
Last active November 22, 2018 17:11
Handsome checkout pages - remove products from cart if no purchase made
<?php
// Handsome checkout pages - remove products from cart if no purchase made
add_filter('wp', 'remove_hcc_cart_item');
function remove_hcc_cart_item() {
if (is_admin() || defined('DOING_AJAX')) {
return;
}
global $post;
@odessy
odessy / upsell_order_notes.php
Created November 26, 2018 15:30
sample of adding upsell order notes
<?php
add_action('wc_1cu_after_item_add', 'update_order_meta_after_add', 10,1);
function update_order_meta_after_add($order){
if(!empty($_GET['offer_notes']) ){
//assume the last order item added.
$items = $order->get_items();
end($items);
$item_id = key($items);
wc_add_order_item_meta( $item_id, 'upsell_order_notes', sanitize_text_field($_GET['offer_notes']));
@odessy
odessy / header.liquid
Created November 26, 2018 21:04
add additional Announcement message
<div class="header__wrapper">
{% if section.settings.header_enable_account or section.settings.header_enable_search or section.settings.header_message != '' %}
<div class="info-bar showMobile">
<div class="wrapper text-center">
{% if shop.customer_accounts_enabled and section.settings.header_enable_account %}
<div class="header-account-link">
<a href="/account"><img src="{{ 'account.svg' | asset_url }}"></a>
</div>
@odessy
odessy / verify_step.js
Created November 29, 2018 14:31
verify first step for handsome checkout page
jQuery(document).ready(function($){
var btn = $('.hcc-t5-step-1 .btn-step2');
if( btn.length == 0 ) btn = $('.btn-step1');
btn.before('<style>.btn-step1-wrapper{display:none;} .hcc-t6-step-1 .btn-step1-wrapper{margin-top: 20px; margin-bottom: 27px; display:block;} .hcc-step-1 .btn-step1,.hcc-step-2 .btn-step1, .hcc-step-2 .btn-step1-wrapper, .hcc-t5-step-2 .btn-step1-wrapper, .hcc-t5-step-3 .btn-step1-wrapper,.hcc-t5-step-1 .btn-step2, .hcc-t6-step-1 .btn-step1{display:none !important;}</style>');
btn.after('<button class="btn btn-success btn-lg wizard-button btn-block btn-step1-wrapper">'+btn.html()+'</button>');
$('.btn-step1-wrapper').on("click", function(event){
var inputs = $('.validate-required:visible').find('input');
var ready = true;
var messages = [];
inputs.each(function(i, item){
@odessy
odessy / address_field_2.php
Last active November 29, 2018 14:51
add address_field_2 in correct location
<?php
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields', 9999 );
function custom_override_checkout_fields( $fields ) {
$address_2 = array(
'placeholder' => __('Appartment, suite, unit etc.(optional)', 'woocommerce'),
'label' => __('Appartment, suite, unit etc.', 'woocommerce'),
'class' => array('form-row-wide', 'address-field'),
'required' => false,
@odessy
odessy / wc_1cu_after_item_add.php
Last active December 4, 2018 22:49
wc_1cu_after_item_add snippet to identify the funnel
<?php
add_action('wc_1cu_after_item_add', 'custom_after_item_add');
function custom_after_item_add($order){
if( !empty( $_GET['1cu_n'] ) && !empty( $order ) )
{
//get funnel for the $order
$funnel = gb_ocu_get_funnel_for_order_items( $order );
@odessy
odessy / remove-variant.liquid
Created December 11, 2018 15:20
remove out of stock variant
{% comment %}
Remove specific variants.
Only works for products that have one option.
It won't work with products that have two or three options, like Size and Color.
{% endcomment %}
{% if product.options.size == 1 %}
<script>
var $addToCartForm = $('form[action="/cart/add"]');
if (window.MutationObserver && $addToCartForm.length) {
{% unless product.has_only_default_variant %}
{% for option in product.options_with_values %}
{% assign downcased_option = option.name | downcase %}
{% if downcased_option contains 'color' or downcased_option contains 'colour' %}
{% if option.values.size > 1 %}
{% assign is_color = true %}
More {{ option.name }}s
{% endif %}
{% endif %}
{% endfor %}
@odessy
odessy / menu_chevron.css
Last active January 4, 2019 15:16
add chevron to main menu
.nav--desktop ul.main-menu > li > a.nav-link[aria-haspopup="true"]:after{
border-style: solid;
border-width: 0.15em 0.15em 0 0;
content: '';
display: inline-block;
height: 0.45em;
width: 0.45em;
left: 0.15em;
top: 0.4em;
position: relative;