This file contains hidden or 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( 'product_upsells', 'wc_upsells_shortcode' ); | |
| function wc_upsells_shortcode( $atts ) { | |
| extract( shortcode_atts( array( | |
| 'posts_per_page' => '-1', | |
| 'columns' => '2', | |
| 'orderby' => 'rand' | |
| ), $atts ) ); | |
| woocommerce_get_template( 'single-product/up-sells.php', array( | |
| 'posts_per_page' => $posts_per_page, |
This file contains hidden or 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('add_to_cart_redirect', 'custom_add_to_cart_redirect'); | |
| function custom_add_to_cart_redirect( $url ) { | |
| $product_id = (int) $_REQUEST['add-to-cart']; | |
| if ( class_exists( 'WC_Subscriptions_Product' ) ) { | |
| if ( WC_Subscriptions_Product::is_subscription( $product_id ) ) { | |
| return get_permalink(get_option( 'woocommerce_checkout_page_id' ) ); | |
| } else return $url; | |
| } else return $url; | |
| } |
This file contains hidden or 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 | |
| // Delete Account Functionality | |
| add_action( 'woocommerce_after_my_account', 'woo_delete_account_button' ); | |
| function woo_delete_account_button() { | |
| ?> | |
| <a href="<?php echo add_query_arg( 'wc-api', 'wc-delete-account', home_url( '/' ) ) ?>" class="button">Delete Account</a> | |
| <?php | |
| } | |
| add_action( 'woocommerce_api_' . strtolower( 'wc-delete-account' ), 'woo_handle_account_delete' ); |
This file contains hidden or 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_main_after', 'woocommerce_get_sidebar', 10 ); | |
| add_action( 'woo_main_after', 'woo_custom_sidebar', 10 ); | |
| function woo_custom_sidebar() { | |
| if ( ! is_product() ) { | |
| woocommerce_get_sidebar(); | |
| } | |
| } | |
| remove_action( 'woocommerce_before_main_content', 'shelflife_before_content', 10 ); |
This file contains hidden or 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_email_headers', 'woo_cc_emails' ); | |
| function woo_cc_emails() { | |
| return 'Bcc: youremail@yourdomain.com' . "\r\n"; | |
| } | |
| ?> |
This file contains hidden or 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; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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; |