Changeset 2092492
- Timestamp:
- 05/21/2019 05:01:51 PM (7 years ago)
- Location:
- drivefx-woocommerce/trunk
- Files:
-
- 2 edited
-
class.DriveFxWoocommerce.php (modified) (6 diffs)
-
drivefx-woocommerce.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
drivefx-woocommerce/trunk/class.DriveFxWoocommerce.php
r1999880 r2092492 2260 2260 } else { 2261 2261 2262 //Obtain name and price of delivery2262 //Obtain name and price of delivery 2263 2263 //Put the same number of order in Drive FX 2264 2264 global $wpdb; … … 2281 2281 } 2282 2282 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 2284 2314 $table_name = $wpdb->prefix."woocommerce_order_items"; 2285 2315 $query = "SELECT * FROM %s WHERE order_id = %s and order_item_type = 'shipping'"; 2286 2316 $resultShipping = $wpdb->get_row(str_replace("'".$table_name."'", $table_name, $wpdb->prepare($query, $table_name, $docid->nextPostId))); 2287 2317 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 2288 2323 $table_name = $wpdb->prefix."woocommerce_order_itemmeta"; 2289 2324 $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 2292 2327 2293 2328 //Obtain VO with updated Bo … … 2315 2350 } 2316 2351 } 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(); 2319 2380 $bi->design = $resultShipping->order_item_name;; 2320 2381 $bi->qtt = 1; … … 2323 2384 $bi->ivaincl=true; 2324 2385 } 2325 2386 //TODO get IVA 2326 2387 if($bi->edebito == 0){ 2327 2388 $bi->qtt = 0; … … 2329 2390 } 2330 2391 2331 $response['result'][0]['bis'][]= $bi; 2332 2333 2392 $response['result'][0]['bis'][]= $bi; */ 2393 2394 2334 2395 2335 2396 $urlBo = $settings['backend']['url'] . $this->extraurl . "/REST/BoWS/actEntity"; … … 2567 2628 //get product tax rate country 2568 2629 $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 2570 2631 foreach ($responseQueryAsEntities['result'] as $tax) { 2571 2632 -
drivefx-woocommerce/trunk/drivefx-woocommerce.php
r1999881 r2092492 3 3 * Plugin Name: Drive FX WooCommerce 4 4 * Description: Easy integration between Woocommerce WordPress and your Drive FX installation. 5 * Version: 4.5. 85 * Version: 4.5.9 6 6 * Author: PHC Software, S.A. 7 7 * Author URI: https://www.drivefx.net/
Note: See TracChangeset
for help on using the changeset viewer.