Add Extra Charges In Woocommerce Cart

If you want to apply extra fee in the cart then Woocommerce provide an action for applying a fee on the cart.

The fee can be used as shipping fee, installation fee or whatever as per your requirement.

add_action( ‘woocommerce_cart_calculate_fees’, ‘add_extra_cart_fee’ ,10,1 );
This action calculates the total fee and adds into the cart amount.

This Woocommerce function is used to add the fee to Woocommerce cart.

How to use it ?

<?php
add_action( ‘woocommerce_cart_calculate_fees’, ‘add_extra_cart_fee’ ,10,1 );
function add_extra_cart_fee( $cart_object ) {

global $woocommerce;
$spfee = 14.00; // initialize special fee
$woocommerce-&gt;cart-&gt;add_fee( ‘Extra Tax Fee’, $spfee, true, ‘standard’ );

}
?>

From: https://www.linkedin.com/pulse/add-fee-woocommerce-cart-vishal-patel

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s