Plugin Directory

Changeset 2510697


Ignore:
Timestamp:
04/07/2021 10:51:40 AM (5 years ago)
Author:
officegestpt
Message:

add cron to force clear parts

Location:
officegest/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • officegest/trunk/officegest.php

    r2494247 r2510697  
    55 *   Plugin URI:   https://www.officegest.com/woocommerce
    66 *   Description:  A forma mais fácil de ligar a sua loja online com a sua faturação.
    7  *   Version:      1.1.2
     7 *   Version:      1.1.3
    88 *   Author:       OfficeGest
    99 *   Author URI:   https://www.officegest.com
  • officegest/trunk/readme.txt

    r2494247 r2510697  
    55Tested up to: 5.5
    66Requires PHP: 7.3
    7 Stable tag: 1.1.2
     7Stable tag: 1.1.3
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    3333
    3434== Changelog ==
     35= 1.1.3 =
     36add cron to force clear parts
     37
    3538= 1.1.2 =
    3639add option to sync only parts with images
  • officegest/trunk/src/Crons.php

    r2420184 r2510697  
    44
    55use Exception;
     6use OfficeGest\Controllers\SyncEcoautoForceClearParts;
    67use OfficeGest\Controllers\SyncEcoautoImages;
    78use OfficeGest\Controllers\SyncOfficeGestArticles;
     
    231232        OfficeGestDBModel::setOption("ecoauto_imagens_time", (int)$runningAt);
    232233    }
     234
     235    /**
     236     * Force clear parts function (officegest_cron_jobs)
     237     *
     238     */
     239    public static function SyncEcoautoForceClearParts(){
     240        $runningAt = time();
     241        try {
     242            self::requires();
     243            if (!Start::login()) {
     244                Log::write("Não foi possível estabelecer uma ligação ao OfficeGest");
     245                return false;
     246            }
     247            $sync_time = OfficeGestDBModel::getOption('officegest_clear_parts_time');
     248            if ($sync_time==null) {
     249                $sync_time =  (int)(time() - 600);
     250                OfficeGestDBModel::setOption('officegest_clear_parts_time',$sync_time);
     251            }
     252            (new SyncEcoautoForceClearParts())->run();
     253        } catch (Exception $ex) {
     254            Log::write("Fatal Errror: " . $ex->getMessage());
     255        }
     256        OfficeGestDBModel::setOption("officegest_clear_parts_time", (int)$runningAt);
     257    }
    233258}
  • officegest/trunk/src/Plugin.php

    r2494247 r2510697  
    55use OfficeGest\Controllers\Documents;
    66use OfficeGest\Controllers\ProductsList;
     7use OfficeGest\Controllers\SyncEcoautoForceClearParts;
    78use WC_Countries;
    89use WC_Order;
     
    8990        if (!wp_next_scheduled('syncOfficeGestArticles')) {
    9091            wp_schedule_event(time(), 'daily', 'syncOfficeGestArticles');
     92        }
     93
     94        /**
     95         * Schedule sync jobs in queue (officegest_cron_jobs)
     96         */
     97        add_action('SyncEcoautoForceClearParts', '\OfficeGest\Crons::SyncEcoautoForceClearParts');
     98        if (!wp_next_scheduled('SyncEcoautoForceClearParts')) {
     99            wp_schedule_event(time(), 'hourly', 'SyncEcoautoForceClearParts');
    91100        }
    92101    }
Note: See TracChangeset for help on using the changeset viewer.