You can add a custom fee to shipping cost in WooCommerce by using a filter hook called woocommerce_cart_shipping_total. This filter hook is called when the shipping cost is calculated in the cart. You can use this hook to add your custom fee to the shipping cost.

Here’s how you can add a custom fee directly into shipping cost in WooCommerce:

  1. Add the following code to your theme’s functions.php file:
phpCopy codeadd_filter( 'woocommerce_cart_shipping_total', 'add_custom_shipping_fee', 10, 2 );

function add_custom_shipping_fee( $shipping_total, $cart ) {
    $custom_fee = 10; // Your custom fee amount
    $shipping_total += $custom_fee;
    return $shipping_total;

In this code, the add_custom_shipping_fee function adds a custom fee of $10 to the shipping cost. You can change the value of $custom_fee to any amount you want.

  1. Save the functions.php file.

With these steps, a custom fee will be added to the shipping cost in WooCommerce.

(Visited 14 times, 1 visits today)
Was this article helpful?
Close Search Window