• Resolved kolumb55

    (@kolumb55)


    What is the snippet to move shipping_method in Delivery Note?
    I want to remove shipping_method from order-items and move it under order-addresses section.

Viewing 1 replies (of 1 total)
  • Plugin Author priyankajagtap

    (@priyankajagtap)

    Hi @kolumb55,

    Sorry for the delay in response to this.

    I have forwarded your mentioned requirement to our development team.
    Our developer has added a filter to our plugin and created the custom code to achieve your requirements.

    Here is the link to download the “print-content.php” file of our plugin that contains the filter code: https://www.dropbox.com/scl/fi/ewx9mxn9rxhynv5gkmwf0/print-content.php?rlkey=4fo8d0wx2l11j2aqn2ox0pnzb&dl=0

    Kindly download this file and replace it with the existing file at: plugins\woocommerce-delivery-notes\templates\print-order\<HERE>

    Once you have replaced the above file, please add these below code snippets under the “functions.php” file of your currently active theme.

    //Remove shipping from order-item
    function modify_order_item_extra( $totals_arr ) {
        if ( isset( $totals_arr['shipping'] ) ) {
            unset( $totals_arr['shipping'] );
        }
        return $totals_arr;
    }
    
    // Hook into the filter to apply modifications
    add_filter( 'wcdn_order_extra_item', 'modify_order_item_extra' );
    // Add shipping method to shipping address in WooCommerce delivery notes
    function custom_wcdn_address_shipping( $formatted_address, $order ) {
        $shipping_method = $order->get_shipping_method();
        // Append shipping method to the formatted shipping address
        $formatted_address .= '<p><strong>' . esc_html__( 'Shipping Method:', 'woocommerce-delivery-notes' ) . '</strong> ' . esc_html( $shipping_method ) . '</p>';
        return $formatted_address;
    }
    add_filter( 'wcdn_address_shipping', 'custom_wcdn_address_shipping', 10, 2 );
    
    // Add shipping method to billing address in WooCommerce delivery notes
    function custom_wcdn_address_billing( $formatted_address, $order ) {
        $shipping_method = $order->get_shipping_method();
        // Append shipping method to the formatted billing address
        $formatted_address .= '<p><strong>' . esc_html__( 'Shipping Method:', 'woocommerce-delivery-notes' ) . '</strong> ' . esc_html( $shipping_method ) . '</p>';
        return $formatted_address;
    }
    add_filter( 'wcdn_address_billing', 'custom_wcdn_address_billing', 10, 2 );

    Screenshot of how the shipping method will be displayed in the order-addresses section: https://prnt.sc/dga2RTtutBxX

    Please check and let me know if the provided code snippet is working as per your requirement or not.

Viewing 1 replies (of 1 total)
  • The topic ‘Delivery Note. How to move shipping under addresses’ is closed to new replies.