WordPress.org

Support

Support » Plugins and Hacks » woocommerce 2.1.1

woocommerce 2.1.1

Viewing 15 replies - 1 through 15 (of 15 total)
  • I also tried with woocommerce 2.12 and WP 3.8.1 and it’s not working!
    Please fix it, is a very useful plugin

    Please update it to Woocommerce 2.1.2
    Thanks!

    Please update!

    In function “woocommerce-add-extra-charges-option-to-payment-gateways.php” i Patched the function like this:

    function add_form_fields(){
            global $woocommerce;
             // Get current tab/section
            $current_tab        = ( empty( $_GET['tab'] ) ) ? '' : sanitize_text_field( urldecode( $_GET['tab'] ) );
            $current_section    = ( empty( $_REQUEST['section'] ) ) ? '' : sanitize_text_field( urldecode( $_REQUEST['section'] ) );
    		//if($current_tab == 'payment_gateways' && $current_section!=''){
    		if($current_tab == 'checkout' && $current_section!=''){
                $gateways = $woocommerce->payment_gateways->payment_gateways();
                foreach($gateways as $gateway){
    				if(strtolower(get_class($gateway))==$current_section){
    					$current_gateway = $gateway -> id;
                        $extra_charges_id = 'woocommerce_'.$current_gateway.'_extra_charges';
                        $extra_charges_type = $extra_charges_id.'_type';
                        if(isset($_REQUEST['save'])){
                            echo  $extra_charges_id."\n";
    						echo $extra_charges_type."\n";
    						update_option( $extra_charges_id, $_REQUEST[$extra_charges_id] );
                            update_option( $extra_charges_type, $_REQUEST[$extra_charges_type] );
                        }
                        $extra_charges = get_option( $extra_charges_id);
                        $extra_charges_type_value = get_option($extra_charges_type);
    
                    }
                }
    
                ?>
                <script>
                jQuery(document).ready(function($){
                    $data = '<h4>Add Extra Charges</h4><table class="form-table">';
                    $data += '<tr valign="top">';
                    $data += '<th scope="row" class="titledesc">Extra Charges</th>';
                    $data += '<td class="forminp">';
                    $data += '<fieldset>';
                    $data += '<input style="" name="<?php echo $extra_charges_id?>" id="<?php echo $extra_charges_id?>" type="text" value="<?php echo $extra_charges?>"/>';
                    $data += '<br /></fieldset></td></tr>';
                    $data += '<tr valign="top">';
                    $data += '<th scope="row" class="titledesc">Extra Charges Type</th>';
                    $data += '<td class="forminp">';
                    $data += '<fieldset>';
                    $data += '<select name="<?php echo $extra_charges_type?>"><option <?php if($extra_charges_type_value=="add") echo "selected=selected"?> value="add">Total Add</option>';
                    $data += '<option <?php if($extra_charges_type_value=="percentage") echo "selected=selected"?> value="percentage">Total % Add</option>';
                    $data += '<br /></fieldset></td></tr></table>';
                    $('.form-table:last').after($data);
    
                });
    </script>
    <?php
    }
    }

    Tell me if u encounter some issues.

    Thank you so much aaarghhh, it works!

    I just updated the plugin so it works with the new woocommerce update, but the formulation I’m using 5% rounds up (from .60 to 1.00) when adding on to an order. Is it supposed to be that way? Thanks.

    It’s also not adding that fee when checking out and going to paypal.

    I have the sema problem too, with this function dont aply the fee, then when i try to go to paypal dont works. Aaarghhh PLEASE HELP!!

    hi mamatobaby & mokarrako,

    Are you all using percentage for paypal?

    No, I looked into it and it’s actually against the terms and conditions of PayPal to charge/penalize your customer for choosing PayPal as the payment method.

    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;
    }

    if to make a charge to the customer for choosing PayPal is against the terms and conditions of PayPal we can make a discount if the customer choose other method, simply. But is there any plugin for discounts charges to payment method? F***ING PayPal!

    rod_lee yes i was using a percentage for Paypal, ill try your function. Thanks!!

    jade.stewart

    @jadestewartgmailcom

    I tryed adding the code `function add_form_fields(){

    global $woocommerce;
             // Get current tab/section
            $current_tab        = ( empty( $_GET['tab'] ) ) ? '' : sanitize_text_field( urldecode( $_GET['tab'] ) );
            $current_section    = ( empty( $_REQUEST['section'] ) ) ? '' : sanitize_text_field( urldecode( $_REQUEST['section'] ) );
    		//if($current_tab == 'payment_gateways' && $current_section!=''){
    		if($current_tab == 'checkout' && $current_section!=''){
                $gateways = $woocommerce->payment_gateways->payment_gateways();
                foreach($gateways as $gateway){
    				if(strtolower(get_class($gateway))==$current_section){
    					$current_gateway = $gateway -> id;
                        $extra_charges_id = 'woocommerce_'.$current_gateway.'_extra_charges';
                        $extra_charges_type = $extra_charges_id.'_type';
                        if(isset($_REQUEST['save'])){
                            echo  $extra_charges_id."\n";
    						echo $extra_charges_type."\n";
    						update_option( $extra_charges_id, $_REQUEST[$extra_charges_id] );
                            update_option( $extra_charges_type, $_REQUEST[$extra_charges_type] );
                        }
                        $extra_charges = get_option( $extra_charges_id);
                        $extra_charges_type_value = get_option($extra_charges_type);
    
                    }
                }
    
                ?>
                <script>
                jQuery(document).ready(function($){
                    $data = '<h4>Add Extra Charges</h4><table class="form-table">';
                    $data += '<tr valign="top">';
                    $data += '<th scope="row" class="titledesc">Extra Charges</th>';
                    $data += '<td class="forminp">';
                    $data += '<fieldset>';
                    $data += '<input style="" name="<?php echo $extra_charges_id?>" id="<?php echo $extra_charges_id?>" type="text" value="<?php echo $extra_charges?>"/>';
                    $data += '<br /></fieldset></td></tr>';
                    $data += '<tr valign="top">';
                    $data += '<th scope="row" class="titledesc">Extra Charges Type</th>';
                    $data += '<td class="forminp">';
                    $data += '<fieldset>';
                    $data += '<select name="<?php echo $extra_charges_type?>"><option <?php if($extra_charges_type_value=="add") echo "selected=selected"?> value="add">Total Add</option>';
                    $data += '<option <?php if($extra_charges_type_value=="percentage") echo "selected=selected"?> value="percentage">Total % Add</option>';
                    $data += '<br /></fieldset></td></tr></table>';
                    $('.form-table:last').after($data);
    
                });
    </script>
    <?php
    }

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    but it crashed out the site

    Hi jade.stewart,

    Try using another plugin call “WooCommerce Pay for Payment”

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘woocommerce 2.1.1’ is closed to new replies.