Plugin Directory

Changeset 1999880


Ignore:
Timestamp:
12/21/2018 04:37:09 PM (7 years ago)
Author:
phcwordpress
Message:

4.5.8 - Fixed issue product's tax rate

Location:
drivefx-woocommerce/trunk
Files:
2 edited

Legend:

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

    r1898537 r1999880  
    17261726                    }
    17271727                   
     1728                    if($billing_country=="GB" ){
     1729                        $this->paramsQuery('Countries', 'nomeabrv', "UK");
     1730                    }else if($billing_country_=="GB"){
     1731                        $this->paramsQuery('Countries', 'nomeabrv', "UK");
     1732                    }
    17281733                   
    17291734                    curl_setopt($ch, CURLOPT_URL, $this->url);
     
    25172522                                                                }
    25182523                                                               
    2519                                                        
     2524                                                               
     2525                                                                //get taxes from drive fx
     2526                                                                $url = $settings['backend']['url'] . $this->extraurl . "/REST/SearchWS/QueryAsEntities";
     2527                                                               
     2528                                                               
     2529                                                                $params =  array('itemQuery' => '{"distinct": true,
     2530                                                                                        "groupByItems": [],
     2531                                                                                        "orderByItems": [
     2532                                                                                            {
     2533                                                                                              "OrderItem": "dataini",
     2534                                                                                              "OrderType": 1
     2535                                                                                            }
     2536                                                                                          ],
     2537                                                                                        "SelectItems": [],
     2538                                                                                        "entityName": "TaxasIVA",
     2539                                                                                        "filterItems": [],
     2540                                                                                        "joinEntities": []
     2541                                                                                    }'
     2542                                                                            );
     2543                                                               
     2544                                                                $queryActEntity = http_build_query($params);
     2545                                                                curl_setopt($ch, CURLOPT_URL, $url);
     2546                                                                curl_setopt($ch, CURLOPT_POST, false);
     2547                                                                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     2548                                                                curl_setopt($ch, CURLOPT_POSTFIELDS, $queryActEntity);
     2549                                                                curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
     2550                                                                $responseQueryAsEntities = curl_exec($ch);
     2551
     2552                                                               
     2553                                                                $responseQueryAsEntities = json_decode($responseQueryAsEntities, true);
     2554
     2555                                                               
     2556                                                                if (is_array($_SESSION['listOfSku'])){
     2557                                                                    foreach ($_SESSION['listOfSku'] as $key => $value){
     2558                                                                         if( $_SESSION['listOfQuantity'][$key]*$_SESSION['listOfValueItem'][$key]!=0){
     2559                                                                            //get product id from sku
     2560                                                                            $getProductId = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $value ) );
     2561                                                                           
     2562                                                                            //get product From id
     2563                                                                            $getProduct = wc_get_product($getProductId);
     2564                                                                           
     2565                                                                            //get product tax rate 
     2566                                                                            $getProductTax = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_class='%s' LIMIT 1", $getProduct->get_tax_class() ) );
     2567                                                                            //get product tax rate country
     2568                                                                            $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                                                                       
     2570                                                                            foreach ($responseQueryAsEntities['result'] as $tax) {
     2571                                                                               
     2572                                                                                 If ($getProductTax == $tax['taxa'] && $getTaxCountry == $tax['regiao'] ) {
     2573                                                                                    $response['result'][0]['bis'][$key]['iva'] = $tax['taxa'];
     2574                                                                                    $response['result'][0]['bis'][$key]['tabiva'] = $tax['codigo'];
     2575                                                                                   
     2576                                                                                    break;
     2577                                                                                 }
     2578                                                                            }
     2579                                                                           
     2580                                                                        }
     2581                                                                    }
     2582                                                                }
     2583                                                               
    25202584                                                               
    25212585                                                                $urlActEntity = $settings['backend']['url'] . $this->extraurl . "/REST/BoWS/actEntity";
  • drivefx-woocommerce/trunk/readme.txt

    r1898537 r1999880  
    44Requires at least: 4.5
    55Tested up to: 4.8
    6 Stable tag: 4.5.7
     6Stable tag: 4.5.8
    77License: GPLv2 or later
    88
Note: See TracChangeset for help on using the changeset viewer.