Viewing 1 replies (of 1 total)
  • In function “woocommerce-add-extra-charges-option-to-payment-gateways.php”
    Change code with 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( $_GET['section'] ) ) ? '' : sanitize_text_field( urldecode( $_GET['section'] ) );
            if($current_tab == 'checkout' && $current_section!=''){
                $gateways = $woocommerce->payment_gateways->payment_gateways();
                foreach($gateways as $gateway){
                    if(strtolower($gateway -> id)==$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'])){
                            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
    }
    }
Viewing 1 replies (of 1 total)
  • The topic ‘no options displayed’ is closed to new replies.