Add a custom fee to the cart in WooCommerce
This code snippet adds a custom fee to the cart in WooCommerce. The fee is $5 and is labeled "Custom".
PHP
add_action( 'woocommerce_cart_calculate_fees', 'custom_fee' );
function custom_fee() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
$woocommerce->cart->add_fee( __('Custom', 'woocommerce'), 5 );
}
Snippet Feedback
Did this snippet work for you? Do you have any questions about this snippet? Leave some feedback below.
SHARED BY