Plugin Directory

Changeset 2092492


Ignore:
Timestamp:
05/21/2019 05:01:51 PM (7 years ago)
Author:
phcwordpress
Message:

4.5.9 - Taxas IVA Fix

Location:
drivefx-woocommerce/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • drivefx-woocommerce/trunk/class.DriveFxWoocommerce.php

    r1999880 r2092492  
    22602260                                                    } else {
    22612261                                                   
    2262                                                         //Obtain name and price of delivery
     2262                                                        //Obtain name and price of delivery
    22632263                                                            //Put the same number of order in Drive FX
    22642264                                                        global $wpdb;
     
    22812281                                                        }
    22822282
    2283                                                                
     2283                                                        //get taxes from drive fx
     2284                                                        $url = $settings['backend']['url'] . $this->extraurl . "/REST/SearchWS/QueryAsEntities";
     2285                                                                                                               
     2286                                                                                                               
     2287                                                        $params =  array('itemQuery' => '{"distinct": true,
     2288                                                                                "groupByItems": [],
     2289                                                                                "orderByItems": [
     2290                                                                                    {
     2291                                                                                        "OrderItem": "dataini",
     2292                                                                                        "OrderType": 1
     2293                                                                                    }
     2294                                                                                    ],
     2295                                                                                "SelectItems": [],
     2296                                                                                "entityName": "TaxasIVA",
     2297                                                                                "filterItems": [],
     2298                                                                                "joinEntities": []
     2299                                                                            }'
     2300                                                                    );
     2301                                                       
     2302                                                        $queryActEntity = http_build_query($params);
     2303                                                        curl_setopt($ch, CURLOPT_URL, $url);
     2304                                                        curl_setopt($ch, CURLOPT_POST, false);
     2305                                                        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     2306                                                        curl_setopt($ch, CURLOPT_POSTFIELDS, $queryActEntity);
     2307                                                        curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
     2308                                                        $responseQueryAsEntities = curl_exec($ch);
     2309
     2310                                                       
     2311                                                        $responseQueryAsEntities = json_decode($responseQueryAsEntities, true);
     2312                                           
     2313                                                           
    22842314                                                        $table_name = $wpdb->prefix."woocommerce_order_items";
    22852315                                                        $query = "SELECT * FROM %s WHERE order_id = %s and order_item_type = 'shipping'";
    22862316                                                        $resultShipping = $wpdb->get_row(str_replace("'".$table_name."'", $table_name, $wpdb->prepare($query, $table_name, $docid->nextPostId)));
    22872317                                                       
     2318                                                        //get tax value for shipping
     2319                                                        $table_name = $wpdb->prefix."woocommerce_order_itemmeta";
     2320                                                        $query = "SELECT * FROM %s WHERE order_item_id = %s and meta_key = 'total_tax'";
     2321                                                        $resultTax = $wpdb->get_row(str_replace("'".$table_name."'", $table_name, $wpdb->prepare($query, $table_name, $resultShipping->order_item_id)));       
     2322   
    22882323                                                        $table_name = $wpdb->prefix."woocommerce_order_itemmeta";
    22892324                                                        $query = "SELECT * FROM %s WHERE order_item_id = %s and meta_key = 'cost'";
    2290                                                         $resultDB = $wpdb->get_row(str_replace("'".$table_name."'", $table_name, $wpdb->prepare($query, $table_name, $resultShipping->order_item_id)));     
    2291 
     2325                                                        $resultDB = $wpdb->get_row(str_replace("'".$table_name."'", $table_name, $wpdb->prepare($query, $table_name, $resultShipping->order_item_id)));
     2326         
    22922327
    22932328                                                        //Obtain VO with updated Bo
     
    23152350                                                            }
    23162351                                                        }
    2317 
    2318                                                         $bi= new stdClass();
     2352                                        foreach ($_SESSION['listOfSku'] as $key => $value) {   
     2353                                                           
     2354                                                            //shipping
     2355                                                            $bi= new stdClass();
     2356                                                            $bi->design = $resultShipping->order_item_name;
     2357                                                            $bi->qtt = 1;
     2358                                                            $bi->edebito = $bi->ettdeb = $resultDB->meta_value;
     2359                                                            if($settings['backend']['includeTaxonSendCost']=="true") {
     2360                                                                 $bi->ivaincl=true;
     2361                                                            }
     2362                                                                                                                   
     2363
     2364                                                            // get IVA
     2365                                                            foreach ($responseQueryAsEntities['result'] as $tax) {
     2366                                                            if ($resultTax->total_tax == $tax['taxa'] && 'PT' == $tax['regiao']) {
     2367                                                                        $bi->iva = $tax['taxa'];
     2368                                                                    $bi->tabiva = $tax['codigo'];       
     2369                                                        }
     2370                                                        }
     2371                                                            if($bi->edebito == 0){
     2372                                                                $bi->qtt = 0;
     2373                                                                $bi->ivaincl = false;
     2374                                                                }   
     2375                                                            $response['result'][0]['bis'][]= $bi;       
     2376                                                }
     2377
     2378                                              //shipping - OLD version :
     2379                                            /*          $bi= new stdClass();
    23192380                                                        $bi->design = $resultShipping->order_item_name;;
    23202381                                                        $bi->qtt = 1;
     
    23232384                                                            $bi->ivaincl=true;
    23242385                                                        }
    2325                                                        
     2386                                                        //TODO get IVA
    23262387                                                        if($bi->edebito == 0){
    23272388                                                            $bi->qtt = 0;
     
    23292390                                                        }   
    23302391                                                       
    2331                                                         $response['result'][0]['bis'][]= $bi;
    2332                                                        
    2333                                                
     2392                                                        $response['result'][0]['bis'][]= $bi;  */
     2393                                           
     2394                                                     
    23342395                                                       
    23352396                                                        $urlBo = $settings['backend']['url'] . $this->extraurl . "/REST/BoWS/actEntity";
     
    25672628                                                                            //get product tax rate country
    25682629                                                                            $getTaxCountry = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_country FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_class='%s' LIMIT 1", $getProduct->get_tax_class() ) );
    2569                                                                        
     2630                                                                   
    25702631                                                                            foreach ($responseQueryAsEntities['result'] as $tax) {
    25712632                                                                               
  • drivefx-woocommerce/trunk/drivefx-woocommerce.php

    r1999881 r2092492  
    33 * Plugin Name: Drive FX WooCommerce
    44 * Description: Easy integration between Woocommerce WordPress and your Drive FX installation.
    5  * Version: 4.5.8
     5 * Version: 4.5.9
    66 * Author: PHC Software, S.A.
    77 * Author URI: https://www.drivefx.net/
Note: See TracChangeset for help on using the changeset viewer.