S
S
Sanyok2020-05-18 19:11:29
WooCommerce
Sanyok, 2020-05-18 19:11:29

How to make an extra charge for payment by card?

Good afternoon! Woocommerce is installed, standard "By bank" and via paypal are included for payment. The question is - how best to implement the following - automatic "margin" for paying by paypal? For example, if you choose this payment method, then an extra charge of 100 rubles or 3 percent of the order amount is immediately added, for example?
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WP Panda, 2020-05-18
@alexander1900

100 rubles - so

add_filter( 'woocommerce_cart_calculate_fees', 'add_my_fee', 10, 1 );
 
function add_my_fee() {
    $gateway = WC()->session->get( 'chosen_payment_method' );
     if ( $gateway == 'paypal' ) {
      WC()->cart->add_fee( 'Наценка за метод оплаты который нам не нравится', 100 );
   }
}

3% get the order amount, get 3 percent from it and substitute the received amount instead of 100 rubles

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question