This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Limit the values customer can enter using measurement price calculator area ( LxW ) option | |
add_action( 'wp_head', 'limit_measurement_values', 99 ); | |
function limit_measurement_values() { | |
if ( is_product() ) { | |
?> | |
<script> | |
jQuery( document ).ready(function() { | |
jQuery( '#length_needed' ).change( function() { | |
if ( jQuery( this ).val() > 100 ) jQuery( this ).val( 100 ).keyup(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add Now: R12, Was: R15, Save 20% price for items on sale | |
add_action( 'woocommerce_sale_price_html', 'wc_custom_sale_price', 10, 2 ); | |
function wc_custom_sale_price( $price, $product ) { | |
$percentage = round( ( ( $product->regular_price - $product->get_price() ) / $product->regular_price ) * 100 ); | |
return sprintf( __( 'Now: %s, Was: %s, Save %s', 'woocommerce' ), woocommerce_price( $product->get_price() ), woocommerce_price( $product->regular_price ), $percentage . '%' ); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add a once-of fee to the cart when certain items are in the cart | |
add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' ); | |
function woocommerce_custom_surcharge() { | |
global $woocommerce; | |
$apply_fee = false; | |
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) | |
return; | |
$product_ids = array( 1, 2, 3, 4 ); // Coma separated list of product id's that must be in cart for fee to apply | |
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Place the following code in your theme's functions.php file to add the shipping method to all emails | |
add_action( 'woocommerce_email_after_order_table', 'wc_add_shipping_method_to_emails', 15, 2 ); | |
function wc_add_shipping_method_to_emails( $order, $is_admin_email ) { | |
echo '<p><strong>Shipping Method:</strong> ' . $order->get_shipping_method() . '</p>'; | |
} | |
// Place the following code in your theme's functions.php file to add the shipping methid to admin emails only | |
add_action( 'woocommerce_email_after_order_table', 'wc_add_shipping_method_to_admin_emails', 15, 2 ); | |
function wc_add_shipping_method_to_admin_emails( $order, $is_admin_email ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Place the code below in your theme's functions.php file | |
add_filter( 'woocommerce_get_catalog_ordering_args', 'wc_get_catalog_ordering_args' ); | |
function wc_get_catalog_ordering_args( $args ) { | |
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) ); | |
if ( 'sales' == $orderby_value ) { | |
$args['orderby'] = 'meta_value_num'; | |
$args['order'] = 'DESC'; | |
$args['meta_key'] = 'total_sales'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Place the following code in your theme's functions.php file to add the payment type to all emails | |
add_action( 'woocommerce_email_after_order_table', 'wc_add_payment_type_to_emails', 15, 2 ); | |
function wc_add_payment_type_to_emails( $order, $is_admin_email ) { | |
echo '<p><strong>Payment Type:</strong> ' . $order->payment_method_title . '</p>'; | |
} | |
// Place the following code in your theme's functions.php file to add the payment type to admin emails only | |
add_action( 'woocommerce_email_after_order_table', 'wc_add_payment_type_to_admin_emails', 15, 2 ); | |
function wc_add_payment_type_to_admin_emails( $order, $is_admin_email ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_available_shipping_methods', 'wc_hide_free_shipping_based_on_weight' , 10, 1 ); | |
function wc_hide_free_shipping_based_on_weight( $available_methods ) { | |
if ( isset( $available_methods['free_shipping'] ) { | |
global $woocommerce; | |
$weight = 0; | |
if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) { | |
foreach ( $woocommerce->cart->get_cart() as $item_id => $values ) { | |
$_product = $values['data']; | |
if ( $_product->exists() && $values['quantity'] > 0 ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Allow auto updates of development releases ie alpha, beta and RC | |
add_filter( 'allow_dev_auto_core_updates', 'wp_control_dev_auto_updates' ); | |
function wp_control_dev_auto_updates( $value ) { | |
// return true to enable and false to disable | |
return true; | |
} | |
//Allow auto updates of minor releases ie 3.7.1, 3.7.2 | |
add_filter( 'allow_minor_auto_core_updates', 'wp_control_minor_auto_updates' ); | |
function wp_control_minor_auto_updates( $value ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Enable Automatic Updates for all updates | |
define( 'WP_AUTO_UPDATE_CORE', true ); | |
// Disable Automatic Updates for all updates | |
define( 'WP_AUTO_UPDATE_CORE', false ); | |
// Only allow Automatic Updates for minor updates | |
define( 'WP_AUTO_UPDATE_CORE', 'minor' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_shortcode( 'list_vendors', 'wc_list_vendors_shortcode' ); | |
function wc_list_vendors_shortcode( $atts ) { | |
$vendors = ''; | |
$terms = get_terms( 'shop_vendor' ); | |
foreach ( $terms as $term ) { | |
$term_link = get_term_link( $term, 'shop_vendor' ); | |
if ( is_wp_error( $term_link ) ) | |
continue; | |
$vendors .= '<h2><a href="' . $term_link . '">' . $term->name . '</a></h2>'; | |
} |