Display static text in place of shipping charges
-
Hello, I have multiple product categories in my site. But for a particular category, I want to display a static text in place of shipping charges, so that we can modify and add shipping charges later from backend.
There will be two items to display for that particular product in hipping section.
1. Static Text : We will contact you and add shipping charge.
2. Pickup from Warehouse.Can anyone help me to achieve this.
I have tried the below code, but not working.
add_filter( 'woocommerce_package_rates', 'product_category_hide_shipping_methods', 90, 2 ); function product_category_hide_shipping_methods( $rates, $package ){ $categories = array( 'tshirts'); $found = false; // Loop through each cart item Checking for the defined product categories foreach( $package['contents'] as $cart_item ) { if ( has_term( $categories, 'product_cat', $cart_item['product_id'] ) ){ $found = true; break; } } $rates_arr = array(); if ( $found ) { foreach($rates as $rate_id => $rate) { if ('local_pickup' === $rate->method_id) { $rates_arr[ $rate_id ] = $rate; } <span style="text-decoration: underline;"> if ('flat_rate' === $rate->method_id) { $rates_arr[ $rate_id ] = $rate;</span> } } } return !empty( $rates_arr ) ? $rates_arr : $rates; }
I want to change the underlined part, so that it displays a static text message.
Thanks.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Display static text in place of shipping charges’ is closed to new replies.