Changeset 2633497
- Timestamp:
- 11/22/2021 12:10:52 PM (4 years ago)
- Location:
- drivefx-woocommerce/trunk
- Files:
-
- 6 edited
-
PHCLibrary/invoices.php (modified) (4 diffs)
-
PHCLibrary/orders.php (modified) (6 diffs)
-
PHCLibrary/utils.php (modified) (1 diff)
-
class.DriveFxWoocommerce.php (modified) (4 diffs)
-
drivefx-woocommerce.php (modified) (1 diff)
-
settings/syncro_gate.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
drivefx-woocommerce/trunk/PHCLibrary/invoices.php
r2579467 r2633497 194 194 $fees = $ft->fees; 195 195 196 //fees196 #fees 197 197 if (isset($fees)){ 198 198 foreach ($fees as $fee) { 199 199 $fi= new stdClass(); 200 200 201 $fi->design = $fee['name']; 201 if($settings->feesName != "0") { 202 203 $responseSt = $this->utils_services->filterItem_Query($ch, $credentials, 'St', 'ref', $settings->feesName); 204 205 //$this->logs->writeFileLog('ResponseST', $response); 206 207 if(empty($responseSt)) { 208 //Reset Fees data like on WC 209 $this->logs->writeFileLog('Warning', "We couldn't find a reference for Fees (FT), so we'll use WC data"); 210 $fi->ref = ""; 211 $fi->design = $fee['name']; 212 } else { 213 //Set Service Data from PHC GO 214 $fi->ref = $responseSt['result'][0]['ref']; 215 $fi->design = $responseSt['result'][0]['design']; 216 217 } 218 } else { 219 //Set Fees data like on WC 220 $fi->ref = ""; 221 $fi->design = $fee['name']; 222 } 223 202 224 $fi->qtt = 1; 203 $fi->etiliquido = $fi->epv = $fee['value'];204 205 if($settings->feesName != "") {206 $fi->ref = $settings->feesName;207 }208 209 225 // IVA 210 226 if ($settings->includeTaxonSendCost == "true") { 227 $fi->etiliquido = $fi->epv = $fee['value'] + $fee['tax_value']; 211 228 $fi->ivaincl=true; 229 } else { 230 $fi->etiliquido = $fi->epv = $fee['value']; 212 231 } 213 232 if ($fi->etiliquido == 0) { … … 218 237 } 219 238 } 220 //shipping 239 240 #shipping 221 241 if (isset($ft->shipping_name)){ 222 242 $fi= new stdClass(); 223 243 224 if($settings->shippingName != "") { 225 $fi->ref = $settings->shippingName; 226 } 244 if($settings->shippingName != "0") { 245 $responseSt = $this->utils_services->filterItem_Query($ch, $credentials, 'St', 'ref', $settings->shippingName); 246 247 //$this->logs->writeFileLog('ResponseST', $response); 248 249 if(empty($responseSt)) { 250 //Reset shipping data like on WC 251 $this->logs->writeFileLog('Warning', "We couldn't find a reference for Shipping (FT), so we'll use WC data"); 252 $fi->ref = ""; 253 $fi->design = $ft->shipping_name; 254 } else { 255 //Set Service Data from PHC GO 256 $fi->ref = $responseSt['result'][0]['ref']; 257 $fi->design = $responseSt['result'][0]['design']; 258 259 } 260 } else { 261 //Set shipping data like on WC 262 $fi->ref = ""; 263 $fi->design = $ft->shipping_name; 264 } 227 265 228 266 $fi->design = $ft->shipping_name; 229 267 $fi->qtt = 1; 268 $fi->etiliquido = $ft->shipping_value; 230 269 231 270 if($settings->includeTaxonSendCost == "true") { … … 255 294 $response['result'][0]['fis'][]= $fi; 256 295 } 296 297 #Obtain vouchers 298 if (isset($dataPack->vouchers)){ 299 foreach ($dataPack->vouchers as $voucher) { 300 //voucher 301 $fi = new stdClass(); 302 303 $fi->ref = ""; 304 if($voucher['type'] == "fixed_cart"){ 305 $fi->design = "Voucher: ".$voucher['code']." (".$voucher['value'].")"; 306 } elseif ($voucher['type'] == "percent"){ 307 $fi->design = "Voucher: ".$voucher['code']." (".$voucher['value']."%)"; 308 } else { 309 $fi->design = "Voucher: ".$voucher['code']; 310 } 311 312 $fi->etiliquido = $fi->epv = 0; 313 $fi->qtt = 0; 314 $fi->ivaincl=false; 315 //fulfill Fis 316 $response['result'][0]['fis'][] = $fi; 317 318 } 319 } 320 257 321 //actEntity 258 322 $response2 = $this->utils_services->actEntity($ch, $credentials, 'FtWS', $response); … … 359 423 } 360 424 } 425 //Set Discount Voucher 426 /* if (isset($dataPack->vouchers)){ 427 foreach ($dataPack->vouchers as $voucher) { 428 $response['result'][0]['efinvat'] += $voucher['value']; 429 } 430 } */ 361 431 362 432 #actEntity -
drivefx-woocommerce/trunk/PHCLibrary/orders.php
r2607350 r2633497 420 420 $this->logs->writeFileLog('addNewOrder13.1.1', $responseTaxes['messages'][0]['messageCodeLocale']); 421 421 } 422 423 #Obtain name and price of delivery 424 //Obtain VO with updated Bo 422 423 #Obtain VO with updated Bo 425 424 foreach ($order->cart as $product) { 426 425 //product … … 439 438 $bi= new stdClass(); 440 439 441 if($settings->shippingName != "") { 442 $bi->ref = $settings->shippingName; 443 } 444 445 $bi->design = $shipping->shipping_name; 440 if($settings->shippingName != "0") { 441 442 $responseSt = $this->utils_services->filterItem_Query($ch, $credentials, 'St', 'ref', $settings->shippingName); 443 444 //$this->logs->writeFileLog('ResponseST.01', $response); 445 446 if(empty($responseSt)) { 447 //Reset shipping data like on WC 448 $this->logs->writeFileLog('Warning', "We couldn't find a reference for Shipping, so we'll use WC data"); 449 $bi->ref = ""; 450 $bi->design = $shipping->shipping_name; 451 } else { 452 //Set Service Data from PHC GO 453 $bi->ref = $responseSt['result'][0]['ref']; 454 $bi->design = $responseSt['result'][0]['design']; 455 456 } 457 } else { 458 //Set shipping data like on WC 459 $bi->ref = ""; 460 $bi->design = $shipping->shipping_name; 461 } 462 446 463 $bi->qtt = 1; 447 464 $bi->edebito = $bi->ettdeb = $shipping->shipping_value; … … 609 626 foreach ($fees as $fee) { 610 627 $bi= new stdClass(); 611 612 $bi->design = $fee['name']; 628 629 if($settings->feesName != "0") { 630 631 $responseSt = $this->utils_services->filterItem_Query($ch, $credentials, 'St', 'ref', $settings->feesName); 632 633 //$this->logs->writeFileLog('ResponseST', $response); 634 635 if(empty($responseSt)) { 636 //Reset Fees data like on WC 637 $this->logs->writeFileLog('Warning', "We couldn't find a reference for Fees, so we'll use WC data"); 638 $bi->ref = ""; 639 $bi->design = $fee['name']; 640 } else { 641 //Set Service Data from PHC GO 642 $bi->ref = $responseSt['result'][0]['ref']; 643 $bi->design = $responseSt['result'][0]['design']; 644 645 } 646 } else { 647 //Set Fees data like on WC 648 $bi->ref = ""; 649 $bi->design = $fee['name']; 650 } 613 651 $bi->qtt = 1; 614 $bi->edebito = $bi->ettdeb = $fee['value']; 615 616 if($settings->feesName != "") { 617 $bi->ref = $settings->feesName; 652 653 if($settings->includeTaxonSendCost == "true") { 654 $bi->edebito = $bi->ettdeb = $fee['value'] + $fee['tax_value']; 655 $bi->ivaincl=true; 656 } else { 657 $bi->edebito = $bi->ettdeb = $fee['value']; 618 658 } 619 659 … … 627 667 } 628 668 } 669 629 670 $response['result'][0]['bis'][]= $bi; 630 } 631 } 671 672 } 673 } 674 675 #Obtain vouchers 676 if (isset($dataPack->vouchers)){ 677 foreach ($dataPack->vouchers as $voucher) { 678 //voucher 679 $bi = new stdClass(); 680 681 $bi->ref = ""; 682 if($voucher['type'] == "fixed_cart"){ 683 $bi->design = "Voucher: ".$voucher['code']." (".$voucher['value'].")"; 684 } elseif ($voucher['type'] == "percent"){ 685 $bi->design = "Voucher: ".$voucher['code']." (".$voucher['value']."%)"; 686 } else { 687 $bi->design = "Voucher: ".$voucher['code']; 688 } 689 $bi->edebito = $bi->ettdeb = 0; 690 $bi->qtt = 0; 691 $bi->ivaincl=false; 692 //fulfill Bis 693 $response['result'][0]['bis'][] = $bi; 694 695 } 696 } 697 632 698 # Discounts 633 699 if (isset($order->discount) && $order->discount > 0){ … … 636 702 637 703 $discount['bistamp'] = ''; 638 if($settings->discountRef != "") {704 if($settings->discountRef != 0) { 639 705 $discount['ref'] = $settings->discountRef; 640 706 } else { … … 649 715 array_push($response['result'][0]['bis'], $discount); 650 716 } 717 651 718 //actEntity 652 719 $response = $this->utils_services->actEntity($ch, $credentials, 'BoWS', $response); -
drivefx-woocommerce/trunk/PHCLibrary/utils.php
r2624007 r2633497 214 214 return $response; 215 215 } 216 217 /******************************************************************* 218 * --- FilterItem InnerJoin --- * 219 ********************************************************************/ 220 /** Quary to get Products by wharehouse **/ 216 221 217 222 public function entityName_Query1($ch, $credentials, $armazem){ -
drivefx-woocommerce/trunk/class.DriveFxWoocommerce.php
r2624007 r2633497 1260 1260 $wooOrder = $this->syncro_services->fetchOrderData($orderid); 1261 1261 $prodPack = $this->syncro_services->processProducts($orderid); 1262 $dataPack = $this->syncro_services->transformWcToPhcData($wooOrder, $prodPack, $ftprodPack); 1262 $couponPack = $this->syncro_services->processVouchers($orderid); 1263 $dataPack = $this->syncro_services->transformWcToPhcData($wooOrder, $prodPack, $ftprodPack, $couponPack); 1263 1264 $response = $this->orders_services->processOrder($credentials, $dataPack, $this->fieldStatus); 1264 1265 //add to table postmeta a key of order and stamp of internal document … … 1384 1385 1385 1386 //If status of order is completed (creates FT) 1386 public function completedOrder( $order_id){1387 public function completedOrder($order_id){ 1387 1388 $this->lockStart(); 1388 1389 $this->logs->writeFileLog('completedOrder', "Entrei" . $order_id); … … 1530 1531 $wooOrder = $this->syncro_services->fetchOrderData($orderid); 1531 1532 $ftprodPack = $this->syncro_services->processFtProducts($orderid); 1532 $dataPack = $this->syncro_services->transformWcToPhcData($wooOrder, $prodPack, $ftprodPack );1533 $dataPack = $this->syncro_services->transformWcToPhcData($wooOrder, $prodPack, $ftprodPack, $couponPack); 1533 1534 $response = $this->invoices_services->addInternalDocInvoice($response, $ch, $credentials, $dataPack); 1534 1535 … … 1547 1548 $wooOrder = $this->syncro_services->fetchOrderData($orderid); 1548 1549 $ftprodPack = $this->syncro_services->processFtProducts($orderid); 1549 $dataPack = $this->syncro_services->transformWcToPhcData($wooOrder, $prodPack, $ftprodPack); 1550 $couponPack = $this->syncro_services->processVouchers($orderid); 1551 $dataPack = $this->syncro_services->transformWcToPhcData($wooOrder, $prodPack, $ftprodPack, $couponPack); 1550 1552 $response = $this->invoices_services->addSimpleInvoice($ch, $credentials, $dataPack); 1551 1553 -
drivefx-woocommerce/trunk/drivefx-woocommerce.php
r2456862 r2633497 3 3 * Plugin Name: PHC GO WooCommerce 4 4 * Description: Easy integration between Woocommerce WordPress and your PHC GO installation. 5 * Version: 4. 6.05 * Version: 4.7.0 6 6 * Author: PHC Software, S.A. 7 7 * Author URI: https://www.phcgo.net/ -
drivefx-woocommerce/trunk/settings/syncro_gate.php
r2607350 r2633497 418 418 $bofees = []; 419 419 420 $the_order = wc_get_order($order_id); 421 422 if(!empty($the_order)){ 423 // Iterating through order fee items ONLY 424 foreach( $the_order->get_items('fee') as $item_id => $item_fee){ 425 426 // The fee name 427 $fee_name = $item_fee->get_name(); 428 429 // The fee total amount 430 $fee_total = $item_fee->get_total(); 431 432 // The fee total tax amount 433 $fee_total_tax = $item_fee->get_total_tax(); 434 435 array_push($bofees,[ 436 'name' => $fee_name, 437 'value' => $fee_total, 438 'tax_value' => $fee_total_tax 439 ]); 440 } 441 } 442 420 443 # fees data (Queries) 421 444 422 445 //get fee from mysql 423 $table_name = $wpdb->prefix."woocommerce_order_items";446 /* $table_name = $wpdb->prefix."woocommerce_order_items"; 424 447 $query = "SELECT * FROM %s WHERE order_id = %s and order_item_type = 'fee'"; 425 448 $resultsFee_bo = $wpdb->get_results(str_replace("'".$table_name."'", $table_name, $wpdb->prepare($query, $table_name, $packDocId->nextPostId))); … … 440 463 ]); 441 464 442 } 465 } */ 443 466 $boFeesPack = $bofees; 444 467 $syncroData->fees_bo = $boFeesPack; … … 495 518 496 519 //Obtain id of order and products 497 $order = new WC_Order($orderid);520 /* $order = new WC_Order($orderid); 498 521 $orderPostId = $order->post->ID; 499 522 //build common object … … 525 548 526 549 $addPack = $fees; 527 $syncroData->fees_ft = $addPack; 550 $syncroData->fees_ft = $addPack; */ 528 551 529 552 //$this->logs->writeFileLog('syncroData', $syncroData); … … 540 563 541 564 $settings = get_option(DRIVEFXWOOCOMMERCE_PLUGIN_NAME); 542 543 565 $prodPack = new stdClass(); 544 545 566 $products = []; 546 567 $cart_contents = WC()->cart->cart_contents; … … 548 569 if (is_array($cart_contents)){ 549 570 foreach (WC()->cart->cart_contents as $key => $value){ 571 550 572 //Obtain info about products in cart 551 573 $productData = WC()->cart->cart_contents[$key]; 574 575 //$this->logs->writeFileLog('productData', $productData); 552 576 553 577 //obtain reference items in cart … … 573 597 ]); 574 598 } 575 //$this->logs->writeFileLog('products_1', $products);599 //$this->logs->writeFileLog('products_1', $products); 576 600 } 577 601 … … 697 721 return $products; 698 722 } 699 723 /******************************************************************* 724 * --- Vouchers Data --- * 725 ********************************************************************/ 726 public function processVouchers($orderid) { 727 728 $vouchers = []; 729 if(!empty($orderid)){ 730 $coupons_codes = wc_get_order($orderid)->get_used_coupons(); 731 // get vouchers code 732 if (is_array($coupons_codes)){ 733 foreach($coupons_codes as $coupon_code){ 734 735 $coupon_post_obj = get_page_by_title($coupon_code, OBJECT, 'shop_coupon'); 736 $coupon_id = $coupon_post_obj->ID; 737 738 //Get an instance of WC_Coupon object in an array 739 $coupon = new WC_Coupon($coupon_id); 740 $coupon_amount = $coupon->get_amount(); 741 $coupon_type = $coupon->get_discount_type(); 742 743 if(!empty($coupon_code)){ 744 $voucherCode = $coupon_code; 745 } 746 array_push($vouchers, [ 747 'code' => $voucherCode, 748 'value' => $coupon_amount, 749 'type' => $coupon_type 750 ]); 751 } 752 } 753 } 754 //$this->logs->writeFileLog('voucher', $vouchers); 755 756 return $vouchers; 757 } 700 758 /******************************************************************* 701 759 * --- Invoice Cart Data --- * … … 859 917 * --- Object PackData --- * 860 918 ********************************************************************/ 861 public function transformWcToPhcData($wooOrder, $prodPack, $ftprodPack ) {919 public function transformWcToPhcData($wooOrder, $prodPack, $ftprodPack, $couponPack) { 862 920 863 921 $dataPack = new stdClass(); … … 870 928 $order = new Order(); 871 929 $ft = new Invoice(); 930 $vouchers = new stdClass(); 872 931 873 932 #settings data … … 966 1025 $ft->shipping_taxValue = $wooOrder->shipping_taxValue; 967 1026 $ft->shipping_tax = $wooOrder->shipping_tax; 968 $ft->fees = $wooOrder->fees_ft; 1027 //$ft->fees = $wooOrder->fees_ft; 1028 $ft->fees = $wooOrder->fees_bo; 1029 1030 $vouchers = $couponPack; 969 1031 970 1032 … … 979 1041 $dataPack->order = $order; 980 1042 $dataPack->ft = $ft; 981 982 //$this->logs->writeFileLog('dataPack', $dataPack); 1043 $dataPack->vouchers = $vouchers; 1044 1045 // $this->logs->writeFileLog('dataPack', $dataPack); 983 1046 984 1047 return $dataPack;
Note: See TracChangeset
for help on using the changeset viewer.