Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Add fee for specific shipping/payment method combo
- add_action( 'woocommerce_cart_calculate_fees', 'mx_add_fee_to_checkout' );
- function mx_add_fee_to_checkout() {
- $chosen_gateway = WC()->session->get( 'chosen_payment_method' );
- $chosen_methods = WC()->session->get( 'chosen_shipping_methods');
- $chosen_shipping = $chosen_methods[0];
- if ( ($chosen_gateway == 'cod') && 0 === strpos($chosen_shipping, 'flat_rate:2')) {
- WC()->cart->add_fee( 'Extra Fee for COD & Flat rate', 5 );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement