Plugin Directory

Changeset 3403989


Ignore:
Timestamp:
11/27/2025 11:08:36 AM (3 months ago)
Author:
phcwordpress
Message:

Improve security T#68336

Location:
drivefx-woocommerce/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • drivefx-woocommerce/trunk/PHCLibrary/invoices.php

    r3160801 r3403989  
    448448                                        if($response['result'][0]['draftRecord'] == 1){
    449449                                            //Save ftstamp of invoice
    450                                             $_SESSION['ftstamp'] = $response['result'][0]['ftstamp'];
    451                                             $_SESSION['fno'] =  $response['result'][0]['fno'];
     450                                            $ftstamp = isset($response['result'][0]['ftstamp']) ? sanitize_text_field($response['result'][0]['ftstamp']) : '';
     451                                            $fno     = isset($response['result'][0]['fno']) ? sanitize_text_field($response['result'][0]['fno']) : '';
     452
     453                                            $_SESSION['ftstamp'] = $ftstamp;
     454                                            $_SESSION['fno']     = $fno;
     455
    452456
    453457                                            //Sign document
     
    506510            } else {
    507511                //Save id of customer
    508                 $_SESSION['numberClient'] = $response['result'][0]['no'];
    509 
     512                $numberClient = isset($response['result'][0]['no'])
     513                ? sanitize_text_field($response['result'][0]['no'])
     514                : '';
     515           
     516                $_SESSION['numberClient'] = $numberClient;
     517           
    510518                //Set customer NIF if is generic customer
    511519                if($response['result'][0]['clivd'] == 1){
  • drivefx-woocommerce/trunk/PHCLibrary/orders.php

    r3059006 r3403989  
    240240                                                            #Save internal document
    241241                                                            $response = $this->utils_services->paramsSave($ch, $credentials, 'BoWS', $response);
    242                                                             //$this->logs->writeFileLog('save update order:', $response);
     242                                                            $this->logs->writeFileLog('save update order:', $response);
    243243
    244244                                                            if (curl_error($ch)) {
     
    407407                }
    408408                //$this->logs->writeFileLog('bis build:', $response['result'][0]['bis']);       
     409                $response = $this->utils_services->actEntity($ch, $credentials, 'BoWS', $response);
     410                if (curl_error($ch)) {
     411                    $this->logs->writeFileLog('addNewOrder13.2', $ch);
     412                } else if(empty($response)){
     413                    $this->logs->writeFileLog('addNewOrder13.2', 'EMPTY RESPONSE');
     414                } else if(isset($response['messages'][0]['messageCodeLocale'])  && $response['messages'][0]['messageCode']!='messages.Business.Stocks.InvalidRefAutoCreate'){
     415                    $this->logs->writeFileLog('addNewOrder13.2', $response['messages'][0]['messageCodeLocale']);
     416                }
    409417
    410418                #shipping
     
    455463                        $bi->ivaincl = false;
    456464                    }
    457                     $response['result'][0]['bis'][]= $bi;
     465                   // $response['result'][0]['bis'][]= $bi;
    458466                }
    459467                //actEntity
     
    684692                            array_push($response['result'][0]['bis'], $discount);
    685693                        }
    686 
    687694                        //actEntity                   
    688695                        $response = $this->utils_services->actEntity($ch, $credentials, 'BoWS', $response);     
    689                         //$this->logs->writeFileLog('actEntity2:', $response);
    690696
    691697                        if (curl_error($ch)) {
     
    720726                                $response['result'][0]['obrano'] = $order->nextPostId;
    721727                            }
     728                            //$this->logs->writeFileLog('addNewOrder15-bis', $response['result'][0]['bis']);
    722729
    723730                            //Insert designation for products
     
    726733                                    if ($bis['ref'] == $product['ref'] && $bis['design'] == "") {
    727734                                        //fill the designation
     735                                        $this->logs->writeFileLog('addNewOrder15', $bis);
     736
    728737                                        $bis['design'] = $product['design'];
    729738                                    }
    730739                                }
    731740                            }
     741                            //$this->logs->writeFileLog('addNewOrder15', $response);
    732742
    733743                            #Save internal document
  • drivefx-woocommerce/trunk/class.DriveFxWoocommerce.php

    r3394987 r3403989  
    251251            add_settings_section('backend-section', null, null, 'backend-options');
    252252            add_settings_field(null, null, null, 'backend-options', 'backend-section');
    253             register_setting('backend-options', DRIVEFXWOOCOMMERCE_PLUGIN_NAME);
    254 
     253            register_setting('backend-options', DRIVEFXWOOCOMMERCE_PLUGIN_NAME, array(
     254                'sanitize_callback' => function( $value ) {
     255                    if ( is_array( $value ) ) {
     256                        // Sanitizar recursivamente
     257                        return array_map( function( $item ) {
     258                            if ( is_array( $item ) ) {
     259                                return array_map( 'sanitize_text_field', $item );
     260                            }
     261                            return sanitize_text_field( $item );
     262                        }, $value );
     263                    }
     264                    if ( !is_scalar( $value ) ) {
     265                        $value = json_encode($value);
     266                    }
     267                    return sanitize_text_field( $value );
     268                }
     269            ));
     270           
     271   
    255272            // Import settings section
    256273            add_settings_section('import-section', null, null, 'import-options');
    257274            add_settings_field(null, null, null, 'import-options', 'import-section');
    258             register_setting('import-options', DRIVEFXWOOCOMMERCE_PLUGIN_NAME);
    259         }
    260 
    261         public function register_scripts() {
    262             ?> <script>
    263             var pathPlugin = "<?php echo plugins_url('/' , __FILE__ ); ?>";
    264             </script> <?php
    265 
    266             // register scripts that will be used later on
    267             wp_register_script(DRIVEFXWOOCOMMERCE_PLUGIN_NAME, plugins_url('/js/'.DRIVEFXWOOCOMMERCE_PLUGIN_NAME.'.js' , __FILE__ ));
    268             wp_register_script('datatable_min', plugins_url('/js/datatable_min.js' , __FILE__ ));
    269 
    270             // register css that will be used later on
    271             wp_register_style('style_datatable_jquery', plugins_url('/css/style_datatable_jquery.css' , __FILE__ ));
    272             wp_register_style('datatable_css', plugins_url('/css/style_datatable.css' , __FILE__ ));
    273         }
     275            register_setting('import-options', DRIVEFXWOOCOMMERCE_PLUGIN_NAME, array(
     276                'sanitize_callback' => function( $value ) {
     277                    if ( is_array( $value ) ) {
     278                        // Sanitizar recursivamente
     279                        return array_map( function( $item ) {
     280                            if ( is_array( $item ) ) {
     281                                return array_map( 'sanitize_text_field', $item );
     282                            }
     283                            return sanitize_text_field( $item );
     284                        }, $value );
     285                    }
     286                    if ( !is_scalar( $value ) ) {
     287                        $value = json_encode($value);
     288                    }
     289                    return sanitize_text_field( $value );
     290                }
     291            ));
     292
     293        }
     294
     295
     296            public function register_scripts() {
     297                ?> <script>
     298                    var pathPlugin = "<?php echo esc_url( plugins_url( '/', __FILE__ ) ); ?>";
     299                </script> <?php
     300   
     301                // Register scripts
     302                wp_register_script(
     303                    DRIVEFXWOOCOMMERCE_PLUGIN_NAME,
     304                    esc_url( plugins_url( '/js/' . DRIVEFXWOOCOMMERCE_PLUGIN_NAME . '.js', __FILE__ ) ),
     305                    array(), // dependencies
     306                    null,    // version
     307                    true     // in footer
     308                );
     309   
     310                wp_register_script(
     311                    'datatable_min',
     312                    esc_url( plugins_url( '/js/datatable_min.js', __FILE__ ) ),
     313                    array('jquery'), // example dependency
     314                    null,
     315                    true
     316                );
     317   
     318                // Register styles
     319                wp_register_style(
     320                    'style_datatable_jquery',
     321                    esc_url( plugins_url( '/css/style_datatable_jquery.css', __FILE__ ) ),
     322                    array(),
     323                    null
     324                );
     325   
     326                wp_register_style(
     327                    'datatable_css',
     328                    esc_url( plugins_url( '/css/style_datatable.css', __FILE__ ) ),
     329                    array(),
     330                    null
     331                );
     332   
     333            }
     334   
     335   
     336            /**
     337             * Sanitize backend options
     338             *
     339             * @param mixed $value The value being sanitized.
     340             * @return array Sanitized value.
     341             */
     342            public function sanitize_backend_options( $value ) {
     343                if ( ! is_array( $value ) ) {
     344                    return array();
     345                }
     346               
     347                $sanitized = array();
     348                foreach ( $value as $key => $val ) {
     349                    $sanitized[ sanitize_key( $key ) ] = sanitize_text_field( $val );
     350                }
     351               
     352                return $sanitized;
     353            }
     354   
     355            /**
     356             * Sanitize import options
     357             *
     358             * @param mixed $value The value being sanitized.
     359             * @return array Sanitized value.
     360             */
     361            public function sanitize_import_options( $value ) {
     362                if ( ! is_array( $value ) ) {
     363                    return array();
     364                }
     365               
     366                $sanitized = array();
     367                foreach ( $value as $key => $val ) {
     368                    $sanitized[ sanitize_key( $key ) ] = sanitize_text_field( $val );
     369                }
     370               
     371                return $sanitized;
     372            }
     373   
    274374
    275375        # Create page of settings
     
    500600            $settings = apply_filters('woocommerce_email_settings', array(
    501601                array('type'   => 'sectionend', 'id' => 'email_recipient_options' ),
    502                 array('title'  => __( 'Email Sender Options', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'The following options affect the sender (email address and name) used in WooCommerce emails.', 'woocommerce' ), 'id' => 'email_options' ),
    503                 array('title'  => __( '"From" Name', 'woocommerce' ),
     602                array('title'  => __( 'Email Sender Options', 'drivefx-woocommerce' ), 'type' => 'title', 'desc' => __( 'The following options affect the sender (email address and name) used in WooCommerce emails.', 'drivefx-woocommerce' ), 'id' => 'email_options' ),
     603                array('title'  => __( '"From" Name', 'drivefx-woocommerce' ),
    504604                    'desc'     => '',
    505605                    'id'       => 'woocommerce_email_from_name',
     
    509609                    'autoload' => false
    510610                    ),
    511                 array('title'           => __( '"From" Email Address', 'woocommerce' ),
     611                array('title'           => __( '"From" Email Address', 'drivefx-woocommerce' ),
    512612                    'desc'              => '',
    513613                    'id'                => 'woocommerce_email_from_address',
     
    519619                ),
    520620                array( 'type'  => 'sectionend', 'id' => 'email_options' ),
    521                 array( 'title' => __( 'Email Template', 'woocommerce' ), 'type' => 'title', 'desc' => sprintf(__( 'This section lets you customise the WooCommerce emails. <a href="%s" target="_blank">Click here to preview your email template</a>. For more advanced control copy <code>woocommerce/templates/emails/</code> to <code>yourtheme/woocommerce/emails/</code>.', 'woocommerce' ), wp_nonce_url(admin_url('?preview_woocommerce_mail=true'), 'preview-mail')), 'id' => 'email_template_options' ),
    522                 array( 'title' => __( 'Header Image', 'woocommerce' ),
    523                     'desc'     => sprintf(__( 'Enter a URL to an image you want to show in the email\'s header. Upload your image using the <a href="%s">media uploader</a>.', 'woocommerce' ), admin_url('media-new.php')),
     621                array( 'title' => __( 'Email Template', 'drivefx-woocommerce' ), 'type' => 'title', 'desc' => sprintf(__( 'This section lets you customise the WooCommerce emails. <a href="%s" target="_blank">Click here to preview your email template</a>. For more advanced control copy <code>woocommerce/templates/emails/</code> to <code>yourtheme/woocommerce/emails/</code>.', 'drivefx-woocommerce' ), wp_nonce_url(admin_url('?preview_woocommerce_mail=true'), 'preview-mail')), 'id' => 'email_template_options' ),
     622                array( 'title' => __( 'Header Image', 'drivefx-woocommerce' ),
     623                    'desc'     => sprintf(__( 'Enter a URL to an image you want to show in the email\'s header. Upload your image using the <a href="%s">media uploader</a>.', 'drivefx-woocommerce' ), admin_url('media-new.php')),
    524624                    'id'       => 'woocommerce_email_header_image',
    525625                    'type'     => 'text',
     
    528628                    'autoload' => false
    529629                ),
    530                 array('title'  => __( 'Email Footer Text', 'woocommerce' ),
    531                     'desc'     => __( 'The text to appear in the footer of WooCommerce emails.', 'woocommerce' ),
     630                array('title'  => __( 'Email Footer Text', 'drivefx-woocommerce' ),
     631                    'desc'     => __( 'The text to appear in the footer of WooCommerce emails.', 'drivefx-woocommerce' ),
    532632                    'id'       => 'woocommerce_email_footer_text',
    533633                    'css'      => 'width:100%; height: 75px;',
    534634                    'type'     => 'textarea',
    535                     'default'  => get_bloginfo('title') . ' - ' . __( 'Powered by WooCommerce', 'woocommerce' ),
     635                    'default'  => get_bloginfo('title') . ' - ' . __( 'Powered by WooCommerce', 'drivefx-woocommerce' ),
    536636                    'autoload' => false
    537637                ),
    538                 array('title'  => __( 'Base Colour', 'woocommerce' ),
    539                     'desc'     => __( 'The base colour for WooCommerce email templates. Default <code>#557da1</code>.', 'woocommerce' ),
     638                array('title'  => __( 'Base Colour', 'drivefx-woocommerce' ),
     639                    'desc'     => __( 'The base colour for WooCommerce email templates. Default <code>#557da1</code>.', 'drivefx-woocommerce' ),
    540640                    'id'       => 'woocommerce_email_base_color',
    541641                    'type'     => 'color',
     
    545645                ),
    546646                array(
    547                     'title'    => __( 'Background Colour', 'woocommerce' ),
    548                     'desc'     => __( 'The background colour for WooCommerce email templates. Default <code>#f5f5f5</code>.', 'woocommerce' ),
     647                    'title'    => __( 'Background Colour', 'drivefx-woocommerce' ),
     648                    'desc'     => __( 'The background colour for WooCommerce email templates. Default <code>#f5f5f5</code>.', 'drivefx-woocommerce' ),
    549649                    'id'       => 'woocommerce_email_background_color',
    550650                    'type'     => 'color',
     
    554654                ),
    555655                array(
    556                     'title'    => __( 'Email Body Background Colour', 'woocommerce' ),
    557                     'desc'     => __( 'The main body background colour. Default <code>#fdfdfd</code>.', 'woocommerce' ),
     656                    'title'    => __( 'Email Body Background Colour', 'drivefx-woocommerce' ),
     657                    'desc'     => __( 'The main body background colour. Default <code>#fdfdfd</code>.', 'drivefx-woocommerce' ),
    558658                    'id'       => 'woocommerce_email_body_background_color',
    559659                    'type'     => 'color',
     
    563663                ),
    564664                array(
    565                     'title'    => __( 'Email Body Text Colour', 'woocommerce' ),
    566                     'desc'     => __( 'The main body text colour. Default <code>#505050</code>.', 'woocommerce' ),
     665                    'title'    => __( 'Email Body Text Colour', 'drivefx-woocommerce' ),
     666                    'desc'     => __( 'The main body text colour. Default <code>#505050</code>.', 'drivefx-woocommerce' ),
    567667                    'id'       => 'woocommerce_email_text_color',
    568668                    'type'     => 'color',
  • drivefx-woocommerce/trunk/drivefx-woocommerce-settings.php

    r3059006 r3403989  
    1414   
    1515    <a href="https://www.phcgo.net/" target="_blank" title="PHC GO" class="alignleft" style="margin-right: 10px;">
    16       <img src="<?php echo plugins_url('images/logo_phcgo.svg', __FILE__) ?>" width="135" height="135">
     16    <img src="<?php echo esc_url( plugins_url('images/logo_phcgo.svg', __FILE__) ); ?>" width="135" height="135" alt="Logo">
    1717    </a>
    1818 
     
    2626  <div class="clear"></div>
    2727
    28   <h2 class="nav-tab-wrapper">
    29     <a href="?page=<?php echo DRIVEFXWOOCOMMERCE_PLUGIN_NAME ?>&tab=backend" class="nav-tab <?php echo $tab==='backend' ? 'nav-tab-active' : '' ?>">Backend Options</a>
    30     <?php if(!empty($_SESSION['username'])){ ?>
    31     <a href="?page=<?php echo DRIVEFXWOOCOMMERCE_PLUGIN_NAME ?>&tab=import" class="nav-tab <?php echo $tab==='import' ? 'nav-tab-active' : '' ?>">Import Products</a>
    32     <?php } ?>
     28  <h2 class="nav-tab-wrapper"> 
     29  <?php  $page_name = esc_attr(DRIVEFXWOOCOMMERCE_PLUGIN_NAME);
     30    $tab_safe  = isset($tab) ? sanitize_text_field($tab) : '';
     31    ?>
     32
     33    <a href="?page=<?php echo $page_name; ?>&tab=backend" class="nav-tab <?php echo ($tab_safe==='backend') ? 'nav-tab-active' : ''; ?>">Backend Options</a>
     34    <?php if(!empty($_SESSION['username'])): ?>
     35        <a href="?page=<?php echo $page_name; ?>&tab=import" class="nav-tab <?php echo ($tab_safe==='import') ? 'nav-tab-active' : ''; ?>">Import Products</a>
     36    <?php endif; ?>
     37
    3338  </h2>
    3439
  • drivefx-woocommerce/trunk/drivefx-woocommerce.php

    r3394987 r3403989  
    33 * Plugin Name: PHC GO Commerce Sync
    44 * Description: Easy integration between Woocommerce WordPress and your PHC GO software installation.
    5  * Version: 5.0.0
     5 * Version: 5.1.0
    66 * Author: Cegid PHC
    77 * License: GPL v2 or later
    88 * Author URI: https://phcsoftware.com/pt/phc-go
    99 * Requires Plugins: woocommerce
    10  * Text Domain: phcgo-commerce-sync
     10 * Text Domain: drivefx-woocommerce
    1111 */
    1212 
    13 // Prevent direct access data leaks
     13// Prevent direct access data leaks 
    1414if ( ! defined( 'ABSPATH' ) ) {
    1515    exit;
  • drivefx-woocommerce/trunk/readme.txt

    r3399073 r3403989  
    11=== PHC GO Commerce Sync ===
    22Contributors: phcgo
    3 Tags: cegid, phc software, drivefx, fx, phc go, go, invoices, client, internal document, products, plugin, business
     3Tags: cegid, phc go, invoices, commerce sync
    44Requires at least: 4.5
    5 Tested up to: 6.7
    6 Stable tag: 5.0.1
     5Tested up to: 6.8
     6Stable tag: 5.1.0
    77License: GPLv2 or later
    88Requires Plugins: woocommerce
    99
    1010
    11 Sync your online shop with your PHC GO accounting software. Integrate your WooCommerce Orders, Customers, Products and PHC GO stocks.
     11Sync your online shop with your PHC GO software. Integrate your WooCommerce Orders, Customers, Products and PHC GO stocks.
    1212
    1313== Description ==
     
    9393 * improvements and adjustments to information related with the plugin
    9494
     95 = 5.1 =
     96 * security improvements and adjustments
    9597 
  • drivefx-woocommerce/trunk/settings/backend.php

    r2964024 r3403989  
    22    // get stored settings
    33    $settings = get_option(DRIVEFXWOOCOMMERCE_PLUGIN_NAME);
    4 
     4   
    55    global $wpdb;
    66
     
    3333          </th>
    3434          <td>
    35             <?php
    36               if(is_array($settings['backend']['url'])){
    37                 $settings['backend']['url'] = '';
    38               } ?>
    39             <input class="regular-text" id="url" type="text" name="drivefx-woocommerce[backend][url]" value="<?php echo $settings['backend']['url'] ?>">
     35         <?php
     36                // Inicializa $settings se não existir
     37            if (!isset($settings) || !is_array($settings)) {
     38                $settings = [];
     39            }
     40
     41            // Inicializa $settings['backend'] como array, se não existir ou se for string
     42            if (!isset($settings['backend']) || !is_array($settings['backend'])) {
     43                $settings['backend'] = [];
     44            }
     45
     46            // Agora podemos acessar com segurança
     47            $backend_url = $settings['backend']['url'] ?? ''; // retorna string vazia se não existir
     48
     49            ?>
     50    <input class="regular-text" id="url" type="text" name="drivefx-woocommerce[backend][url]"
     51            value="<?php echo $settings['backend']['url'] ?? ''; ?>">
    4052
    4153              <?php if(isset($resultDB->meta_value) && $resultDB->meta_value != ''){ ?>
    4254                <div id="backend_url_initialize" class="button button-primary" title="Autenticate plugin">
    43                   <img id="plus" src="<?php echo plugins_url('/../images/plus.png', __FILE__) ?>" title="Autenticate plugin">
     55                <img
     56                    id="plus"
     57                    src="<?php echo esc_url( plugins_url('../images/plus.png', __FILE__) ); ?>"
     58                    title="<?php echo esc_attr('Authenticate plugin'); ?>"
     59                    alt="Plus Icon"
     60                >
    4461                  <span id="autenticatePlugin">Re-Autenticate</span>
    4562                </div>
     
    4966              <?php } else { ?>
    5067                <div id="backend_url_initialize" class="button button-primary" title="Autenticate plugin">
    51                   <img id="plus" src="<?php echo plugins_url('/../images/plus.png', __FILE__) ?>" title="Autenticate plugin">
     68                <img
     69                    id="plus"
     70                    src="<?php echo esc_url( plugins_url('../images/plus.png', __FILE__) ); ?>"
     71                    title="<?php echo esc_attr('Authenticate plugin'); ?>"
     72                    alt="Plus Icon"
     73                >
    5274                  <span id="autenticatePlugin">Autenticate</span>
    5375                </div>
     
    83105                  <tr>
    84106                    <th scope="row">
    85                       <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>
     107                    <label for="<?php echo esc_attr($id); ?>"><?php echo esc_html($opts['label']); ?></label>
    86108                    </th>
    87109                    <td>
    88                       <input class="regular-text" id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>" value="<?php echo $value ?>">
    89                       <span style='color:red;'>*</span>
    90                       <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p>
    91                     </td>
     110                    <input
     111                        class="regular-text"
     112                        id="<?php echo esc_attr($id); ?>"
     113                        type="<?php echo esc_attr($opts['type']); ?>"
     114                        name="<?php echo esc_attr($name); ?>"
     115                        value="<?php echo esc_attr($value); ?>"
     116                    >
     117                    <span style="color:red;">*</span>
     118                    <?php if (isset($opts['descr'])): ?>
     119                        <p class="description"><?php echo esc_html($opts['descr']); ?></p>
     120                    <?php endif; ?>
     121                    </td>
    92122                  </tr>
    93123              <?php break;
     
    95125          ?><tr>
    96126            <th scope="row">
    97               <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>
    98             </th>
    99             <td>
    100               <input class="regular-text" id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>" value="<?php echo $value ?>">
    101               <span style='color:red;'>*</span>
    102               <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p>
     127              <label for="<?php echo esc_attr($id); ?>"><?php echo esc_html($opts['label']); ?></label>
     128            </th>
     129            <td>
     130             <input
     131                class="regular-text"
     132                id="<?php echo esc_attr($id); ?>"
     133                type="<?php echo esc_attr($opts['type']); ?>"
     134                name="<?php echo esc_attr($name); ?>"
     135                value="<?php echo esc_attr($value); ?>"
     136            >
     137            <span style="color:red;">*</span>
     138            <?php if (isset($opts['descr'])): ?>
     139                <p class="description"><?php echo esc_html($opts['descr']); ?></p>
     140            <?php endif; ?>
    103141              </td>
    104142            </tr>
     
    107145          ?><tr>
    108146            <th scope="row">
    109               <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>
    110             </th>
    111             <td>
    112               <input class="regular-text" id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>" value="<?php echo $value ?>">
    113               <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p>
     147                <label for="<?php echo esc_attr($id); ?>"><?php echo esc_html($opts['label']); ?></label>
     148            </th>
     149            <td>
     150            <input
     151                class="regular-text"
     152                id="<?php echo esc_attr($id); ?>"
     153                type="<?php echo esc_attr($opts['type']); ?>"
     154                name="<?php echo esc_attr($name); ?>"
     155                value="<?php echo esc_attr($value); ?>"
     156            >
     157            <?php if (isset($opts['descr'])): ?>
     158                <p class="description"><?php echo esc_html($opts['descr']); ?></p>
     159            <?php endif; ?>
    114160            </td>
    115161          </tr>
     
    131177                      <th scope="row">
    132178                        <?php if($_SESSION['manageStockParameter'] === 'S' && $_SESSION['gamaDRIVEFX'] >= 9) { ?>
    133                             <label for="<?php echo $id ?>">Create Clients, Orders and Invoices</label>
     179                            <label for="<?php echo esc_attr($id); ?>">Create Clients, Orders and Invoices</label>
    134180                        <?php } else { ?>
    135                             <label for="<?php echo $id ?>">Create Clients and Invoices</label>
     181                            <label for="<?php echo esc_attr($id); ?>">Create Clients and Invoices</label>
    136182                        <?php } ?>
    137183                      </th>
     
    161207            <tr>
    162208            <th scope="row">
    163               <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>
     209            <label for="<?php echo esc_attr($id); ?>"><?php echo esc_html($opts['label']); ?></label>
    164210            </th>
    165211            <td>
     
    169215                $checkbox = '';
    170216              } ?>
    171               <input style="width: 0;" class="regular-text" <?php echo $checkedBox ?> id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>">
    172               <span><?php echo $opts['checkboxDescription'] ?></span>
    173               <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p>
     217              <input
     218                    style="width: 0;"
     219                    class="regular-text"
     220                    <?php echo esc_attr($checkedBox); ?>
     221                    id="<?php echo esc_attr($id); ?>"
     222                    type="<?php echo esc_attr($opts['type']); ?>"
     223                    name="<?php echo esc_attr($name); ?>"
     224                >
     225                <span><?php echo esc_html($opts['checkboxDescription']); ?></span>
     226                <?php if (isset($opts['descr'])): ?>
     227                    <p class="description"><?php echo esc_html($opts['descr']); ?></p>
     228                <?php endif; ?>
    174229            </td>
    175230          </tr>
     
    181236          <tr>
    182237            <th scope="row">
    183               <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>
     238                <label for="<?php echo esc_attr($id); ?>"><?php echo esc_html($opts['label']); ?></label>
    184239            </th>
    185240            <td>
     
    189244                $checkbox = '';
    190245              } ?>
    191               <input style="width: 0;" class="regular-text" <?php echo $checkedBox ?> id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>">
    192               <span><?php echo $opts['checkboxDescription'] ?></span>
    193               <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p>
     246              <input
     247                    style="width: 0;"
     248                    class="regular-text"
     249                    <?php echo esc_attr($checkedBox); ?>
     250                    id="<?php echo esc_attr($id); ?>"
     251                    type="<?php echo esc_attr($opts['type']); ?>"
     252                    name="<?php echo esc_attr($name); ?>"
     253                >
     254                <span><?php echo esc_html($opts['checkboxDescription']); ?></span>
     255                <?php if (isset($opts['descr'])): ?>
     256                    <p class="description"><?php echo esc_html($opts['descr']); ?></p>
     257                <?php endif; ?>
    194258            </td>
    195259          </tr>
     
    198262            if((isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '') && (isset($settings['backend']['sendInvoice']) && $settings['backend']['sendInvoice'] != '')){ ?>
    199263            <tr>
     264            <th scope="row">
     265            <label for="<?php echo esc_attr($id); ?>"><?php echo esc_html($opts['label']); ?></label>
     266            </th>
     267            <td>
     268               <select id="<?php echo $id ?>" name="<?php echo $name ?>">
     269              <?php if(!empty($_SESSION[$id])){ ?>
     270                <option value="0">Select one...</option>
     271              <?php }
     272              echo $_SESSION[$id]; ?>
     273            </td>
     274          </tr>
     275          <?php } break;
     276        // CC email
     277        case 'emailCC':
     278          if((isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '') && (isset($settings['backend']['sendInvoice']) && $settings['backend']['sendInvoice'] != '')){ ?>
     279          <tr>
     280            <th scope="row">
     281                <label for="<?php echo esc_attr($id); ?>"><?php echo esc_html($opts['label']); ?></label>
     282            </th>
     283            <td>
     284                <input
     285                    class="regular-text"
     286                    id="<?php echo esc_attr($id); ?>"
     287                    type="<?php echo esc_attr($opts['type']); ?>"
     288                    name="<?php echo esc_attr($name); ?>"
     289                    value="<?php echo esc_attr($value); ?>"
     290                >
     291                <?php if (isset($opts['descr'])): ?>
     292                    <p class="description"><?php echo esc_html($opts['descr']); ?></p>
     293                <?php endif; ?>
     294            </td>
     295          </tr>
     296          <?php } break;
     297        // Text for email body
     298        case 'emailBody':
     299          if((isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '') && (isset($settings['backend']['sendInvoice']) && $settings['backend']['sendInvoice'] != '')){ ?>
     300          <tr>
     301            <th scope="row">
     302            <label for="<?php echo esc_attr($id); ?>"><?php echo esc_html($opts['label']); ?></label>
     303            </th>
     304            <td>
     305                <textarea
     306                    class="regular-text"
     307                    id="<?php echo esc_attr($id); ?>"
     308                    name="<?php echo esc_attr($name); ?>"
     309                ><?php echo esc_textarea($value); ?></textarea>
     310
     311                <?php if (isset($opts['descr'])): ?>
     312                    <p class="description"><?php echo esc_html($opts['descr']); ?></p>
     313                <?php endif; ?>
     314            </td>
     315          </tr>
     316          <?php } break;
     317        // Type of Invoice PT
     318        case 'typeOfInvoice':
     319          if((isset($_SESSION['username']) && $_SESSION['username'] != '') && (isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '')){ ?>
     320            <tr>
     321              <th scope="row">
     322                <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>
     323              </th>
     324              <td>
     325                <select id="<?php echo $id ?>" name="<?php echo $name ?>">
     326                <?php if(!empty($_SESSION[$id])){ ?>
     327                  <option value="0">Select one...</option>
     328                <?php }
     329                echo $_SESSION[$id]; ?>
     330              </td>
     331            </tr>
     332            <?php } break;
     333        case 'typeOf_EU_Invoice':
     334          if((isset($_SESSION['username']) && $_SESSION['username'] != '') && (isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '')){ ?>
     335          <tr>
    200336            <th scope="row">
    201337              <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>
     
    210346          </tr>
    211347          <?php } break;
    212         // CC email
    213         case 'emailCC':
    214           if((isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '') && (isset($settings['backend']['sendInvoice']) && $settings['backend']['sendInvoice'] != '')){ ?>
    215           <tr>
    216             <th scope="row">
    217               <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>
    218             </th>
    219             <td>
    220               <input class="regular-text" id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>" value="<?php echo $value ?>">
    221               <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p>
    222             </td>
    223           </tr>
    224           <?php } break;
    225         // Text for email body
    226         case 'emailBody':
    227           if((isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '') && (isset($settings['backend']['sendInvoice']) && $settings['backend']['sendInvoice'] != '')){ ?>
    228           <tr>
    229             <th scope="row">
    230               <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>
    231             </th>
    232             <td>
    233               <textarea class="regular-text" id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>"><?php echo $value ?></textarea>
    234               <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p>
    235             </td>
    236           </tr>
    237           <?php } break;
    238         // Type of Invoice PT
    239         case 'typeOfInvoice':
    240           if((isset($_SESSION['username']) && $_SESSION['username'] != '') && (isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '')){ ?>
    241           <tr>
    242             <th scope="row">
    243               <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>
    244             </th>
    245             <td>
    246               <select id="<?php echo $id ?>" name="<?php echo $name ?>">
    247               <?php if(!empty($_SESSION[$id])){ ?>
    248                 <option value="0">Select one...</option>
    249               <?php }
    250               echo $_SESSION[$id]; ?>
    251             </td>
    252           </tr>
    253           <?php } break;
    254         case 'typeOf_EU_Invoice':
    255           if((isset($_SESSION['username']) && $_SESSION['username'] != '') && (isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '')){ ?>
    256           <tr>
    257             <th scope="row">
    258               <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>
    259             </th>
    260             <td>
    261               <select id="<?php echo $id ?>" name="<?php echo $name ?>">
    262               <?php if(!empty($_SESSION[$id])){ ?>
    263                 <option value="0">Select one...</option>
    264               <?php }
    265               echo $_SESSION[$id]; ?>
    266             </td>
    267           </tr>
    268           <?php } break;
    269348        case 'toSignInvoice':
    270349          if((isset($_SESSION['username']) && $_SESSION['username'] != '') && (isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '')){ ?>
    271               <tr>
    272                 <th scope="row">
    273                   <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>
    274                 </th>
    275                 <td>
    276                   <?php if($value == 'on'){
    277                     $checkedBox = 'checked';
    278                   } else {
    279                     $checkbox = '';
    280                   } ?>
    281                   <input style="width: 0;" class="regular-text" <?php echo $checkedBox ?> id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>">
    282                   <span><?php echo $opts['checkboxDescription'] ?></span>
    283                   <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p>
    284                 </td>
    285               </tr>
    286 
    287               <?php } break;
    288 
    289         case 'fieldNif':
    290           if((isset($_SESSION['username']) && $_SESSION['username'] != '') && (isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '')){ ?>
    291               <tr>
    292                 <th scope="row">
    293                   <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>
    294                 </th>
    295                 <td>
    296             <select id="<?php echo $id ?>" name="<?php echo $name ?>">
    297             <?php echo $_SESSION[$id];?>
    298 
    299                 </td>
    300               </tr>
    301               <?php } break;
    302 
    303         case 'includeTaxonSendCost':
     350            <tr>
     351              <th scope="row">
     352                <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>
     353              </th>
     354              <td>
     355                <?php if($value == 'on'){
     356                  $checkedBox = 'checked';
     357                } else {
     358                  $checkbox = '';
     359                } ?>
     360                <input style="width: 0;" class="regular-text" <?php echo $checkedBox ?> id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>">
     361                <span><?php echo $opts['checkboxDescription'] ?></span>
     362                <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p>
     363              </td>
     364            </tr>
     365
     366            <?php } break;
     367
     368      case 'fieldNif':
     369        if((isset($_SESSION['username']) && $_SESSION['username'] != '') && (isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '')){ ?>
     370            <tr>
     371              <th scope="row">
     372                <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>
     373              </th>
     374              <td>
     375          <select id="<?php echo $id ?>" name="<?php echo $name ?>">
     376          <?php echo $_SESSION[$id];?>
     377
     378              </td>
     379            </tr>
     380            <?php } break;
     381         case 'includeTaxonSendCost':
    304382          if((isset($_SESSION['username']) && $_SESSION['username'] != '') && (isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '')){ ?>
    305383          <tr>
  • drivefx-woocommerce/trunk/settings/import-products.php

    r3147200 r3403989  
    1111<div id="loader"></div>
    1212<div id="importToShop" class="button button-primary" title="List all products from PHC">
    13     <img id="list" src="<?php echo plugins_url('/../images/list.png', __FILE__) ?>" title="List all products from PHC"> List Products
     13<img
     14    id="list"
     15    src="<?php echo esc_url( plugins_url('../images/list.png', __FILE__) ); ?>"
     16    title="<?php echo esc_attr('List all products from PHC'); ?>"
     17    alt="List Products"
     18> List Products
    1419</div>
    1520
     
    2025<div id="loader2"></div>
    2126<div id="saveProductInShop" class="button button-primary" title="Import new products from PHC">
    22     <img id="plus" src="<?php echo plugins_url('/../images/plus.png', __FILE__) ?>" title="Save selected product in yout online store"> Import New Products
     27<img
     28    id="plus"
     29    src="<?php echo esc_url( plugins_url('../images/plus.png', __FILE__) ); ?>"
     30    title="<?php echo esc_attr('Save selected product in your online store'); ?>"
     31    alt="Import New Products"
     32> Import New Products
    2333</div>
    2434
    2535<?php if($_SESSION['manageStockParameter'] === 'S' && $_SESSION['gamaDRIVEFX'] >= 9){ ?>
    2636    <div id="updateStocks" class="button button-primary" title="Update stocks in your online store">
    27         <img id="plus" src="<?php echo plugins_url('/../images/update.png', __FILE__) ?>" title="Update all stocks of products from PHC"> Update Stocks
     37    <img
     38    id="plus"
     39    src="<?php echo esc_url( plugins_url('../images/update.png', __FILE__) ); ?>"
     40    title="<?php echo esc_attr('Update all stocks of products from PHC'); ?>"
     41    alt="Update Stocks"
     42> Update Stocks
    2843    </div>
    2944<?php } ?>
    3045
    3146<div id="updatePrices" class="button button-primary" title="Update prices in your online store">
    32     <img id="plus" src="<?php echo plugins_url('/../images/update.png', __FILE__) ?>" title="Update all prices of products from PHC"> Update Prices
     47<img
     48    id="plus"
     49    src="<?php echo esc_url( plugins_url('../images/update.png', __FILE__) ); ?>"
     50    title="<?php echo esc_attr('Update all prices of products from PHC'); ?>"
     51    alt="Update Prices"
     52> Update Prices
    3353</div>
    3454
    3555<div id="updateAllFields" class="button button-primary" title="Update all fields of products from PHC">
    36     <img id="plus" src="<?php echo plugins_url('/../images/update.png', __FILE__) ?>" title="Update all data of products in your online store"> Update all Fields
     56<img
     57    id="plus"
     58    src="<?php echo esc_url( plugins_url('../images/update.png', __FILE__) ); ?>"
     59    title="<?php echo esc_attr('Update all data of products in your online store'); ?>"
     60    alt="Update all Fields"
     61> Update all Fields
    3762</div>
    3863
  • drivefx-woocommerce/trunk/settings/syncro_gate.php

    r3399073 r3403989  
    261261                            if(!empty($value)){
    262262                                // get shipping tax rate ID
    263                                 $shipping_tax_rate_id = $key;
     263                                $shipping_tax_rate_id = isset($key) ? intval($key) : 0;
    264264                            }
    265265                        }
     
    269269                    // order shipping tax rate
    270270                    $getShippingTax = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_id='".$shipping_tax_rate_id."' LIMIT 1"));           
    271                 } else {
     271               } else {
    272272                    //$this->logs->writeFileLog('Warning', 'Can not obtain the tax rate ID for shipping, so we apply manual calculation');
    273273                }
     
    488488
    489489                    // order tax rate country
    490                     $getTaxID = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM ".$wpdb->prefix."woocommerce_order_itemmeta WHERE meta_key='rate_id' ORDER BY order_item_id DESC  LIMIT 1" ) );
    491                     $getTaxCountry = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_country FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_id='".$getTaxID."' LIMIT 1" ) );
    492                    
     490                    $getTaxID = $wpdb->get_var( $wpdb->prepare(
     491                        "SELECT meta_value FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key = %s ORDER BY order_item_id DESC LIMIT 1",
     492                        'rate_id'
     493                    ) );
     494
     495                    $getTaxCountry = $wpdb->get_var( $wpdb->prepare(
     496                        "SELECT tax_rate_country FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d LIMIT 1",
     497                        intval($getTaxID)
     498                    ) );
    493499                    //order Item ID
    494500                    //$getOrderItemID = $wpdb->get_var( $wpdb->prepare("SELECT order_item_id FROM ".$wpdb->prefix."woocommerce_order_items WHERE order_item_name ='".$product['design']."' and order_item_type = 'line_item' and order_id = '".$orderid."' LIMIT 1" ) );
    495                     $getOrderItemID = $wpdb->get_var( $wpdb->prepare("SELECT order_item_id FROM ".$wpdb->prefix."woocommerce_order_items WHERE order_item_name ='".$wc_product->get_name()."' and order_item_type = 'line_item' and order_id = '".$orderid."' LIMIT 1" ) );
    496                                    
    497                     //order Item product by order Item ID
    498                     $item = new WC_Order_Item_Product($getOrderItemID);
     501                    $getOrderItemID = $wpdb->get_var( $wpdb->prepare(
     502                        "SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_name = %s AND order_item_type = %s AND order_id = %d LIMIT 1",
     503                        $wc_product->get_name(),
     504                        'line_item',
     505                        intval($orderid)
     506                    ) );
     507
     508                    // order Item product by order Item ID
     509                    $item = new WC_Order_Item_Product($getOrderItemID);
    499510
    500511                    // The product name
     
    515526                        if(!empty($tax_rate_id)){
    516527                            // order item tax rate
    517                             $getTaxOrder = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_id='".$tax_rate_id."' LIMIT 1"));
    518                         } else {
     528                            $getTaxOrder = $wpdb->get_var( $wpdb->prepare(
     529                                "SELECT tax_rate FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d LIMIT 1",
     530                                intval($tax_rate_id)
     531                            ) );                       
     532                        } else {
    519533                            $this->logs->writeFileLog('Warning', 'check the way to obtain the tax rate for items');
    520534                        }
     
    551565            $_SESSION['listOfValueItem'] = [];
    552566
    553             foreach( $products as $product ) {
    554                 array_push($_SESSION['listOfSku'], $product->sku);
    555                 array_push($_SESSION['listOfQuantity'], $product->quantity);
    556                 array_push($_SESSION['listOfValueItem'], $product->value);
    557             }
     567            foreach( $products as $product ) {
     568                // Sanitize SKU (text)
     569                $sku = sanitize_text_field( $product->sku );
     570           
     571                // Sanitize quantity (integer)
     572                $quantity = absint( $product->quantity );
     573           
     574                // Sanitize value (float)
     575                $value = (float) $product->value;
     576           
     577                // Push sanitized values to session
     578                array_push($_SESSION['listOfSku'], $sku);
     579                array_push($_SESSION['listOfQuantity'], $quantity);
     580                array_push($_SESSION['listOfValueItem'], $value);
     581            }
     582           
    558583            return $products;
    559584        }
     
    671696                    # get product ref & design
    672697                    global $wpdb;
    673                     $product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $product['ref']));
     698                    $product_id = $wpdb->get_var( $wpdb->prepare(
     699                        "SELECT post_id FROM {$wpdb->prefix}postmeta WHERE meta_key = %s AND meta_value = %s LIMIT 1",
     700                        '_sku',
     701                        $product['ref']
     702                    ) );                   
    674703                    if(empty($product_id) && !empty($product['productId'])){
    675704                        $product_id = $product['productId'];
     
    698727                        $tax_rate_id = $item->get_rate_id(); // Tax rate ID               
    699728                    }
    700                     $getTaxCountry = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_country FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_id='".$tax_rate_id."' LIMIT 1" ) );
    701                    
     729                    $getTaxCountry = $wpdb->get_var( $wpdb->prepare(
     730                        "SELECT tax_rate_country FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d LIMIT 1",
     731                        intval($tax_rate_id)
     732                    ) );                   
    702733                    //order Item ID
    703                     $getOrderItemID = $wpdb->get_var( $wpdb->prepare("SELECT order_item_id FROM ".$wpdb->prefix."woocommerce_order_items WHERE order_item_name ='".$wc_prod->get_name()."' and order_item_type = 'line_item' and order_id = '".$orderid."' LIMIT 1" ) );                                                 
    704                     //order Item product by order Item ID
     734                    $getOrderItemID = $wpdb->get_var( $wpdb->prepare(
     735                        "SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_name = %s AND order_item_type = %s AND order_id = %d LIMIT 1",
     736                        $wc_prod->get_name(),
     737                        'line_item',
     738                        intval($orderid)
     739                    ) );                   
     740                    //order Item product by order Item ID
    705741                    $item = new WC_Order_Item_Product($getOrderItemID);
    706742                    //$this->logs->writeFileLog('item', $item);
     
    721757                        }
    722758                        // order item tax rate
    723                         $getTaxProduct = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_id='".$tax_rate_id."' LIMIT 1"));
    724                     }
     759                        $getTaxProduct = $wpdb->get_var( $wpdb->prepare(
     760                            "SELECT tax_rate FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d LIMIT 1",
     761                            intval($tax_rate_id)
     762                        ) );                   
     763                    }
    725764
    726765                    if (isset($getTaxCountry)){
     
    751790        }
    752791
    753         public function setFtProductsSession($ftProducts){
    754             //Save items of cart
    755             $_SESSION['listOfSku'] = [];
    756             $_SESSION['listOfQuantity'] = [];
    757             $_SESSION['listOfValueItem'] = [];
    758 
    759             foreach( $ftProducts as $ftProduct ) {
    760                 array_push($_SESSION['listOfSku'], $ftProduct->sku);
    761                 array_push($_SESSION['listOfQuantity'], $ftProduct->quantity);
    762                 array_push($_SESSION['listOfValueItem'], $ftProduct->value);
    763             }
    764             return $ftProducts;
    765         }
     792        public function setFtProductsSession($ftProducts) {
     793            // Initialize arrays
     794            $_SESSION['listOfSku'] = [];
     795            $_SESSION['listOfQuantity'] = [];
     796            $_SESSION['listOfValueItem'] = [];
     797       
     798            foreach ($ftProducts as $ftProduct) {
     799                // Sanitize SKU (string)
     800                $sku = sanitize_text_field($ftProduct->sku);
     801       
     802                // Sanitize Quantity (integer)
     803                $quantity = absint($ftProduct->quantity);
     804       
     805                // Sanitize Value (float)
     806                $value = (float) $ftProduct->value;
     807       
     808                // Push sanitized data to session
     809                array_push($_SESSION['listOfSku'], $sku);
     810                array_push($_SESSION['listOfQuantity'], $quantity);
     811                array_push($_SESSION['listOfValueItem'], $value);
     812            }
     813       
     814            return $ftProducts;
     815        }
     816       
    766817
    767818
Note: See TracChangeset for help on using the changeset viewer.