Skip to content

Instantly share code, notes, and snippets.

View amitramani's full-sized avatar

Amit Ramani amitramani

View GitHub Profile
@amitramani
amitramani / autocomplete.php
Created April 24, 2020 03:33
WooCommerce Price to Algolia AutoComplete Results Drop Down
<script type="text/html" id="tmpl-autocomplete-header">
<div class="autocomplete-header">
<div class="autocomplete-header-title">{{{ data.label }}}</div>
<div class="clear"></div>
</div>
</script>
<!-- Amit Ramani: April 19, 2020 Added Price to the bottom of title -->
<script type="text/html" id="tmpl-autocomplete-post-suggestion">
<a class="suggestion-link" href="{{ data.permalink }}" title="{{ data.post_title }}">
<# if ( data.images.thumbnail ) { #>
// Copyright 2015, Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@amitramani
amitramani / functions.php
Created September 10, 2017 01:00
To move the Archive Intro Text from the top (default) position to the bottom of the page (after shop loop)
/* Remove the Archive Headline and Text from the default location */
remove_action( 'genesis_archive_title_descriptions', 'genesis_do_archive_headings_open', 5);
remove_action( 'genesis_archive_title_descriptions', 'genesis_do_archive_headings_close', 15);
remove_action( 'genesis_archive_title_descriptions', 'genesis_do_archive_headings_headline', 10);
remove_action( 'genesis_archive_title_descriptions', 'genesis_do_archive_headings_intro_text', 12);
/* Now, add it back at the bottom */
add_action( 'woocommerce_after_shop_loop', 'ar_add_custom_hook_archive_description', 8);
add_action( 'ar_add_wc_archive_descr_text' , 'ar_do_custom_archive_description_text', 7, 3);
function ar_add_custom_hook_archive_description() {
@amitramani
amitramani / functions.php
Created August 22, 2016 01:05
How to send WooCommerce Checkout Error Messages to Google Analytics as Events
function load_ga_error_script() {
// Load the JS file (jquery is a dependency)
wp_enqueue_script( 'ga-send-error-event', get_stylesheet_directory_uri() . '/js/ga-send-error-event.js', array('jquery' ) );
}
add_action( 'wp_enqueue_scripts', 'load_ga_error_script' );
@amitramani
amitramani / functions.php
Created June 4, 2016 17:45
[WooCommerce] How to add Custom Fields to Products
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
function woo_add_custom_general_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
woocommerce_wp_checkbox(
array(
'id' => '_no_free_shipping_checkbox',
@amitramani
amitramani / functions.php
Last active February 9, 2018 22:49
How to get Crawler Based Search Engine for Swiftype on WordPress using Genesis
// October 11, 2015 Change search form text from https://wpbeaches.com/change-search-field-default-text-genesis-wordpress-theme/
function themeprefix_search_button_text( $text ) {
return ( 'Start Typing...');
}
add_filter( 'genesis_search_text', 'themeprefix_search_button_text' );
function b3m_search_form( $form, $search_text, $button_text, $label ) {
$onfocus = " onfocus=\"if (this.value == '$search_text') {this.value = '';}\"";
$onblur = " onblur=\"if (this.value == '') {this.value = '$search_text';}\"";
@amitramani
amitramani / functions.php
Created April 16, 2016 00:42
Enqueue the JS File, Add Progress Bar to Checkout Page
/* Enqueue the JS File for manipulating the Progress Bar */
function my_theme_scripts() {
wp_enqueue_script( 'wc-checkout-progress-bar', get_stylesheet_directory_uri() . '/js/wc-checkout-progress-bar.js', array( 'jquery' ), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' );
/* Add the Progress Bar to the Checkout Page */
function ar_add_progress_bar(){
echo do_shortcode('[wppb progress=50 option="animated-candystripe purple" location=inside fullwidth=true]');
}