Skip to content

Instantly share code, notes, and snippets.

@aadityajs
aadityajs / jsGetUrl.js
Last active December 22, 2015 23:29 — forked from travhimself/gist:6546838
JS to grab Get Paramert from URL
var getparams = function(param) {
var url = window.location.search.substring(1);
var urlvars = url.split('&');
for (var i = 0; i < urlvars.length; i++) {
var paramname = urlvars[i].split('=');
if ( paramname[0] == param) {
return paramname[1];
}
}
};
@aadityajs
aadityajs / Woocommerce 'Ask for Quotation'.php
Last active January 2, 2016 02:18 — forked from mikejolley/gist:1597957
Woocommerce 'Ask for Quotation'
/**
* This code should be added to functions.php of your theme
**/
add_filter('woocommerce_empty_price_html', 'custom_call_for_price');
function custom_call_for_price() {
return 'Call for price';
}
@aadityajs
aadityajs / Apply tax based on subtotal.php
Created January 3, 2014 10:14 — forked from mikejolley/gist:5568708
Apply tax based on subtotal
<?php
add_filter( 'woocommerce_product_tax_class', 'big_apple_get_tax_class', 1, 2 );
function big_apple_get_tax_class( $tax_class, $product ) {
global $woocommerce;
if ( $woocommerce->cart->subtotal <= 110 )
$tax_class = 'Zero Rate';
return $tax_class;
@aadityajs
aadityajs / woocommerce_get_price_html - add + VAT.php
Last active January 2, 2016 02:18 — forked from mikejolley/gist:4150218
woocommerce_get_price_html - add + VAT
<?php
add_filter( 'woocommerce_get_price_html', 'price_plus_vat' );
function price_plus_vat( $price ) {
return $price . ' ' . __( '+ VAT', 'woocommerce' );
}
?>
@aadityajs
aadityajs / WooCommerce - Create a coupon via PHP.php
Created January 3, 2014 10:21 — forked from mikejolley/gist:3969579
WooCommerce - Create a coupon via PHP
<?php
$coupon_code = 'UNIQUECODE'; // Code
$amount = '10'; // Amount
$discount_type = 'fixed_cart'; // Type: fixed_cart, percent, fixed_product, percent_product
$coupon = array(
'post_title' => $coupon_code,
'post_content' => '',
'post_status' => 'publish',
'post_author' => 1,
@aadityajs
aadityajs / WooCommerce - Send an email from the customer on order complete..php
Created January 3, 2014 10:22 — forked from mikejolley/gist:3930685
WooCommerce - Send an email from the customer on order complete.
<?php
add_action( 'woocommerce_order_status_completed', 'custom_send_email_from_customer' );
function custom_send_email_from_customer( $order_id ) {
$order = new WC_Order( $order_id );
$headers = 'From: ' . $order->billing_first_name . ' ' . $order->billing_last_name . ' <' . $order->billing_email . '>' . "\r\n";
wp_mail( 'someone@somesite.com', 'Subject', 'Message', $headers );
}
?>
@aadityajs
aadityajs / functions.php
Created January 3, 2014 10:23 — forked from mikejolley/functions.php
WooCommerce - Change number of upsells displayed and # of products per row
<?php
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display');
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_upsells', 20);
if (!function_exists('woocommerce_output_upsells')) {
function woocommerce_output_upsells() {
woocommerce_upsell_display(3,3); // Display 3 products in rows of 3
}
}
?>
@aadityajs
aadityajs / functions.php
Created January 3, 2014 10:24 — forked from mikejolley/functions.php
Move Tabs Around in WooCommerce
<?php
add_action( 'wp' , 'wc_order_tabs' );
function wc_order_tabs() {
// Remove tabs
remove_action( 'woocommerce_product_tabs', 'woocommerce_product_description_tab', 10 );
remove_action( 'woocommerce_product_tabs', 'woocommerce_product_attributes_tab', 20 );
remove_action( 'woocommerce_product_tabs', 'woocommerce_product_reviews_tab', 30 );
@aadityajs
aadityajs / WooCommerce - Change products per page conditionally.php
Created January 3, 2014 10:27 — forked from mikejolley/gist:3358102
WooCommerce - Change products per page conditionally
<?php
add_action( 'pre_get_posts', 'mj_change_per_page' );
function mj_change_per_page() {
if ( is_product_category( 'games' ) ) {
add_filter('loop_shop_per_page', create_function('$cols', 'return 1;') );
} else {
add_filter('loop_shop_per_page', create_function('$cols', 'return 8;') );
}
@aadityajs
aadityajs / WooCommerce - India states.php
Created January 3, 2014 10:27 — forked from mikejolley/gist:3123868
WooCommerce - India states
<?php
/**
* Code goes in functions.php or a custom plugin.
*/
add_filter( 'woocommerce_states', 'indian_woocommerce_states' );
function indian_woocommerce_states( $states ) {
$states['IN'] = array(
'AP' => __('Andra Pradesh', 'woocommerce'),