Add Percentage as Fee for order over $5k
-
Hello,
I’ve been reading through tutorials but I’m not quite able to figure this problem out. We use Paypal to accept payments and would like to charge a 3% fee for orders that are $5,000 and over.
Currently I have it setup so that payment is not accepted for orders over a certain limit because we want to make sure that this fee is in place first.
Can someone explain to me what would need to be added in a Snippet?
I’ve been reading through this:
https://awhitepixel.com/blog/woocommerce-checkout-add-custom-fees/The following are what is at the link. I need to charge a fee for order totals(including shipping and tax) over $5k and I need the fee to be 3% of the total.
add_action('woocommerce_cart_calculate_fees', function() { if (is_admin() && !defined('DOING_AJAX')) { return; } $cart_total = WC()->cart->get_cart_contents_total(); // This is excluding shipping if ($cart_total < 500) { WC()->cart->add_fee(__('Fee for small transactions', 'txtdomain'), 50); } });
add_action('woocommerce_cart_calculate_fees', function() { if (is_admin() && !defined('DOING_AJAX')) { return; } $percentage = 0.05; // Percentage (5%) in float $percentage_fee = (WC()->cart->get_cart_contents_total() + WC()->cart->get_shipping_total()) * $percentage; WC()->cart->add_fee(__('A small fee', 'txtdomain'), $percentage_fee); });
The page I need help with: [log in to see the link]
- The topic ‘Add Percentage as Fee for order over $5k’ is closed to new replies.