Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi jade.stewart,

    Try using another plugin call “WooCommerce Pay for Payment”

    Hi mamatobaby,

    I made a change on one of the function in “woocommerce-add-extra-charges-option-to-payment-gateways.php” and it seems to work with the paypal percentage. Maybe you can try this and see if it works:

    public function calculate_totals( $totals ) {
        global $woocommerce;
        $available_gateways = $woocommerce->payment_gateways->get_available_payment_gateways();
        $current_gateway = '';
        if ( ! empty( $available_gateways ) ) {
               // Chosen Method
            if ( isset( $woocommerce->session->chosen_payment_method ) && isset( $available_gateways[ $woocommerce->session->chosen_payment_method ] ) ) {
                $current_gateway = $available_gateways[ $woocommerce->session->chosen_payment_method ];
            } elseif ( isset( $available_gateways[ get_option( 'woocommerce_default_gateway' ) ] ) ) {
                $current_gateway = $available_gateways[ get_option( 'woocommerce_default_gateway' ) ];
            } else {
                $current_gateway =  current( $available_gateways );
    
            }
        }
        if($current_gateway!=''){
            $current_gateway_id = $current_gateway -> id;
            $extra_charges_id = 'woocommerce_'.$current_gateway_id.'_extra_charges';
            $extra_charges_type = $extra_charges_id.'_type';
            $extra_charges = (float)get_option( $extra_charges_id);
            $extra_charges_type_value = get_option( $extra_charges_type);
            if($extra_charges){
                if($extra_charges_type_value=="percentage"){
                    //$totals -> cart_contents_total = $totals -> cart_contents_total + round(($totals -> cart_contents_total*$extra_charges)/100);
                    $totals -> cart_contents_total = $totals -> cart_contents_total + round(($totals -> cart_contents_total*$extra_charges)/100, 1, PHP_ROUND_HALF_UP);
               }else{
                    $totals -> cart_contents_total = $totals -> cart_contents_total + $extra_charges;
                }
                $this -> current_gateway_title = $current_gateway -> title;
                $this -> current_gateway_extra_charges = $extra_charges;
                $this -> current_gateway_extra_charges_type_value = $extra_charges_type_value;
                add_action( 'woocommerce_review_order_before_order_total',  array( $this, 'add_payment_gateway_extra_charges_row'));
    
            }
    
        }
        return $totals;
    }

    hi mamatobaby & mokarrako,

    Are you all using percentage for paypal?

    @davewgill This is what I am looking for! Thank you so much! ??

Viewing 4 replies - 1 through 4 (of 4 total)