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
| <? | |
| /* | |
| *Product ajax search code | |
| *[woo_search num="5" sku="on" description="on" price="on"] | |
| */ | |
| add_shortcode("woo_search", "woo_search_func"); | |
| function woo_search_func($atts) | |
| { | |
| $atts = shortcode_atts( | |
| [ |
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 deault sorting by sku in catalogue page | |
| function add_sku_sorting_msr( $args ) { | |
| $orderby_value = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) ); | |
| if ( 'sku' == $orderby_value ) { | |
| $args['orderby'] = 'meta_value'; | |
| $args['order'] = 'asc'; // lists SKUs alphabetically 0-9, a-z; change to desc for reverse alphabetical | |
| $args['meta_key'] = '_sku'; |
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 | |
| //show sku in shop | |
| add_action( 'woocommerce_after_shop_loop_item_title', 'db_show_sku_msr', 10 ); | |
| function db_show_sku_msr(){ | |
| global $product; | |
| echo '<span style="color:#000000; font-size: 18px;" class="custom_sku">SKU: ' . $product->get_sku() . '</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
| <?php | |
| //show sku | |
| function return_sku_msr( $product ){ | |
| $sku = $product->get_sku(); | |
| if ( ! empty( $sku ) ) { | |
| return '<p>SKU: ' . $sku . '</p>'; | |
| } else {return '';}} | |
| // This adds the SKU under cart/checkout item name | |
| add_filter( 'woocommerce_cart_item_name', 'bbloomer_sku_cart_checkout_pages_msr', 9999, 3 ); | |
| function bbloomer_sku_cart_checkout_pages_msr( $item_name, $cart_item, $cart_item_key ) { |
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 | |
| function return_sku_msr( $product ){ | |
| $sku = $product->get_sku(); | |
| if ( ! empty( $sku ) ) { | |
| return '<p>SKU: ' . $sku . '</p>'; | |
| } else {return '';} | |
| } | |
| //This adds SKU under order item table name EMAIL | |
| add_action( 'woocommerce_order_item_meta_start', 'thankyou_order_email_pages_msr', 9999, 4 ); | |
| function thankyou_order_email_pages_msr( $item_id, $item, $order, $plain_text ) { |
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_email_order_items_args', 'order_with_product_images_msr', 10 ); | |
| function order_with_product_images_msr( $args ) { | |
| $args['show_image'] = true; | |
| $args['image_size'] = array( 100, 100 ); | |
| return $args; | |
| } |
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_variable_add_to_cart', 'update_price_with_variation_price_msr' ); | |
| function update_price_with_variation_price_msr() { | |
| global $product; | |
| $price = $product->get_price_html(); | |
| wc_enqueue_js( " | |
| $(document).on('found_variation', 'form.cart', function( event, variation ) { | |
| if(variation.price_html) $('.summary > p.price').html(variation.price_html); | |
| $('.woocommerce-variation-price').hide(); |
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_order_item_name', 'add_email_order_item_permalink_msr', 10, 2 ); // Product name | |
| function add_email_order_item_permalink_msr( $output_html, $item, $bool = false ) { | |
| // Only email notifications | |
| if( is_wc_endpoint_url() ) | |
| return $output_html; | |
| $product = $item->get_product(); | |
| return '<a href="'.esc_url( $product->get_permalink() ).'">' . $output_html . '</a>'; | |
| } |
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 | |
| function search_by_sku_msr( $search, $query_vars ) { | |
| global $wpdb; | |
| if(isset($query_vars->query['s']) && !empty($query_vars->query['s'])){ | |
| $args = array( | |
| 'posts_per_page' => -1, | |
| 'post_type' => 'product', | |
| 'meta_query' => array( | |
| array( | |
| 'key' => '_sku', |
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
| <? | |
| //reorder my account page menu | |
| add_filter( 'woocommerce_account_menu_items', 'menu_links_reorder_msr' ); | |
| function menu_links_reorder_msr( $menu_links ){ | |
| return array( | |
| 'edit-account' => __( 'Account details', 'woocommerce' ), | |
| 'orders' => __( 'Orders', 'woocommerce' ), | |
| 'prev-prod'=> __( 'My previous products', 'woocommerce' ), | |
| 'edit-address' => __( 'Addresses', 'woocommerce' ), | |
| 'customer-logout' => __( 'Logout', 'woocommerce' ) |
NewerOlder