Add Custom Fee to Cart
This snippet adds a custom fee to the cart total, which can be useful for handling additional charges or discounts.
PHP
function add_custom_fee() {
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
WC()->cart->add_fee( 'Custom Fee', 5.00 );
}
add_action( 'woocommerce_cart_calculate_fees', 'add_custom_fee' );
Snippet Feedback
Did this snippet work for you? Do you have any questions about this snippet? Leave some feedback below.
SHARED BY