Changeset 3435393
- Timestamp:
- 01/08/2026 05:59:33 PM (3 months ago)
- Location:
- storecontrl-wp-connection/trunk
- Files:
-
- 5 edited
-
includes/api/class-storecontrl-web-api-functions.php (modified) (23 diffs)
-
includes/cronjob/class-storecontrl-cronjob-functions.php (modified) (2 diffs)
-
includes/woocommerce/class-storecontrl-woocommerce-functions.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
-
storecontrl-wp-connection.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
storecontrl-wp-connection/trunk/includes/api/class-storecontrl-web-api-functions.php
r3434321 r3435393 13 13 14 14 private $functions; 15 private $cronjob_functions; 16 private $logging; 17 15 18 private $storecontrl_api_ftp_user; 16 19 private $storecontrl_api_ftp_password; … … 22 25 { 23 26 $this->functions = new StoreContrl_WP_Connection_Functions(); 27 $this->cronjob_functions = new StoreContrl_Cronjob_Functions(); 28 $this->logging = new StoreContrl_WP_Connection_Logging(); 24 29 $this->use_instock_variations = get_option('storecontrl_use_instock_variations'); 25 30 $this->storecontrl_api_ftp_user = get_option('storecontrl_api_ftp_user'); … … 37 42 // Refresh if not exist 38 43 if( !isset($storecontrl_masterdata['VariationInfo']) || empty($storecontrl_masterdata['VariationInfo']) ){ 39 $cronjob_functions = new StoreContrl_Cronjob_Functions(); 40 $cronjob_functions->storecontrl_set_masterdata(); 44 $this->cronjob_functions->storecontrl_set_masterdata(); 41 45 42 46 $storecontrl_masterdata = file_get_contents($directory . '/MasterData.json'); … … 53 57 { 54 58 $web_api = new StoreContrl_Web_Api(); 55 $logging = new StoreContrl_WP_Connection_Logging();59 $logging = $this->logging; 56 60 57 61 // Upload directory … … 104 108 public function set_product_masterdata($product) 105 109 { 106 $logging = new StoreContrl_WP_Connection_Logging();110 $logging = $this->logging; 107 111 108 112 $output = $product; … … 177 181 public function set_product_variations_data($variations) 178 182 { 179 $logging = new StoreContrl_WP_Connection_Logging();183 $logging = $this->logging; 180 184 181 185 $mapped_variations = $this->storecontrl_masterdata['VariationInfo']; … … 230 234 public function storecontrl_update_wc_product($product, $full_sync = false) 231 235 { 236 // DEBUG 237 $start = microtime(true); 238 $logging = $this->logging; 232 239 233 240 // Get all masterdata by product id's … … 400 407 $storecontrl_keep_product_images = get_option('storecontrl_keep_product_images'); 401 408 if (!isset($storecontrl_keep_product_images) || !$storecontrl_keep_product_images || !has_post_thumbnail($post_id)) { 402 $cronjob_functions = new StoreContrl_Cronjob_Functions(); 403 $this::$storecontrl_ftp_connection = $cronjob_functions->GetFTPConnection(true); 409 $this::$storecontrl_ftp_connection = $this->cronjob_functions->GetFTPConnection(true); 404 410 $gallery_image_ids = $this->save_product_images($post_id, $product); 405 411 $Product->set_gallery_image_ids($gallery_image_ids); … … 422 428 // Product full update if new variations are more than existing 423 429 if( count($product['variations']) > count($all_product_variations) ){ 424 $cronjob_functions = new StoreContrl_Cronjob_Functions(); 425 $cronjob_functions->storecontrl_synchronize_product($product['product_id']); 430 $this->cronjob_functions->storecontrl_synchronize_product($product['product_id']); 426 431 } 427 432 … … 444 449 if( isset($new_product_size_list) && !empty($new_product_size_list) ) { 445 450 if (!in_array($storecontrl_size_id, $new_product_size_list)) { 446 $logging = new StoreContrl_WP_Connection_Logging();447 451 $logging->log_file_write('DEBUG | Variation ' . $variation_post_id . ' deleted from product: ' . $post_id . ' beacuse variation don\'t exist in StoreContrl.'); 448 452 wp_delete_post($variation_post_id, true); … … 745 749 if (!isset($storecontrl_keep_product_status) || !$storecontrl_keep_product_status) { 746 750 $post_status = $no_image_post_status; 747 748 // LOG749 $logging = new StoreContrl_WP_Connection_Logging();750 751 $logging->log_file_write('Status | Post (' . $post_id . ') has no image. Updating post-status to: ' . $no_image_post_status); 751 752 } … … 1040 1041 $sub_category_id_1 = $sub_category_1->get_error_data("term_exists"); 1041 1042 } else { 1042 $logging = new StoreContrl_WP_Connection_Logging(); 1043 $logging->log_file_write('WP error | Error creating new subterm'); 1043 $this->logging->log_file_write('WP error | Error creating new subterm'); 1044 1044 } 1045 1045 } else { … … 1143 1143 if (is_wp_error($main_category)) { 1144 1144 $error_string = $main_category->get_error_message(); 1145 $logging = new StoreContrl_WP_Connection_Logging(); 1146 $logging->log_file_write('WP error | ' . $error_string); 1145 $this->logging->log_file_write('WP error | ' . $error_string); 1147 1146 } else { 1148 1147 $main_category_id = $main_category['term_id']; … … 1175 1174 if (is_wp_error($sub_category_1)) { 1176 1175 $error_string = $sub_category_1->get_error_message(); 1177 $logging = new StoreContrl_WP_Connection_Logging(); 1178 $logging->log_file_write('WP error | ' . $error_string); 1176 $this->logging->log_file_write('WP error | ' . $error_string); 1179 1177 } else { 1180 1178 $sub_category_id_1 = $sub_category_1['term_id']; … … 1205 1203 if (is_wp_error($sub_category_2)) { 1206 1204 $error_string = $sub_category_2->get_error_message(); 1207 $logging = new StoreContrl_WP_Connection_Logging(); 1208 $logging->log_file_write('WP error | ' . $error_string); 1205 $this->logging->log_file_write('WP error | ' . $error_string); 1209 1206 } else { 1210 1207 $sub_category_id_2 = $sub_category_2['term_id']; … … 1344 1341 if (isset($attribute_id->errors)) { 1345 1342 foreach ($attribute_id->errors as $error) { 1346 $logging = new StoreContrl_WP_Connection_Logging(); 1347 $logging->log_file_write('ERROR | ' . $error[0]); 1343 $this->logging->log_file_write('ERROR | ' . $error[0]); 1348 1344 } 1349 1345 } … … 1374 1370 public function insert_product_variations( $product_id, $product ) 1375 1371 { 1376 global $wpdb; 1377 1378 $logging = new StoreContrl_WP_Connection_Logging(); 1372 $logging = $this->logging; 1379 1373 1380 1374 $variations = $product['variations']; … … 1483 1477 } 1484 1478 1485 // Set barcode to the new GTIN field 1486 if( !empty($variation['barcode']) && $this->is_valid_gtin($variation['barcode']) ) { 1487 1488 $ean = $variation['barcode']; 1479 /// Set barcode to the new GTIN field 1480 if ( ! empty($variation['barcode']) && $this->is_valid_gtin($variation['barcode']) ) { 1481 1482 global $wpdb; 1483 1484 $ean = $variation['barcode']; 1489 1485 $meta_key = '_global_unique_id'; 1490 1491 // check of er al een ander product/variatie is met dezelfde EAN 1492 $existing_id = (int)$wpdb->get_var( 1486 $current_id = (int) $variation_post_id; // dit is jouw eigen variatie ID 1487 1488 // check of er al een ander product/variatie is met dezelfde EAN (behalve deze zelf) 1489 $existing_id = (int) $wpdb->get_var( 1493 1490 $wpdb->prepare( 1494 1491 " … … 1499 1496 WHERE pm.meta_key = %s 1500 1497 AND pm.meta_value = %s 1498 AND pm.post_id != %d 1501 1499 AND p.post_type IN ('product','product_variation') 1500 AND p.post_status NOT IN ('trash','auto-draft') 1502 1501 LIMIT 1 1503 1502 ", 1504 1503 $meta_key, 1505 $ean 1504 $ean, 1505 $current_id 1506 1506 ) 1507 1507 ); 1508 1508 1509 if ($existing_id > 0) { 1510 $logging->log_file_write('NOTICE | Duplicate _global_unique_id: ' . $ean . ' (exist already on post ' . $existing_id . ')'); 1509 if ( $existing_id > 0 ) { 1510 $logging->log_file_write( 1511 'NOTICE | Duplicate _global_unique_id: ' . $ean . ' (exists already on post ' . $existing_id . ')' 1512 ); 1511 1513 } else { 1512 1514 $Variation->update_meta_data('_global_unique_id', $ean); … … 1668 1670 $attachment_ids = []; 1669 1671 $functions = new StoreContrl_WP_Connection_Functions(); 1670 $logging = new StoreContrl_WP_Connection_Logging();1672 $logging = $this->logging; 1671 1673 1672 1674 $storecontrl_hide_featured_image_from_gallery = get_option('storecontrl_hide_featured_image_from_gallery'); … … 1687 1689 1688 1690 // Verwijder niet-bestaande afbeeldingen 1689 if ($attach_id && !$functions->is_url_exist(wp_get_attachment_url($attach_id))) { 1690 wp_delete_attachment($attach_id); 1691 $attach_id = null; 1691 if ($attach_id) { 1692 $file = get_attached_file($attach_id); 1693 if (!$file || !file_exists($file)) { 1694 wp_delete_attachment($attach_id, true); 1695 $attach_id = null; 1696 } 1692 1697 } 1693 1698 … … 1733 1738 } 1734 1739 if ($is_featured) { 1735 set_post_thumbnail($post_id, $attach_id); 1740 $current_thumb = (int) get_post_meta($post_id, '_thumbnail_id', true); 1741 if ($current_thumb !== $attach_id) { 1742 set_post_thumbnail($post_id, $attach_id); 1743 } 1736 1744 } else { 1737 1745 $attachment_ids[] = $attach_id; … … 1747 1755 global $wpdb; 1748 1756 1749 $logging = new StoreContrl_WP_Connection_Logging();1757 $logging = $this->logging; 1750 1758 1751 1759 $existing_product_variation = $wpdb->get_results( -
storecontrl-wp-connection/trunk/includes/cronjob/class-storecontrl-cronjob-functions.php
r3434321 r3435393 240 240 unset($output[$product['product_id']]['sku_list']); 241 241 242 file_put_contents($new_upload_dir . '/ products_batch_' . $sc_product_id . '.json', json_encode($output));242 file_put_contents($new_upload_dir . '/'.time().'_products_batch_' . $sc_product_id . '.json', json_encode($output)); 243 243 } 244 244 } … … 339 339 $products_array = json_encode($products_array); 340 340 341 $success = file_put_contents($new_upload_dir . '/ products_batch_' . $batch . '.json', $products_array);341 $success = file_put_contents($new_upload_dir . '/'.time().'_products_batch_' . $batch . '.json', $products_array); 342 342 if( $success === FALSE ){ 343 343 $this->logging->log_file_write( 'ERROR | Product batch ' .$batch. ' not created!' ); -
storecontrl-wp-connection/trunk/includes/woocommerce/class-storecontrl-woocommerce-functions.php
r3434321 r3435393 92 92 } 93 93 94 file_put_contents($new_upload_dir . '/ products_batch_bulk.json', json_encode($output));94 file_put_contents($new_upload_dir . '/'.time().'_products_batch_bulk.json', json_encode($output)); 95 95 96 96 $redirect_url = add_query_arg('storecontrl-import-started', count($post_ids), $redirect_url); … … 636 636 $order->update_meta_data('order_returned_successfully_to_storecontrl', '1'); 637 637 } elseif ($results == 'OrderId already exists') { 638 //update_post_meta($order_id, 'order_returned_successfully_to_storecontrl', '1');639 638 $order->update_meta_data('order_returned_successfully_to_storecontrl', '1'); 640 639 $message = 'OrderId already exists: ' . $order_data['id']; -
storecontrl-wp-connection/trunk/readme.txt
r3434321 r3435393 5 5 Requires at least: 6.6.0 6 6 Tested up to: 6.8.3 7 Stable tag: 4.2. 37 Stable tag: 4.2.4 8 8 Requires PHP: 8.0 9 9 License: GPLv2 or later -
storecontrl-wp-connection/trunk/storecontrl-wp-connection.php
r3434321 r3435393 4 4 Plugin URI: http://www.arture.nl/storecontrl 5 5 Description: The Wordpress plugin for connecting Woocommerce with StoreContrl Cloud. With the synchronizing cronjobs your products will be automatically processed, images added, and the categories set. Every 5 minutes all stock changes are processed. We provide a up-to-date plugin, easy setup and always the best support. 6 Version: 4.2. 36 Version: 4.2.4 7 7 Requires Plugins: woocommerce 8 8 Author: Arture
Note: See TracChangeset
for help on using the changeset viewer.