1

enter image description here

I need add "Include pack" line with conditional logic to WooCommerce checkout review order section. How it possible?

1

You could use the Fee API that will create in totals line below shipping optionsCode goes in function.php file of your active child theme (or active theme). Tested and works., based on the shipping total x 1.5 (+50%), where you can include your conditional logic, like:

add_action( 'woocommerce_cart_calculate_fees','custom_pack_fee', 10 , 1 );
function custom_pack_fee( $cart ) {
    if ( is_admin() && ! defined( 'DOING_AJAX' ) )
        return;

    if ( ! is_chekout() )
        return;

    // Add your conditional logic and calculations below

    $percentage     = 1.5; // Percentage (150%)
    $shipping_total = $cart->get_shipping_total();

    if ( $shipping_total > 0 ) {
        $cart->add_fee( __('Include pack', 'woocommerce'), ($shipping_total * $percentage), true );
    }
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.