Changeset 2742625
- Timestamp:
- 06/15/2022 06:49:53 AM (4 years ago)
- Location:
- ourivesweb-api
- Files:
-
- 6 edited
-
tags/1.1.1/src/Controller/Products/Product.php (modified) (1 diff)
-
tags/1.1.1/src/Plugin.php (modified) (2 diffs)
-
tags/1.1.1/src/Views/settings.php (modified) (1 diff)
-
trunk/src/Controller/Products/Product.php (modified) (1 diff)
-
trunk/src/Plugin.php (modified) (3 diffs)
-
trunk/src/Views/settings.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ourivesweb-api/tags/1.1.1/src/Controller/Products/Product.php
r2742584 r2742625 41 41 $tempo = time(); 42 42 43 L OG::phpCreateFile($File_name); //Cria documento43 Log::phpCreateFile($File_name); //Cria documento 44 44 Log::write(OURIVES_DIVIDER . "<br/>" . OURIVES_DIVIDER . "<br/>"); 45 45 Log::write('-----> Update Started'); -
ourivesweb-api/tags/1.1.1/src/Plugin.php
r2742584 r2742625 159 159 public static function syncProductCron() 160 160 { 161 Log::write('Iniciando uma Sincronização'); 161 Log::write('Iniciando Sincronização Automática'); 162 Model::defineConfigs(); 162 163 (new Product())->Update_OurivesWeb_ToWC(); 163 164 } … … 165 166 private function crons() 166 167 { 168 global $wpdb; 167 169 remove_action("woocommerce_update_product", __CLASS__ . '::productUpdated'); 168 170 add_action('woocommerce_update_product', __CLASS__ . '::productUpdated'); 169 171 170 add_action('woocommerce_Ourives_Sync_product', 'OurivesWeb\Plugin::syncProductCron'); 171 172 173 if ((!wp_next_scheduled('woocommerce_Ourives_Sync_product'))) { 174 global $wpdb; 175 $results = $wpdb->get_results("SELECT selected FROM OurivesWeb_api_config WHERE config = 'ourivesweb_stock_sync'"); 176 177 if ($results[0]->selected == 1) { 178 $results = $wpdb->get_results("SELECT selected FROM OurivesWeb_api_config WHERE config = 'ourivesweb_stock_sync_time'"); 179 180 if (!empty($results)) { 181 $value = $results[0]->selected; 182 } else { 183 $value = 1000; 184 } 185 return wp_schedule_single_event(time() + $value, 'woocommerce_Ourives_Sync_product'); 186 } 187 } 188 189 172 add_action('ourivesweb_woocommerce_products_sync', '\OurivesWeb\Plugin::syncProductCron'); 173 $ourivesweb_stock_sync = absint($wpdb->get_var("SELECT selected FROM OurivesWeb_api_config WHERE config = 'ourivesweb_stock_sync'")); 174 $next_exec = time() + (absint($wpdb->get_var("SELECT selected FROM OurivesWeb_api_config WHERE config = 'ourivesweb_stock_sync_time'")) ?: 1000); 175 if ($ourivesweb_stock_sync && !wp_next_scheduled('ourivesweb_woocommerce_products_sync')) { 176 wp_schedule_single_event($next_exec, 'ourivesweb_woocommerce_products_sync'); 177 Log::write('Finalizando Sincronização Automática'); 178 Log::write(sprintf('Próxima sincronização agendada para %s', date('Y-m-d H:i:s', $next_exec))); 179 } 190 180 add_action('woocommerce_order_status_changed', '\OurivesWeb\Plugin::autoDoc', 10, 3); 191 181 } -
ourivesweb-api/tags/1.1.1/src/Views/settings.php
r2742584 r2742625 419 419 <label class="slidecontainer"> 420 420 <?php 421 if (defined('OURIVES _STOCK_SYNC_TIME')) {421 if (defined('OURIVESWEB_STOCK_SYNC_TIME')) { 422 422 echo ' 423 423 <label for="ourivesweb_stock_sync_time">' . ("Intervalo para sincronização automática") . '<p>Valor: <span id="demo"></span></p></label> 424 <input type="range" min="300" max="43200" step="300" id="myRange" class="slider" placeholder="Intervalo para sincronização automática" name="opt[ourivesweb_stock_sync_time]" value=' . OURIVES _STOCK_SYNC_TIME . '>';424 <input type="range" min="300" max="43200" step="300" id="myRange" class="slider" placeholder="Intervalo para sincronização automática" name="opt[ourivesweb_stock_sync_time]" value=' . OURIVESWEB_STOCK_SYNC_TIME . '>'; 425 425 } ?> 426 426 </label> -
ourivesweb-api/trunk/src/Controller/Products/Product.php
r2726965 r2742625 41 41 $tempo = time(); 42 42 43 L OG::phpCreateFile($File_name); //Cria documento43 Log::phpCreateFile($File_name); //Cria documento 44 44 Log::write(OURIVES_DIVIDER . "<br/>" . OURIVES_DIVIDER . "<br/>"); 45 45 Log::write('-----> Update Started'); -
ourivesweb-api/trunk/src/Plugin.php
r2742574 r2742625 159 159 public static function syncProductCron() 160 160 { 161 Log::write('Iniciando uma Sincronização'); 161 Log::write('Iniciando Sincronização Automática'); 162 Model::defineConfigs(); 162 163 (new Product())->Update_OurivesWeb_ToWC(); 163 164 } … … 165 166 private function crons() 166 167 { 168 global $wpdb; 167 169 remove_action("woocommerce_update_product", __CLASS__ . '::productUpdated'); 168 170 add_action('woocommerce_update_product', __CLASS__ . '::productUpdated'); 169 171 170 add_action('woocommerce_Ourives_Sync_product', 'OurivesWeb\Plugin::syncProductCron'); 171 172 173 if ((!wp_next_scheduled('woocommerce_Ourives_Sync_product'))) { 174 global $wpdb; 175 $results = $wpdb->get_results("SELECT selected FROM OurivesWeb_api_config WHERE config = 'ourivesweb_stock_sync'"); 176 177 if ($results[0]->selected == 1) { 178 $results = $wpdb->get_results("SELECT selected FROM OurivesWeb_api_config WHERE config = 'ourivesweb_stock_sync_time'"); 179 180 if (!empty($results)) { 181 $value = $results[0]->selected; 182 } else { 183 $value = 1000; 184 } 185 return wp_schedule_single_event(time() + $value, 'woocommerce_Ourives_Sync_product'); 186 } 187 } 188 189 172 add_action('ourivesweb_woocommerce_products_sync', '\OurivesWeb\Plugin::syncProductCron'); 173 $ourivesweb_stock_sync = absint($wpdb->get_var("SELECT selected FROM OurivesWeb_api_config WHERE config = 'ourivesweb_stock_sync'")); 174 $next_exec = time() + (absint($wpdb->get_var("SELECT selected FROM OurivesWeb_api_config WHERE config = 'ourivesweb_stock_sync_time'")) ?: 1000); 175 if ($ourivesweb_stock_sync && !wp_next_scheduled('ourivesweb_woocommerce_products_sync')) { 176 wp_schedule_single_event($next_exec, 'ourivesweb_woocommerce_products_sync'); 177 Log::write('Finalizando Sincronização Automática'); 178 Log::write(sprintf('Próxima sincronização agendada para %s', date('Y-m-d H:i:s', $next_exec))); 179 } 190 180 add_action('woocommerce_order_status_changed', '\OurivesWeb\Plugin::autoDoc', 10, 3); 191 181 } … … 211 201 } 212 202 213 private function update(){ 214 if(OURIVES_VERSION === '1.1.1') { 203 private function update() 204 { 205 if (OURIVES_VERSION === '1.1.1') { 215 206 global $wpdb; 216 207 $wpdb->query("UPDATE OurivesWeb_api_config SET config='ourivesweb_stock_sync' WHERE config = 'Ourives_stock_sync'"); -
ourivesweb-api/trunk/src/Views/settings.php
r2742574 r2742625 419 419 <label class="slidecontainer"> 420 420 <?php 421 if (defined('OURIVES _STOCK_SYNC_TIME')) {421 if (defined('OURIVESWEB_STOCK_SYNC_TIME')) { 422 422 echo ' 423 423 <label for="ourivesweb_stock_sync_time">' . ("Intervalo para sincronização automática") . '<p>Valor: <span id="demo"></span></p></label> 424 <input type="range" min="300" max="43200" step="300" id="myRange" class="slider" placeholder="Intervalo para sincronização automática" name="opt[ourivesweb_stock_sync_time]" value=' . OURIVES _STOCK_SYNC_TIME . '>';424 <input type="range" min="300" max="43200" step="300" id="myRange" class="slider" placeholder="Intervalo para sincronização automática" name="opt[ourivesweb_stock_sync_time]" value=' . OURIVESWEB_STOCK_SYNC_TIME . '>'; 425 425 } ?> 426 426 </label>
Note: See TracChangeset
for help on using the changeset viewer.