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( '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 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 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 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 | |
| // 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 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
| // 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 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 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 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
| add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10); | |
| add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10); | |
| function my_theme_wrapper_start() { | |
| echo '<div class="fixed">'; | |
| echo '<div class="content-home-right">'; | |
| } | |
| function my_theme_wrapper_end() { | |
| echo '</div>'; |
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
| function woocommerce_content() { | |
| if ( is_singular( 'product' ) ) { | |
| while ( have_posts() ) : the_post(); | |
| woocommerce_get_template_part( 'content', 'single-product' ); | |
| endwhile; |
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
| add_filter( 'woocommerce_bacs_fields', 'woocommerce_bacs_custom_sort_code_text', 10, 1 ); | |
| function woocommerce_bacs_custom_sort_code_text( $fields ) { | |
| $fields['sort_code'] = 'BSB'; | |
| return $fields; | |
| } |
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
| add_filter( 'woocommerce_is_sold_individually', 'wc_remove_all_quantity_fields', 10, 2 ); | |
| function wc_remove_all_quantity_fields( $return, $product ) { | |
| if ( is_product() ) | |
| return true; | |
| else return $return; | |
| } |
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
| add_filter( 'woocommerce_get_price_html', 'woocommerce_nyp_min_price', 11, 2 ); | |
| function woocommerce_nyp_min_price( $price, $product ) { | |
| if ( !$product->nyp ) | |
| return $price; | |
| if( is_shop() || is_product_category() || is_product_tag() ) { | |
| $price = woocommerce_price( $product->minimum ); | |
| } | |
| return $price; |