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
| /** | |
| * Show product dimensions on archive pages for WC 3+. | |
| */ | |
| function wb_show_dimensions() { | |
| global $product; | |
| $dimensions = wc_format_dimensions( $product->get_dimensions( false ) ); | |
| if ( $product->has_dimensions() ) { | |
| echo '<div class="product-meta"><span class="product-meta-label">Dimensions: </span>' . $dimensions . '</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
| /** | |
| * Show product dimensions on archive pages WC 3 and below. | |
| */ | |
| function wb_wc_show_dimensions() { | |
| global $product; | |
| $dimensions = $product->get_dimensions(); | |
| if ( ! empty( $dimensions ) ) { | |
| echo '<span class="dimensions">' . $dimensions . '</span>'; | |
| } |
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
| /** | |
| * Unhook and remove WooCommerce default emails. | |
| */ | |
| function wb_unhook_those_pesky_emails( $email_class ) { | |
| /** | |
| * Hooks for sending emails during store events. | |
| */ | |
| remove_action( 'woocommerce_low_stock_notification', array( $email_class, 'low_stock' ) ); | |
| remove_action( 'woocommerce_no_stock_notification', array( $email_class, 'no_stock' ) ); |
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
| /** | |
| * Hide shipping rates when free shipping is available. | |
| * Updated to support WooCommerce 2.6 Shipping Zones. | |
| * | |
| * @param array $rates Array of rates found for the package. | |
| * @return array | |
| */ | |
| function wb_hide_shipping_when_free_is_available( $rates ) { | |
| $free = array(); | |
| foreach ( $rates as $rate_id => $rate ) { |
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
| /** | |
| * Hide shipping rates when free shipping is available, but keep "Local pickup". | |
| * Updated to support WooCommerce 2.6 Shipping Zones. | |
| */ | |
| function wb_hide_shipping_when_free_is_available( $rates, $package ) { | |
| $new_rates = array(); | |
| foreach ( $rates as $rate_id => $rate ) { | |
| // Only modify rates if free_shipping is present. | |
| if ( 'free_shipping' === $rate->method_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
| /** | |
| * Hide ALL shipping options when free shipping is available and customer is NOT in certain states. | |
| * | |
| * Change $excluded_states = array( 'AK','HI','GU','PR' ); to include all the states that DO NOT have free shipping. | |
| */ | |
| function wb_hide_all_shipping_when_free_is_available( $rates, $package ) { | |
| $excluded_states = array( 'AK', 'HI', 'GU', 'PR' ); | |
| if ( isset( $rates['free_shipping'] ) and ! in_array( WC()->customer->shipping_state, $excluded_states ) ) : | |
| // Get Free Shipping array into a new array. |
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
| /** | |
| * Rename a country. | |
| */ | |
| function wb_rename_ireland( $countries ) { | |
| $countries['IE'] = 'Ireland'; | |
| return $countries; | |
| } | |
| add_filter( 'woocommerce_countries', 'wb_rename_ireland' ); |
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
| /** | |
| * Change a currency symbol. | |
| */ | |
| function wb_change_existing_currency_symbol( $currency_symbol, $currency ) { | |
| switch ( $currency ) { | |
| case 'AUD': | |
| $currency_symbol = 'AUD$'; | |
| break; | |
| } | |
| return $currency_symbol; |
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
| /** | |
| * Set a minimum order amount for checkout. | |
| */ | |
| function wb_wc_minimum_order_amount() { | |
| // Set this variable to specify a minimum order value. | |
| $minimum = 50; | |
| if ( WC()->cart->total < $minimum ) { | |
| if ( is_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
| /** | |
| * Change number of products that are displayed per page (shop page). | |
| */ | |
| function wb_loop_shop_per_page( $cols ) { | |
| // $cols contains the current number of products per page based on the value stored on Options -> Reading. | |
| // Return the number of products you wanna show per page. | |
| $cols = 9; | |
| return $cols; | |
| } | |
| add_filter( 'loop_shop_per_page', 'wb_loop_shop_per_page', 20 ); |