Changeset 2940233
- Timestamp:
- 07/19/2023 08:43:47 AM (3 years ago)
- Location:
- extendago-wp-connection/trunk
- Files:
-
- 4 edited
-
extendago-wp-connection.php (modified) (1 diff)
-
includes/class-extendago-wp-connection.php (modified) (1 diff)
-
includes/woocommerce/class-extendago-woocommerce-functions.php (modified) (11 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
extendago-wp-connection/trunk/extendago-wp-connection.php
r2935547 r2940233 4 4 Plugin URI: http://www.arture.nl/extendago 5 5 Description: The Wordpress plugin for connecting Woocommerce with Extenda GO / Wallmob. You can manage your products inside Extenda GO or make your webshop as leading foor product manangement. You Stock changes will be two-way binding. 6 Version: 1.3. 86 Version: 1.3.9 7 7 Author: Arture B.V. 8 8 Author URI: https://arture.nl/ -
extendago-wp-connection/trunk/includes/class-extendago-wp-connection.php
r2932171 r2940233 68 68 $this->loader->add_action( 'wp_ajax_check_extendago_voucher', $woocommerce, 'check_extendago_voucher' ); 69 69 $this->loader->add_action( 'wp_ajax_nopriv_check_extendago_voucher', $woocommerce, 'check_extendago_voucher' ); 70 $this->loader->add_action( 'woocommerce_order_status_changed', $woocommerce, 'create_extendago_new_order' );70 //$this->loader->add_action( 'woocommerce_order_status_changed', $woocommerce, 'create_extendago_new_order' ); 71 71 $this->loader->add_action( 'manage_edit-shop_order_columns', $woocommerce, 'add_extendago_order_returned_column' ); 72 72 $this->loader->add_action( 'manage_shop_order_posts_custom_column', $woocommerce, 'add_extendago_order_returned_column_value' ); -
extendago-wp-connection/trunk/includes/woocommerce/class-extendago-woocommerce-functions.php
r2935547 r2940233 14 14 add_action( 'woocommerce_product_data_panels', array($this, 'add_extendago_product_data_fields') ); 15 15 add_action( 'woocommerce_process_product_meta', array($this, 'woocommerce_extendago_product_fields_save') ); 16 17 add_action( 'save_post_shop_order', array($this, 'process_order_to_extendago'), 10, 3 ); 16 18 } 17 19 … … 47 49 if($post->post_type === 'product') { 48 50 49 $extendago_product_id = get_post_meta( $post_id, 'extendago_product_id', true ); 50 51 require_once(__DIR__ . "/../api/class-extendago-web-api.php"); 52 $Extendago = new Extendago_Web_Api(); 53 $ProductResponse = $Extendago->CurlRequest('/products/'.$extendago_product_id, 'GET'); 54 55 if( isset($ProductResponse['id']) ){ 56 $Extendago->CurlRequest('/products/'.$extendago_product_id, 'DELETE', array(), false, true); 51 // Only delete product inside Extenda if EXPORT enabled ( Woocommerce leading. 52 $extendago_export_only = get_option('extendago_export_only'); 53 if ( isset($extendago_export_only) && $extendago_export_only == '1') { 54 55 $extendago_product_id = get_post_meta( $post_id, 'extendago_product_id', true ); 56 require_once(__DIR__ . "/../api/class-extendago-web-api.php"); 57 $Extendago = new Extendago_Web_Api(); 58 $ProductResponse = $Extendago->CurlRequest('/products/'.$extendago_product_id, 'GET'); 59 if( isset($ProductResponse['id']) ){ 60 $Extendago->CurlRequest('/products/'.$extendago_product_id, 'DELETE', array(), false, true); 61 } 57 62 } 58 63 } … … 69 74 70 75 public function add_extendago_product_data_fields() { 71 global $ woocommerce, $post;76 global $post; 72 77 ?> 73 78 <div id="extendago_product_data" class="panel woocommerce_options_panel"> 74 79 <?php 75 //require_once(__DIR__ . "/../api/class-extendago-web-api.php");76 80 $Extendago = new Extendago_Web_Api(); 77 81 $Units = $Extendago->CurlRequest('/units', 'GET'); … … 431 435 } 432 436 433 public function create_extendago_new_order( $order_id, $response = false ) { 437 // public function handle_update_post_shop_order($post_id, $post, $update){ 438 // 439 // if( $update ){ 440 // 441 // 442 // } 443 // 444 // 445 // echo '<pre>'; 446 // print_r($post_id); 447 // echo '</pre>'; 448 // echo '<pre>'; 449 // print_r($post); 450 // echo '</pre>'; 451 // echo '<pre>'; 452 // var_dump($update); 453 // echo '</pre>'; 454 // exit; 455 // 456 // } 457 458 //public function create_extendago_new_order( $order_id, $response = false ) { 459 public function process_order_to_extendago($order_id, $post, $update){ 434 460 435 461 // Check if "New order" option is enabled … … 444 470 $logging->log_file_write('NewOrder | WebOrder status changed to: '.$order->get_status()); 445 471 446 // Skip already processed orders 472 // Update already processed orders 473 $update_existing_order = false; 447 474 $order_returned_successfully_to_extendago = get_post_meta($order_id, 'order_returned_successfully_to_extendago', true); 448 475 if( $order_returned_successfully_to_extendago == '1' ) { 449 return ''; 450 } 451 452 $create_order = false; 476 $update_existing_order = true; 477 } 478 elseif( $update ){ 479 $update_existing_order = true; 480 } 481 482 $extendago_order_id = get_post_meta($order_id, 'extendago_order_id', true); 483 if( $update_existing_order && ( !isset($extendago_order_id) || empty($extendago_order_id)) ) { 484 return; 485 } 486 487 $process_order = false; 453 488 $extendago_click_and_collect = get_option( 'extendago_click_and_collect' ); 454 489 $order_is_paid = false; … … 457 492 // Check ones more if order is paid and completed 458 493 if( $order->has_status( 'processing' ) || $order->has_status( 'completed' ) ){ 459 $ create_order = true;494 $process_order = true; 460 495 $order_is_paid = true; 461 496 } … … 466 501 467 502 if( isset($shipping_line_data['instance_id']) && $shipping_line_data['instance_id'] == $extendago_click_and_collect){ 468 $ create_order = true;503 $process_order = true; 469 504 $order_is_paid = false; 470 505 $click_and_collect_order = 'yes'; … … 474 509 } 475 510 476 if( $create_order ){ 511 // Check for update 512 if( isset($extendago_order_id) && !empty($extendago_order_id)){ 513 $process_order = true; 514 $order_is_paid = false; 515 if( $order->has_status( 'processing' ) || $order->has_status( 'completed' ) ) { 516 $order_is_paid = true; 517 } 518 } 519 520 if( $process_order ){ 477 521 $data = array(); 478 522 … … 565 609 $order_line_item['product_id'] = get_post_meta($item_data['product_id'], 'extendago_product_id', true); 566 610 $order_line_item['product_variant_id'] = get_post_meta($item_data['variation_id'], 'extendago_size_id', true); 567 $order_line_item['product_variant_name'] = $product_full_name[1];611 $order_line_item['product_variant_name'] = ( isset($product_full_name[1]) )? $product_full_name[1] : $product_full_name[0]; 568 612 569 613 $retail_price = (float)get_post_meta($item_data['variation_id'], '_regular_price', true); … … 767 811 768 812 // Save order 769 $results = $web_api->createOrder($data); 813 if( !$update_existing_order && isset($extendago_order_id) && !empty($extendago_order_id) ) { 814 $results = $web_api->createOrder($data); 815 } 816 else{ 817 $results = $web_api->CurlRequest('/orders/'.$extendago_order_id, 'PUT', $data); 818 } 770 819 771 820 $logging = new ExtendaGo_WP_Connection_Logging(); … … 778 827 else{ 779 828 $message = 'OrderId processed: ' . $order_data['id']; 829 update_post_meta($order_id, 'extendago_order_id', $results['id']); 780 830 update_post_meta($order_id, 'order_returned_successfully_to_extendago', '1'); 781 831 update_post_meta($order_id, 'click_and_collect_order', $click_and_collect_order); -
extendago-wp-connection/trunk/readme.txt
r2935547 r2940233 5 5 Requires at least: 6.0 6 6 Tested up to: 6.2.2 7 Stable tag: 1.3. 87 Stable tag: 1.3.9 8 8 Requires PHP: 7.4 9 9 License: GPLv2 or later … … 30 30 31 31 == Changelog == 32 33 = 1.3.9 = 34 * Bugfix with hide_from_web status and Extenda product delete 32 35 33 36 = 1.3.8 =
Note: See TracChangeset
for help on using the changeset viewer.