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. | |
| */ | |
| function wb_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 ), | |
| ); | |
| 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 a custom field (in an order) to the emails. | |
| */ | |
| function wb_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order ) { | |
| $fields['hear_about_us'] = array( | |
| 'label' => __( 'Hear About Us' ), | |
| 'value' => get_post_meta( $order->id, 'hear_about_us', true ), | |
| ); | |
| 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
| /** | |
| * Allow customers to access wp-admin. | |
| */ | |
| add_filter( 'woocommerce_prevent_admin_access', '__return_false' ); | |
| add_filter( 'woocommerce_disable_admin_bar', '__return_false' ); |
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
| /** | |
| * Automatically add product to cart on visit. | |
| */ | |
| function wb_add_product_to_cart() { | |
| if ( ! is_admin() ) { | |
| $product_id = 38; // replace with your own product id. | |
| $found = false; | |
| // check if product already in cart. | |
| if ( sizeof( WC()->cart->get_cart() ) > 0 ) { | |
| foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) { |
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 another product depending on the cart total. | |
| */ | |
| function wb_add_product_to_cart() { | |
| if ( ! is_admin() ) { | |
| global $woocommerce; | |
| $product_id = 38; // replace with your product id. | |
| $found = false; | |
| $cart_total = 30; // replace with your cart total needed to add above item. |
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 weight on archive or shop pages. | |
| */ | |
| function wb_show_weights() { | |
| global $product; | |
| $weight = $product->get_weight(); | |
| if ( $product->has_weight() ) { | |
| echo '<div class="product-meta"><span class="product-meta-label">Weight: </span>' . $weight . get_option( 'woocommerce_weight_unit' ) . '</div></br>'; |
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
| /** | |
| * Prevent PO box shipping. | |
| */ | |
| function wb_deny_pobox_postcode( $posted ) { | |
| global $woocommerce; | |
| $address = ( isset( $posted['shipping_address_1'] ) ) ? $posted['shipping_address_1'] : $posted['billing_address_1']; | |
| $postcode = ( isset( $posted['shipping_postcode'] ) ) ? $posted['shipping_postcode'] : $posted['billing_postcode']; | |
| $replace = 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
| /** | |
| * Notify admin when a new customer account is created. | |
| */ | |
| function wb_woocommerce_created_customer_admin_notification( $customer_id ) { | |
| wp_send_new_user_notifications( $customer_id, 'admin' ); | |
| } | |
| add_action( 'woocommerce_created_customer', 'wb_woocommerce_created_customer_admin_notification' ); |
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 product attribute archive links. | |
| */ | |
| function wb_wc_show_attribute_links() { | |
| global $post; | |
| $attribute_names = array( 'pa_color', 'pa_size' ); // Add attribute names here and remember to add the pa_ prefix to the attribute name. | |
| foreach ( $attribute_names as $attribute_name ) { | |
| $taxonomy = get_taxonomy( $attribute_name ); |
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
| /** | |
| * Trim zeros in price decimals. | |
| */ | |
| add_filter( 'woocommerce_price_trim_zeros', '__return_true' ); |