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
| /** | |
| * Display category image on category archive | |
| */ | |
| add_action( 'woocommerce_archive_description', 'woocommerce_category_image', 2 ); | |
| function woocommerce_category_image() { | |
| if ( is_product_category() ){ | |
| global $wp_query; | |
| $cat = $wp_query->get_queried_object(); | |
| $thumbnail_id = get_term_meta( $cat->term_id, 'thumbnail_id', true ); | |
| $image = wp_get_attachment_url( $thumbnail_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
| /** | |
| * Change number of products that are displayed per page (shop page) | |
| */ | |
| add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 ); | |
| function new_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; |
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
| /** | |
| * Custom currency and currency symbol | |
| */ | |
| add_filter( 'woocommerce_currencies', 'add_my_currency' ); | |
| function add_my_currency( $currencies ) { | |
| $currencies['ABC'] = __( 'Currency name', 'woocommerce' ); | |
| return $currencies; | |
| } |
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 | |
| */ | |
| add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2); | |
| function 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
| /** | |
| * Notify admin when a new customer account is created | |
| */ | |
| add_action( 'woocommerce_created_customer', 'woocommerce_created_customer_admin_notification' ); | |
| function woocommerce_created_customer_admin_notification( $customer_id ) { | |
| wp_send_new_user_notifications( $customer_id, 'admin' ); | |
| } |
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
| /* | |
| * goes in theme functions.php or a custom plugin | |
| * | |
| * Subject filters: | |
| * woocommerce_email_subject_new_order | |
| * woocommerce_email_subject_customer_processing_order | |
| * woocommerce_email_subject_customer_completed_order | |
| * woocommerce_email_subject_customer_invoice | |
| * woocommerce_email_subject_customer_note | |
| * woocommerce_email_subject_low_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
| /** | |
| * Send an email each time an order with coupon(s) is completed | |
| * The email contains coupon(s) used during checkout process | |
| * | |
| */ | |
| function woo_email_order_coupons( $order_id ) { | |
| $order = new WC_Order( $order_id ); | |
| if( $order->get_used_coupons() ) { | |
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 a custom field (in an order) to the emails | |
| */ | |
| add_filter( 'woocommerce_email_order_meta_fields', 'custom_woocommerce_email_order_meta_fields', 10, 3 ); | |
| function custom_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order ) { | |
| $fields['meta_key'] = array( | |
| 'label' => __( 'Label' ), | |
| 'value' => get_post_meta( $order->id, 'meta_key', 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
| /** | |
| * Unhook and remove WooCommerce default emails. | |
| */ | |
| add_action( 'woocommerce_email', 'unhook_those_pesky_emails' ); | |
| function unhook_those_pesky_emails( $email_class ) { | |
| /** | |
| * Hooks for sending emails during store events | |
| **/ |
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 my_hide_shipping_when_free_is_available( $rates ) { | |
| $free = array(); | |
| foreach ( $rates as $rate_id => $rate ) { |