• Resolved wpdevs2022

    (@wpdevs2022)


    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)
  • Hi @wpdevs2022

    Thanks for reaching out!

    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.

    Checking our marketplace, I found the premium plugin Checkout Field Editor seems fit to what you’re trying to achieve here. The Checkout Field Editor provides you with an interface to add, edit, and remove fields shown on your WooCommerce checkout page.?Fields can be added and removed from the billing and shipping sections, as well as inserted after these sections next to the standard ‘order notes’.

    If you want to try our products, please note we have a 30-day refund policy.

    If the product doesn’t work the way you need it or you think another product would work better, we are more than happy to offer a full refund. You can read more about our refund policy on our website here.

    I want to change the underlined part, so that it displays a static text message.

    Kindly be informed that custom coding is outside our scope of support, hence, I am leaving this thread open for a bit to see if anyone can chime in to help you out.

    For questions related to development and custom coding, your best bet is to ask on any of these channels for support. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, too.

    Hope this helps!

Viewing 1 replies (of 1 total)
  • The topic ‘Display static text in place of shipping charges’ is closed to new replies.