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 save percent next to sale item prices. | |
add_filter( 'woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2 ); | |
function woocommerce_custom_sales_price( $price, $product ) { | |
$percentage = round( ( ( $product->regular_price - $product->sale_price ) / $product->regular_price ) * 100 ); | |
return $price . sprintf( __(' Save %s', 'woocommerce' ), $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
// check for clear-cart get param to clear the cart, append ?clear-cart to any site url to trigger this | |
add_action( 'init', 'woocommerce_clear_cart_url' ); | |
function woocommerce_clear_cart_url() { | |
if ( isset( $_GET['clear-cart'] ) ) { | |
global $woocommerce; | |
$woocommerce->cart->empty_cart(); | |
} | |
} |
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 | |
// check that cart items quantities totals are in multiples of 6 | |
add_action( 'woocommerce_check_cart_items', 'woocommerce_check_cart_quantities' ); | |
function woocommerce_check_cart_quantities() { | |
$multiples = 6; | |
$total_products = 0; | |
foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) { | |
$total_products += $values['quantity']; | |
} | |
if ( ( $total_products % $multiples ) > 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
<?php | |
// add custom field to invoice email | |
add_action( 'woocommerce_email_after_order_table', 'woocommerce_custom_invoice_fields' ); | |
function woocommerce_custom_invoice_fields( $order ) { | |
?> | |
<p><strong><?php _e('Free Book:', 'woocommerce'); ?></strong> <?php echo get_post_meta( $order->id, 'Free Book', true ); ?></p> | |
<p><strong><?php _e('Free DVD:', 'woocommerce'); ?></strong> <?php echo get_post_meta( $order->id, 'Free DVD', true ); ?></p> | |
<p><strong><?php _e('Gift:', 'woocommerce'); ?></strong> <?php echo get_post_meta( $order->id, 'Gift Order', true ); ?></p> | |
<p><strong><?php _e('Gift Message:', 'woocommerce'); ?></strong> <?php echo get_post_meta( $order->id, 'Special Gift Message', true ); ?></p> | |
<?php |
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_shortcode( 'sale_products', 'sale_products' ); | |
function sale_products( $atts ){ | |
global $woocommerce_loop, $woocommerce; | |
extract( shortcode_atts( array( | |
'per_page' => '12', | |
'columns' => '4', | |
'orderby' => 'title', | |
'order' => 'asc' |
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_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' ); | |
function custom_woocommerce_get_catalog_ordering_args( $args ) { | |
if( isset ( $_SESSION['orderby'] ) ) { | |
switch ( $_SESSION['orderby'] ) { | |
case 'sku_asc' : | |
$args['orderby'] = 'meta_value'; | |
$args['order'] = 'asc'; | |
$args['meta_key'] = '_sku'; | |
break; |
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 | |
// Exclude coupons from being applied when products on sale | |
add_filter( 'woocommerce_coupon_is_valid', 'woocommerce_coupon_check_sale_items', 10, 2 ); | |
function woocommerce_coupon_check_sale_items( $valid, $coupon ) { | |
global $woocommerce; | |
$valid_for_cart = $valid; | |
if (sizeof($woocommerce->cart->get_cart())>0) : foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) : | |
if ( function_exists( 'get_product') ) | |
$product = get_product( $cart_item['product_id'] ); |
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_payment_complete_order_status', 'virtual_order_payment_complete_order_status', 10, 2 ); | |
function virtual_order_payment_complete_order_status( $order_status, $order_id ) { | |
$order = new WC_Order( $order_id ); | |
if ( $order_status == 'processing' && | |
( $order->status == 'on-hold' || $order->status == 'pending' || $order->status == 'failed' ) ) { | |
$virtual_order = true; | |
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
#Zeus webserver version of basic Wordpress mod_rewrite rules | |
map path into SCRATCH:path from %{URL} | |
look for file at %{SCRATCH:path} | |
if exists then goto END | |
look for dir at %{SCRATCH:path} | |
if exists then goto END | |
##### FIX FOR LOGIN/FORGOTTEN PASSWORD/ADMIN ETC ##### | |
match URL into $ with ^/wp-.*$ | |
if matched then goto END | |
set URL = /index.php |
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 | |
remove_action( 'woo_nav_inside', 'woo_add_nav_cart_link' ); | |
add_filter( 'wp_nav_menu_items', 'woo_move_cart_to_top_nav', 10, 2 ); | |
function woo_move_cart_to_top_nav( $items, $args ) { | |
global $woocommerce; | |
if ( $args->menu_id == 'top-nav' ) { | |
$items .= '<li><a class="cart-contents" href="'.esc_url( $woocommerce->cart->get_cart_url() ).'" title="'.esc_attr_e( 'View your shopping cart', 'woothemes' ).'">'.sprintf( _n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes' ), $woocommerce->cart->cart_contents_count ).' - '.$woocommerce->cart->get_cart_total().'</a></li>'; | |
} | |
return $items; |