Changeset 3331481
- Timestamp:
- 07/21/2025 12:29:27 PM (8 months ago)
- Location:
- connect-ecommerce
- Files:
-
- 14 edited
- 1 copied
-
tags/3.1.2 (copied) (copied from connect-ecommerce/trunk)
-
tags/3.1.2/connect-ecommerce.php (modified) (3 diffs)
-
tags/3.1.2/includes/Admin/Import_Products.php (modified) (2 diffs)
-
tags/3.1.2/includes/Admin/Settings.php (modified) (2 diffs)
-
tags/3.1.2/includes/Helpers/CRON.php (modified) (4 diffs)
-
tags/3.1.2/includes/Helpers/PROD.php (modified) (3 diffs)
-
tags/3.1.2/readme.txt (modified) (3 diffs)
-
tags/3.1.2/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/connect-ecommerce.php (modified) (3 diffs)
-
trunk/includes/Admin/Import_Products.php (modified) (2 diffs)
-
trunk/includes/Admin/Settings.php (modified) (2 diffs)
-
trunk/includes/Helpers/CRON.php (modified) (4 diffs)
-
trunk/includes/Helpers/PROD.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
connect-ecommerce/tags/3.1.2/connect-ecommerce.php
r3329057 r3331481 6 6 * Author: Closetechnology 7 7 * Author URI: https://close.technology/ 8 * Version: 3.1. 18 * Version: 3.1.2 9 9 * 10 10 * @package WordPress … … 17 17 defined( 'ABSPATH' ) || exit; 18 18 19 define( 'CONECOM_VERSION', '3.1. 1' );19 define( 'CONECOM_VERSION', '3.1.2' ); 20 20 define( 'CONECOM_FILE', __FILE__ ); 21 21 define( 'CONECOM_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); … … 61 61 'table_sync' => $wpdb->prefix . 'sync_conecom-clientify', 62 62 'file' => __FILE__, 63 'cron' => array(64 array(65 'key' => 'every_five_minutes',66 'interval' => 300,67 'display' => __( 'Every 5 minutes', 'connect-ecommerce' ),68 'cron' => 'conecom-clientify_sync_five_minutes',69 ),70 array(71 'key' => 'every_fifteen_minutes',72 'interval' => 900,73 'display' => __( 'Every 15 minutes', 'connect-ecommerce' ),74 'cron' => 'conecom-clientify_sync_fifteen_minutes',75 ),76 array(77 'key' => 'every_thirty_minutes',78 'interval' => 1800,79 'display' => __( 'Every 30 Minutes', 'connect-ecommerce' ),80 'cron' => 'conecom-clientify_sync_thirty_minutes',81 ),82 array(83 'key' => 'every_one_hour',84 'interval' => 3600,85 'display' => __( 'Every 1 Hour', 'connect-ecommerce' ),86 'cron' => 'conecom-clientify_sync_one_hour',87 ),88 array(89 'key' => 'every_three_hours',90 'interval' => 10800,91 'display' => __( 'Every 3 Hours', 'connect-ecommerce' ),92 'cron' => 'conecom-clientify_sync_three_hours',93 ),94 array(95 'key' => 'every_six_hours',96 'interval' => 21600,97 'display' => __( 'Every 6 Hours', 'connect-ecommerce' ),98 'cron' => 'conecom-clientify_sync_six_hours',99 ),100 array(101 'key' => 'every_twelve_hours',102 'interval' => 43200,103 'display' => __( 'Every 12 Hours', 'connect-ecommerce' ),104 'cron' => 'conecom-clientify_sync_twelve_hours',105 ),106 ),107 63 ], 108 64 ] -
connect-ecommerce/tags/3.1.2/includes/Admin/Import_Products.php
r3329057 r3331481 292 292 return; 293 293 } 294 $pos = array_search( $this->sync_period, array_column( $this->options['cron'], 'cron' ), true ); 295 if ( false !== $pos ) { 296 $cron_option = $this->options['cron'][ $pos ]; 297 } 294 $cron_option = CRON::get_active_period( $this->sync_period ); 298 295 299 296 if ( isset( $cron_option['cron'] ) && false === as_has_scheduled_action( $cron_option['cron'] ) ) { … … 309 306 public function cron_sync_products() { 310 307 $is_table_sync = ! empty( $this->options['table_sync'] ) ? true : false; 311 $products_sync = CRON::get_products_sync( $this->settings, $this->options, $this->connapi_erp );312 313 308 if ( $is_table_sync ) { 314 309 HELPER::check_table_sync( $this->options['table_sync'] ); 315 } 316 310 } else { 311 // Check if the API method exists. 312 if ( ! method_exists( $this->connapi_erp, 'get_products_ids_since' ) ) { 313 return; 314 } 315 } 316 317 // Get products to sync. 318 $products_sync = CRON::get_products_sync( $this->settings, $this->options, $this->connapi_erp ); 317 319 if ( empty( $products_sync ) && $is_table_sync ) { 318 320 CRON::send_sync_ended_products( $this->settings, $this->options['table_sync'], $this->options['name'], $this->options['slug'] ); 319 CRON::fill_table_sync( $this->settings, $this->options['table_sync'], $this->connapi_erp, $this->options['slug'] ); 320 } elseif ( ! empty( $products_sync ) ) { 321 CRON::fill_table_sync( $this->settings, $this->options, $this->connapi_erp ); 322 $products_sync = CRON::get_products_sync( $this->settings, $this->options, $this->connapi_erp ); 323 } 324 if ( ! empty( $products_sync ) ) { 321 325 foreach ( $products_sync as $product_sync ) { 322 326 $product_id = isset( $product_sync['prod_id'] ) ? $product_sync['prod_id'] : $product_sync; -
connect-ecommerce/tags/3.1.2/includes/Admin/Settings.php
r3301423 r3331481 17 17 use CLOSE\ConnectEcommerce\Helpers\HELPER; 18 18 use CLOSE\ConnectEcommerce\Helpers\AI; 19 use CLOSE\ConnectEcommerce\Helpers\CRON; 19 20 20 21 /** … … 1465 1466 <option value="no" <?php selected( $sync, 'no' ); ?>><?php esc_html_e( 'No', 'connect-ecommerce' ); ?></option> 1466 1467 <?php 1467 if ( ! empty( $this->options['cron'] ) ) { 1468 foreach ( $this->options['cron'] as $cron_option ) { 1469 echo '<option value="' . esc_html( $cron_option['cron'] ) . '" '; 1470 selected( $sync, $cron_option['cron'] ); 1471 echo '>' . esc_html( $cron_option['display'] ) . '</option>'; 1468 $periods = CRON::get_cron_periods(); 1469 if ( ! empty( $periods ) ) { 1470 foreach ( $periods as $period ) { 1471 echo '<option value="' . esc_html( $period['cron'] ) . '" '; 1472 selected( $sync, $period['cron'] ); 1473 echo '>' . esc_html( $period['display'] ) . '</option>'; 1472 1474 } 1473 1475 } -
connect-ecommerce/tags/3.1.2/includes/Helpers/CRON.php
r3281293 r3331481 48 48 * @return boolean 49 49 */ 50 public static function fill_table_sync( $settings, $table_sync, $api_erp, $option_prefix ) { 51 global $wpdb; 50 public static function fill_table_sync( $settings, $options, $api_erp ) { 51 global $wpdb; 52 $table_sync = isset( $options['table_sync'] ) ? $options['table_sync'] : ''; 53 if ( empty( $table_sync ) ) { 54 return false; 55 } 52 56 $wpdb->query( "TRUNCATE TABLE $table_sync;" ); 53 57 54 // Get products from API. 55 $products = $api_erp->get_products(); 58 // Get ALL products from API. 59 $products = array(); 60 $api_pagination = ! empty( $options['api_pagination'] ) ? (int) $options['api_pagination'] : false; 61 if ( $api_pagination ) { 62 $sync_loop = 0; 63 64 do { 65 $loop_page = $sync_loop * $api_pagination; 66 $api_products = $api_erp->get_products( null, $loop_page ); 67 if ( empty( $api_products ) ) { 68 break; 69 } 70 $sync_loop++; 71 $count_products = count( $api_products ); 72 $products = array_merge( $products, $api_products ); 73 } while ( $count_products === $api_pagination ); 74 75 } else { 76 $products = $api_erp->get_products(); 77 } 78 56 79 if ( ! is_array( $products ) ) { 57 80 return; 58 81 } 59 82 60 update_option( $option_prefix . '_total_api_products', count( $products ) );61 update_option( $option_prefix . '_sync_start_time', strtotime( 'now' ) );62 update_option( $option_prefix . '_sync_errors', array() );83 update_option( 'conecom_total_api_products', count( $products ) ); 84 update_option( 'conecom_sync_start_time', strtotime( 'now' ) ); 85 update_option( 'conecom_sync_errors', array() ); 63 86 64 87 foreach ( $products as $product ) { … … 93 116 // Method with modified products. 94 117 if ( empty( $table_sync ) ) { 95 $sync_period = isset( $settings['sync'] ) ? strval( $settings['sync'] ) : 'no'; 96 $pos = array_search( $sync_period, array_column( $options['cron'], 'cron' ), true ); 97 if ( false !== $pos ) { 98 $cron_option = $options['cron'][ $pos ]; 99 } 100 $modified_since_date = isset( $cron_option['interval'] ) ? strtotime( '-' . $cron_option['interval'] . ' seconds' ) : strtotime( '-1 day' ); 118 $period = self::get_active_period( $settings ); 119 $modified_since_date = isset( $period['interval'] ) ? strtotime( '-' . $period['interval'] . ' seconds' ) : strtotime( '-1 day' ); 101 120 if ( ! method_exists( $connapi_erp, 'get_products_ids_since' ) ) { 102 121 return false; … … 106 125 // Method with table sync. 107 126 global $wpdb; 108 $limit = isset( $settings['sync_num'] ) ? $settings['sync_num'] : 5;127 $limit = isset( $settings['sync_num'] ) ? (int) $settings['sync_num'] : 50; 109 128 110 129 $results = $wpdb->get_results( 111 130 $wpdb->prepare( 112 'SELECT prod_id FROM %i WHERE synced = 0 LIMIT % s',131 'SELECT prod_id FROM %i WHERE synced = 0 LIMIT %d', 113 132 $table_sync, 114 133 $limit … … 248 267 } 249 268 } 269 270 /** 271 * Returns the active period for sync. 272 * 273 * @param array $settings|value Settings of plugin or period. 274 * 275 * @return array|false 276 */ 277 public static function get_active_period( $sync_period ) { 278 $sync_period = is_array( $sync_period ) ? $sync_period['sync'] : $sync_period; 279 280 if ( 'no' === $sync_period ) { 281 return false; 282 } 283 $periods = self::get_cron_periods(); 284 $pos = array_search( $sync_period, array_column( $periods, 'cron' ), true ); 285 286 return false !== $pos ? $periods[ $pos ] : end( $periods ); 287 } 288 289 /** 290 * Returns the cron periods. 291 * 292 * @return array 293 */ 294 public static function get_cron_periods() { 295 return array( 296 array( 297 'key' => 'every_five_minutes', 298 'interval' => 300, 299 'display' => __( 'Every 5 minutes', 'connect-ecommerce' ), 300 'cron' => 'conecom_sync_five_minutes', 301 ), 302 array( 303 'key' => 'every_fifteen_minutes', 304 'interval' => 900, 305 'display' => __( 'Every 15 minutes', 'connect-ecommerce' ), 306 'cron' => 'conecom_sync_fifteen_minutes', 307 ), 308 array( 309 'key' => 'every_thirty_minutes', 310 'interval' => 1800, 311 'display' => __( 'Every 30 Minutes', 'connect-ecommerce' ), 312 'cron' => 'conecom_sync_thirty_minutes', 313 ), 314 array( 315 'key' => 'every_one_hour', 316 'interval' => 3600, 317 'display' => __( 'Every 1 Hour', 'connect-ecommerce' ), 318 'cron' => 'conecom_sync_one_hour', 319 ), 320 array( 321 'key' => 'every_three_hours', 322 'interval' => 10800, 323 'display' => __( 'Every 3 Hours', 'connect-ecommerce' ), 324 'cron' => 'conecom_sync_three_hours', 325 ), 326 array( 327 'key' => 'every_six_hours', 328 'interval' => 21600, 329 'display' => __( 'Every 6 Hours', 'connect-ecommerce' ), 330 'cron' => 'conecom_sync_six_hours', 331 ), 332 array( 333 'key' => 'every_twelve_hours', 334 'interval' => 43200, 335 'display' => __( 'Every 12 Hours', 'connect-ecommerce' ), 336 'cron' => 'conecom_sync_twelve_hours', 337 ), 338 ); 339 } 250 340 } -
connect-ecommerce/tags/3.1.2/includes/Helpers/PROD.php
r3329057 r3331481 576 576 $variation->set_props( $variation_props ); 577 577 // Stock. 578 if ( ! empty( $variant['stock'] ) ) { 579 $variation->set_stock_quantity( $variant['stock'] ); 578 if ( isset( $variant['stock'] ) ) { 579 $stock_status = 0 === (int) $variant['stock'] ? 'outofstock' : 'instock'; 580 $variation->set_stock_quantity( (int) $variant['stock'] ); 580 581 $variation->set_manage_stock( true ); 581 $variation->set_stock_status( 'instock');582 $variation->set_stock_status( $stock_status ); 582 583 } else { 583 584 $variation->set_manage_stock( false ); … … 1088 1089 } 1089 1090 1091 1092 1090 1093 /** 1091 1094 * Get attribute category ID … … 1096 1099 */ 1097 1100 private static function get_rate_price( $item, $rate_id ) { 1101 $price = null; 1102 1098 1103 if ( empty( $item ) ) { 1099 return null; 1100 } 1104 return $price; 1105 } 1106 1101 1107 if ( 'default' === $rate_id || '' === $rate_id || empty( $item['rates'] ) || ! is_array( $item['rates'] ) ) { 1102 returnisset( $item['price'] ) ? $item['price'] : null;1108 $price = isset( $item['price'] ) ? $item['price'] : null; 1103 1109 } else { 1104 1110 $price_key = array_search( $rate_id, array_column( $item['rates'], 'id' ) ); 1105 return isset( $item['rates'][ $price_key ]['subtotal'] ) ? $item['rates'][ $price_key ]['subtotal'] : null; 1106 } 1111 $price = isset( $item['rates'][ $price_key ]['subtotal'] ) ? $item['rates'][ $price_key ]['subtotal'] : null; 1112 $price = empty( $price ) && isset( $item['rates'][ $rate_id ]['subtotal'] ) ? $item['rates'][ $rate_id ]['subtotal'] : $price; 1113 } 1114 return (float) $price; 1107 1115 } 1108 1116 -
connect-ecommerce/tags/3.1.2/readme.txt
r3329057 r3331481 6 6 Requires PHP: 7.0 7 7 Tested up to: 6.8 8 Stable tag: 3.1. 19 Version: 3.1. 18 Stable tag: 3.1.2 9 Version: 3.1.2 10 10 License: GPL2 11 11 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 37 37 - [NEO TPV](https://close.technology/en/wordpress-plugins/connect-woocommerce-neo/) 38 38 39 == Frequently Asked Questions == 40 41 = What does this plugin do? = 42 Connect Ecommerce allows you to import products from a ERP/CRM via API with your WooCommerce store. 43 44 = How are products and orders synchronized? = 45 Products are synchronized from the ERP/CRM to WooCommerce. This is because the ERP should always contain the most up-to-date information about your business. It is the correct source for managing products, pricing, and commercial data. 46 47 Orders are synchronized from WooCommerce to the ERP/CRM. This ensures that every time a customer places an order, it is sent to your ERP for proper order and invoice management. 48 49 = What happens when a simple product is out of stock? = 50 The default behavior is that the product disappears from the store catalog, but it remains visible to search engines. This is intentional and matches the expected behavior of the shop. 39 51 40 52 == Installation == … … 64 76 65 77 == Changelog == 78 79 = 3.1.2 = 80 * Fixed: Getting prices rates from variation products. 81 * Fixed: Zero stock in variation products was giving not manage stock. 82 * Fixed: Automated products sync not working properly. 66 83 67 84 = 3.1.1 = -
connect-ecommerce/tags/3.1.2/vendor/composer/installed.php
r3329057 r3331481 2 2 'root' => array( 3 3 'name' => 'closemarketing/connect-ecommerce', 4 'pretty_version' => '3.1. 1',5 'version' => '3.1. 1.0',6 'reference' => ' 3600b8f8ac4196bfd7f881d9f386cfd3d10ebb01',4 'pretty_version' => '3.1.2', 5 'version' => '3.1.2.0', 6 'reference' => 'fbf4de2acf91f556373c907e1880a7612681101a', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'closemarketing/connect-ecommerce' => array( 14 'pretty_version' => '3.1. 1',15 'version' => '3.1. 1.0',16 'reference' => ' 3600b8f8ac4196bfd7f881d9f386cfd3d10ebb01',14 'pretty_version' => '3.1.2', 15 'version' => '3.1.2.0', 16 'reference' => 'fbf4de2acf91f556373c907e1880a7612681101a', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../../', -
connect-ecommerce/trunk/connect-ecommerce.php
r3329057 r3331481 6 6 * Author: Closetechnology 7 7 * Author URI: https://close.technology/ 8 * Version: 3.1. 18 * Version: 3.1.2 9 9 * 10 10 * @package WordPress … … 17 17 defined( 'ABSPATH' ) || exit; 18 18 19 define( 'CONECOM_VERSION', '3.1. 1' );19 define( 'CONECOM_VERSION', '3.1.2' ); 20 20 define( 'CONECOM_FILE', __FILE__ ); 21 21 define( 'CONECOM_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); … … 61 61 'table_sync' => $wpdb->prefix . 'sync_conecom-clientify', 62 62 'file' => __FILE__, 63 'cron' => array(64 array(65 'key' => 'every_five_minutes',66 'interval' => 300,67 'display' => __( 'Every 5 minutes', 'connect-ecommerce' ),68 'cron' => 'conecom-clientify_sync_five_minutes',69 ),70 array(71 'key' => 'every_fifteen_minutes',72 'interval' => 900,73 'display' => __( 'Every 15 minutes', 'connect-ecommerce' ),74 'cron' => 'conecom-clientify_sync_fifteen_minutes',75 ),76 array(77 'key' => 'every_thirty_minutes',78 'interval' => 1800,79 'display' => __( 'Every 30 Minutes', 'connect-ecommerce' ),80 'cron' => 'conecom-clientify_sync_thirty_minutes',81 ),82 array(83 'key' => 'every_one_hour',84 'interval' => 3600,85 'display' => __( 'Every 1 Hour', 'connect-ecommerce' ),86 'cron' => 'conecom-clientify_sync_one_hour',87 ),88 array(89 'key' => 'every_three_hours',90 'interval' => 10800,91 'display' => __( 'Every 3 Hours', 'connect-ecommerce' ),92 'cron' => 'conecom-clientify_sync_three_hours',93 ),94 array(95 'key' => 'every_six_hours',96 'interval' => 21600,97 'display' => __( 'Every 6 Hours', 'connect-ecommerce' ),98 'cron' => 'conecom-clientify_sync_six_hours',99 ),100 array(101 'key' => 'every_twelve_hours',102 'interval' => 43200,103 'display' => __( 'Every 12 Hours', 'connect-ecommerce' ),104 'cron' => 'conecom-clientify_sync_twelve_hours',105 ),106 ),107 63 ], 108 64 ] -
connect-ecommerce/trunk/includes/Admin/Import_Products.php
r3329057 r3331481 292 292 return; 293 293 } 294 $pos = array_search( $this->sync_period, array_column( $this->options['cron'], 'cron' ), true ); 295 if ( false !== $pos ) { 296 $cron_option = $this->options['cron'][ $pos ]; 297 } 294 $cron_option = CRON::get_active_period( $this->sync_period ); 298 295 299 296 if ( isset( $cron_option['cron'] ) && false === as_has_scheduled_action( $cron_option['cron'] ) ) { … … 309 306 public function cron_sync_products() { 310 307 $is_table_sync = ! empty( $this->options['table_sync'] ) ? true : false; 311 $products_sync = CRON::get_products_sync( $this->settings, $this->options, $this->connapi_erp );312 313 308 if ( $is_table_sync ) { 314 309 HELPER::check_table_sync( $this->options['table_sync'] ); 315 } 316 310 } else { 311 // Check if the API method exists. 312 if ( ! method_exists( $this->connapi_erp, 'get_products_ids_since' ) ) { 313 return; 314 } 315 } 316 317 // Get products to sync. 318 $products_sync = CRON::get_products_sync( $this->settings, $this->options, $this->connapi_erp ); 317 319 if ( empty( $products_sync ) && $is_table_sync ) { 318 320 CRON::send_sync_ended_products( $this->settings, $this->options['table_sync'], $this->options['name'], $this->options['slug'] ); 319 CRON::fill_table_sync( $this->settings, $this->options['table_sync'], $this->connapi_erp, $this->options['slug'] ); 320 } elseif ( ! empty( $products_sync ) ) { 321 CRON::fill_table_sync( $this->settings, $this->options, $this->connapi_erp ); 322 $products_sync = CRON::get_products_sync( $this->settings, $this->options, $this->connapi_erp ); 323 } 324 if ( ! empty( $products_sync ) ) { 321 325 foreach ( $products_sync as $product_sync ) { 322 326 $product_id = isset( $product_sync['prod_id'] ) ? $product_sync['prod_id'] : $product_sync; -
connect-ecommerce/trunk/includes/Admin/Settings.php
r3301423 r3331481 17 17 use CLOSE\ConnectEcommerce\Helpers\HELPER; 18 18 use CLOSE\ConnectEcommerce\Helpers\AI; 19 use CLOSE\ConnectEcommerce\Helpers\CRON; 19 20 20 21 /** … … 1465 1466 <option value="no" <?php selected( $sync, 'no' ); ?>><?php esc_html_e( 'No', 'connect-ecommerce' ); ?></option> 1466 1467 <?php 1467 if ( ! empty( $this->options['cron'] ) ) { 1468 foreach ( $this->options['cron'] as $cron_option ) { 1469 echo '<option value="' . esc_html( $cron_option['cron'] ) . '" '; 1470 selected( $sync, $cron_option['cron'] ); 1471 echo '>' . esc_html( $cron_option['display'] ) . '</option>'; 1468 $periods = CRON::get_cron_periods(); 1469 if ( ! empty( $periods ) ) { 1470 foreach ( $periods as $period ) { 1471 echo '<option value="' . esc_html( $period['cron'] ) . '" '; 1472 selected( $sync, $period['cron'] ); 1473 echo '>' . esc_html( $period['display'] ) . '</option>'; 1472 1474 } 1473 1475 } -
connect-ecommerce/trunk/includes/Helpers/CRON.php
r3281293 r3331481 48 48 * @return boolean 49 49 */ 50 public static function fill_table_sync( $settings, $table_sync, $api_erp, $option_prefix ) { 51 global $wpdb; 50 public static function fill_table_sync( $settings, $options, $api_erp ) { 51 global $wpdb; 52 $table_sync = isset( $options['table_sync'] ) ? $options['table_sync'] : ''; 53 if ( empty( $table_sync ) ) { 54 return false; 55 } 52 56 $wpdb->query( "TRUNCATE TABLE $table_sync;" ); 53 57 54 // Get products from API. 55 $products = $api_erp->get_products(); 58 // Get ALL products from API. 59 $products = array(); 60 $api_pagination = ! empty( $options['api_pagination'] ) ? (int) $options['api_pagination'] : false; 61 if ( $api_pagination ) { 62 $sync_loop = 0; 63 64 do { 65 $loop_page = $sync_loop * $api_pagination; 66 $api_products = $api_erp->get_products( null, $loop_page ); 67 if ( empty( $api_products ) ) { 68 break; 69 } 70 $sync_loop++; 71 $count_products = count( $api_products ); 72 $products = array_merge( $products, $api_products ); 73 } while ( $count_products === $api_pagination ); 74 75 } else { 76 $products = $api_erp->get_products(); 77 } 78 56 79 if ( ! is_array( $products ) ) { 57 80 return; 58 81 } 59 82 60 update_option( $option_prefix . '_total_api_products', count( $products ) );61 update_option( $option_prefix . '_sync_start_time', strtotime( 'now' ) );62 update_option( $option_prefix . '_sync_errors', array() );83 update_option( 'conecom_total_api_products', count( $products ) ); 84 update_option( 'conecom_sync_start_time', strtotime( 'now' ) ); 85 update_option( 'conecom_sync_errors', array() ); 63 86 64 87 foreach ( $products as $product ) { … … 93 116 // Method with modified products. 94 117 if ( empty( $table_sync ) ) { 95 $sync_period = isset( $settings['sync'] ) ? strval( $settings['sync'] ) : 'no'; 96 $pos = array_search( $sync_period, array_column( $options['cron'], 'cron' ), true ); 97 if ( false !== $pos ) { 98 $cron_option = $options['cron'][ $pos ]; 99 } 100 $modified_since_date = isset( $cron_option['interval'] ) ? strtotime( '-' . $cron_option['interval'] . ' seconds' ) : strtotime( '-1 day' ); 118 $period = self::get_active_period( $settings ); 119 $modified_since_date = isset( $period['interval'] ) ? strtotime( '-' . $period['interval'] . ' seconds' ) : strtotime( '-1 day' ); 101 120 if ( ! method_exists( $connapi_erp, 'get_products_ids_since' ) ) { 102 121 return false; … … 106 125 // Method with table sync. 107 126 global $wpdb; 108 $limit = isset( $settings['sync_num'] ) ? $settings['sync_num'] : 5;127 $limit = isset( $settings['sync_num'] ) ? (int) $settings['sync_num'] : 50; 109 128 110 129 $results = $wpdb->get_results( 111 130 $wpdb->prepare( 112 'SELECT prod_id FROM %i WHERE synced = 0 LIMIT % s',131 'SELECT prod_id FROM %i WHERE synced = 0 LIMIT %d', 113 132 $table_sync, 114 133 $limit … … 248 267 } 249 268 } 269 270 /** 271 * Returns the active period for sync. 272 * 273 * @param array $settings|value Settings of plugin or period. 274 * 275 * @return array|false 276 */ 277 public static function get_active_period( $sync_period ) { 278 $sync_period = is_array( $sync_period ) ? $sync_period['sync'] : $sync_period; 279 280 if ( 'no' === $sync_period ) { 281 return false; 282 } 283 $periods = self::get_cron_periods(); 284 $pos = array_search( $sync_period, array_column( $periods, 'cron' ), true ); 285 286 return false !== $pos ? $periods[ $pos ] : end( $periods ); 287 } 288 289 /** 290 * Returns the cron periods. 291 * 292 * @return array 293 */ 294 public static function get_cron_periods() { 295 return array( 296 array( 297 'key' => 'every_five_minutes', 298 'interval' => 300, 299 'display' => __( 'Every 5 minutes', 'connect-ecommerce' ), 300 'cron' => 'conecom_sync_five_minutes', 301 ), 302 array( 303 'key' => 'every_fifteen_minutes', 304 'interval' => 900, 305 'display' => __( 'Every 15 minutes', 'connect-ecommerce' ), 306 'cron' => 'conecom_sync_fifteen_minutes', 307 ), 308 array( 309 'key' => 'every_thirty_minutes', 310 'interval' => 1800, 311 'display' => __( 'Every 30 Minutes', 'connect-ecommerce' ), 312 'cron' => 'conecom_sync_thirty_minutes', 313 ), 314 array( 315 'key' => 'every_one_hour', 316 'interval' => 3600, 317 'display' => __( 'Every 1 Hour', 'connect-ecommerce' ), 318 'cron' => 'conecom_sync_one_hour', 319 ), 320 array( 321 'key' => 'every_three_hours', 322 'interval' => 10800, 323 'display' => __( 'Every 3 Hours', 'connect-ecommerce' ), 324 'cron' => 'conecom_sync_three_hours', 325 ), 326 array( 327 'key' => 'every_six_hours', 328 'interval' => 21600, 329 'display' => __( 'Every 6 Hours', 'connect-ecommerce' ), 330 'cron' => 'conecom_sync_six_hours', 331 ), 332 array( 333 'key' => 'every_twelve_hours', 334 'interval' => 43200, 335 'display' => __( 'Every 12 Hours', 'connect-ecommerce' ), 336 'cron' => 'conecom_sync_twelve_hours', 337 ), 338 ); 339 } 250 340 } -
connect-ecommerce/trunk/includes/Helpers/PROD.php
r3329057 r3331481 576 576 $variation->set_props( $variation_props ); 577 577 // Stock. 578 if ( ! empty( $variant['stock'] ) ) { 579 $variation->set_stock_quantity( $variant['stock'] ); 578 if ( isset( $variant['stock'] ) ) { 579 $stock_status = 0 === (int) $variant['stock'] ? 'outofstock' : 'instock'; 580 $variation->set_stock_quantity( (int) $variant['stock'] ); 580 581 $variation->set_manage_stock( true ); 581 $variation->set_stock_status( 'instock');582 $variation->set_stock_status( $stock_status ); 582 583 } else { 583 584 $variation->set_manage_stock( false ); … … 1088 1089 } 1089 1090 1091 1092 1090 1093 /** 1091 1094 * Get attribute category ID … … 1096 1099 */ 1097 1100 private static function get_rate_price( $item, $rate_id ) { 1101 $price = null; 1102 1098 1103 if ( empty( $item ) ) { 1099 return null; 1100 } 1104 return $price; 1105 } 1106 1101 1107 if ( 'default' === $rate_id || '' === $rate_id || empty( $item['rates'] ) || ! is_array( $item['rates'] ) ) { 1102 returnisset( $item['price'] ) ? $item['price'] : null;1108 $price = isset( $item['price'] ) ? $item['price'] : null; 1103 1109 } else { 1104 1110 $price_key = array_search( $rate_id, array_column( $item['rates'], 'id' ) ); 1105 return isset( $item['rates'][ $price_key ]['subtotal'] ) ? $item['rates'][ $price_key ]['subtotal'] : null; 1106 } 1111 $price = isset( $item['rates'][ $price_key ]['subtotal'] ) ? $item['rates'][ $price_key ]['subtotal'] : null; 1112 $price = empty( $price ) && isset( $item['rates'][ $rate_id ]['subtotal'] ) ? $item['rates'][ $rate_id ]['subtotal'] : $price; 1113 } 1114 return (float) $price; 1107 1115 } 1108 1116 -
connect-ecommerce/trunk/readme.txt
r3329057 r3331481 6 6 Requires PHP: 7.0 7 7 Tested up to: 6.8 8 Stable tag: 3.1. 19 Version: 3.1. 18 Stable tag: 3.1.2 9 Version: 3.1.2 10 10 License: GPL2 11 11 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 37 37 - [NEO TPV](https://close.technology/en/wordpress-plugins/connect-woocommerce-neo/) 38 38 39 == Frequently Asked Questions == 40 41 = What does this plugin do? = 42 Connect Ecommerce allows you to import products from a ERP/CRM via API with your WooCommerce store. 43 44 = How are products and orders synchronized? = 45 Products are synchronized from the ERP/CRM to WooCommerce. This is because the ERP should always contain the most up-to-date information about your business. It is the correct source for managing products, pricing, and commercial data. 46 47 Orders are synchronized from WooCommerce to the ERP/CRM. This ensures that every time a customer places an order, it is sent to your ERP for proper order and invoice management. 48 49 = What happens when a simple product is out of stock? = 50 The default behavior is that the product disappears from the store catalog, but it remains visible to search engines. This is intentional and matches the expected behavior of the shop. 39 51 40 52 == Installation == … … 64 76 65 77 == Changelog == 78 79 = 3.1.2 = 80 * Fixed: Getting prices rates from variation products. 81 * Fixed: Zero stock in variation products was giving not manage stock. 82 * Fixed: Automated products sync not working properly. 66 83 67 84 = 3.1.1 = -
connect-ecommerce/trunk/vendor/composer/installed.php
r3329057 r3331481 2 2 'root' => array( 3 3 'name' => 'closemarketing/connect-ecommerce', 4 'pretty_version' => '3.1. 1',5 'version' => '3.1. 1.0',6 'reference' => ' 3600b8f8ac4196bfd7f881d9f386cfd3d10ebb01',4 'pretty_version' => '3.1.2', 5 'version' => '3.1.2.0', 6 'reference' => 'fbf4de2acf91f556373c907e1880a7612681101a', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'closemarketing/connect-ecommerce' => array( 14 'pretty_version' => '3.1. 1',15 'version' => '3.1. 1.0',16 'reference' => ' 3600b8f8ac4196bfd7f881d9f386cfd3d10ebb01',14 'pretty_version' => '3.1.2', 15 'version' => '3.1.2.0', 16 'reference' => 'fbf4de2acf91f556373c907e1880a7612681101a', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.