v3.3.2
This commit is contained in:
parent
a0541627d7
commit
4a90087e61
@ -1,3 +1,7 @@
|
||||
## 2018-08-22 v3.3.2
|
||||
* Убрана проверка существования задач в wp-cron при каждой загрузке страницы
|
||||
* Задачи в wp-cron теперь активируются в настройках плагина
|
||||
|
||||
## 2018-08-09 v3.3.1
|
||||
* Исправлена ошибка с дублированием товаров с WC
|
||||
|
||||
|
@ -49,15 +49,12 @@ if (!class_exists('WC_Retailcrm_Base')) {
|
||||
|
||||
// Actions.
|
||||
add_action('woocommerce_update_options_integration_' . $this->id, array($this, 'process_admin_options'));
|
||||
add_filter('woocommerce_settings_api_sanitized_fields_' . $this->id, array($this, 'api_sanitized'));
|
||||
|
||||
add_filter('cron_schedules', array($this, 'filter_cron_schedules'), 10, 1);
|
||||
add_action('woocommerce_checkout_order_processed', array($this, 'retailcrm_process_order'), 10, 1);
|
||||
add_action('retailcrm_history', array($this, 'retailcrm_history_get'));
|
||||
add_action('retailcrm_icml', array($this, 'generate_icml'));
|
||||
add_action('retailcrm_inventories', array($this, 'load_stocks'));
|
||||
add_action('init', array($this, 'register_load_inventories'));
|
||||
add_action('init', array($this, 'register_icml_generation'));
|
||||
add_action('init', array($this, 'register_retailcrm_history'));
|
||||
add_action('wp_ajax_do_upload', array($this, 'upload_to_crm'));
|
||||
add_action('wp_ajax_generate_icml', array($this, 'generate_icml'));
|
||||
add_action('wp_ajax_order_upload', array($this, 'order_upload'));
|
||||
@ -71,6 +68,35 @@ if (!class_exists('WC_Retailcrm_Base')) {
|
||||
add_action('wp_print_footer_scripts', array($this, 'send_analytics'), 99);
|
||||
}
|
||||
|
||||
public function api_sanitized($settings)
|
||||
{
|
||||
if (isset($settings['sync']) && $settings['sync'] == 'yes') {
|
||||
if (!wp_next_scheduled('retailcrm_inventories')) {
|
||||
wp_schedule_event(time(), 'fiveteen_minutes', 'retailcrm_inventories');
|
||||
}
|
||||
} elseif (isset($settings['sync']) && $settings['sync'] == 'no') {
|
||||
wp_clear_scheduled_hook('retailcrm_inventories');
|
||||
}
|
||||
|
||||
if (isset($settings['history']) && $settings['history'] == 'yes') {
|
||||
if (!wp_next_scheduled('retailcrm_history')) {
|
||||
wp_schedule_event(time(), 'five_minutes', 'retailcrm_history');
|
||||
}
|
||||
} elseif (isset($settings['history']) && $settings['history'] == 'no') {
|
||||
wp_clear_scheduled_hook('retailcrm_history');
|
||||
}
|
||||
|
||||
if (isset($settings['icml']) && $settings['icml'] == 'yes') {
|
||||
if (!wp_next_scheduled('retailcrm_icml')) {
|
||||
wp_schedule_event(time(), 'three_hours', 'retailcrm_icml');
|
||||
}
|
||||
} elseif (isset($settings['icml']) && $settings['icml'] == 'no') {
|
||||
wp_clear_scheduled_hook('retailcrm_icml');
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check custom file
|
||||
*
|
||||
@ -86,26 +112,6 @@ if (!class_exists('WC_Retailcrm_Base')) {
|
||||
return 'class-wc-retailcrm-' . $file . '.php';
|
||||
}
|
||||
|
||||
public function filter_cron_schedules($schedules) {
|
||||
return array_merge(
|
||||
$schedules,
|
||||
array(
|
||||
'five_minutes' => array(
|
||||
'interval' => 300, // seconds
|
||||
'display' => __('Every 5 minutes')
|
||||
),
|
||||
'three_hours' => array(
|
||||
'interval' => 10800, // seconds
|
||||
'display' => __('Every 3 hours')
|
||||
),
|
||||
'fiveteen_minutes' => array(
|
||||
'interval' => 900, // seconds
|
||||
'display' => __('Every 15 minutes')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function generate_icml() {
|
||||
if (!class_exists('WC_Retailcrm_Icml')) {
|
||||
require_once (self::checkCustomFile('icml'));
|
||||
@ -151,29 +157,6 @@ if (!class_exists('WC_Retailcrm_Base')) {
|
||||
$inventories->updateQuantity();
|
||||
}
|
||||
|
||||
public function register_load_inventories() {
|
||||
if ( !wp_next_scheduled( 'retailcrm_inventories' ) ) {
|
||||
// Schedule the event
|
||||
wp_schedule_event( time(), 'fiveteen_minutes', 'retailcrm_inventories' );
|
||||
}
|
||||
}
|
||||
|
||||
public function register_icml_generation() {
|
||||
// Make sure this event hasn't been scheduled
|
||||
if ( !wp_next_scheduled( 'retailcrm_icml' ) ) {
|
||||
// Schedule the event
|
||||
wp_schedule_event( time(), 'three_hours', 'retailcrm_icml' );
|
||||
}
|
||||
}
|
||||
|
||||
public function register_retailcrm_history() {
|
||||
// Make sure this event hasn't been scheduled
|
||||
if ( !wp_next_scheduled( 'retailcrm_history' ) ) {
|
||||
// Schedule the event
|
||||
wp_schedule_event( time(), 'five_minutes', 'retailcrm_history' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload selected orders
|
||||
*/
|
||||
@ -468,6 +451,7 @@ if (!class_exists('WC_Retailcrm_Base')) {
|
||||
'type' => 'multiselect',
|
||||
'description' => __('Select order methods which will be uploaded from retailCRM to the website', 'retailcrm'),
|
||||
'options' => $order_methods_option,
|
||||
'css' => 'min-height:100px;',
|
||||
'select_buttons' => true
|
||||
);
|
||||
}
|
||||
@ -665,6 +649,13 @@ if (!class_exists('WC_Retailcrm_Base')) {
|
||||
'id' => 'icml-retailcrm'
|
||||
);
|
||||
|
||||
$this->form_fields['icml'] = array(
|
||||
'label' => __('Generating ICML', 'retailcrm'),
|
||||
'title' => __('Generating ICML catalog by wp-cron', 'retailcrm'),
|
||||
'class' => 'checkbox',
|
||||
'type' => 'checkbox'
|
||||
);
|
||||
|
||||
/*
|
||||
* Upload single order
|
||||
*/
|
||||
@ -691,6 +682,13 @@ if (!class_exists('WC_Retailcrm_Base')) {
|
||||
'desc_tip' => true,
|
||||
'id' => 'single_order_btn'
|
||||
);
|
||||
|
||||
$this->form_fields['history'] = array(
|
||||
'label' => __('Activate history uploads', 'retailcrm'),
|
||||
'title' => __('Upload data from retailCRM', 'retailcrm'),
|
||||
'class' => 'checkbox',
|
||||
'type' => 'checkbox'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,28 @@ class WC_Retailcrm_Plugin {
|
||||
|
||||
private function __construct($file) {
|
||||
$this->file = $file;
|
||||
|
||||
add_filter('cron_schedules', array($this, 'filter_cron_schedules'), 10, 1);
|
||||
}
|
||||
|
||||
public function filter_cron_schedules($schedules) {
|
||||
return array_merge(
|
||||
$schedules,
|
||||
array(
|
||||
'five_minutes' => array(
|
||||
'interval' => 300, // seconds
|
||||
'display' => __('Every 5 minutes')
|
||||
),
|
||||
'three_hours' => array(
|
||||
'interval' => 10800, // seconds
|
||||
'display' => __('Every 3 hours')
|
||||
),
|
||||
'fiveteen_minutes' => array(
|
||||
'interval' => 900, // seconds
|
||||
'display' => __('Every 15 minutes')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function register_activation_hook() {
|
||||
|
Binary file not shown.
@ -45,6 +45,9 @@ API-ключ должен быть для отдельного магазина
|
||||
2. В появившихся списках справочников настройте соответствие способов доставки и оплаты, а так же статусов заказов. Отметьте галочку "Выгружать остатки", если хотите выгружать остатки из Retailcrm в магазин (подробнее смотрите в описании).
|
||||
|
||||
== Changelog ==
|
||||
= 3.3.2 =
|
||||
* Задачи в wp-cron теперь активируются в настройках плагина
|
||||
|
||||
= 3.3.1 =
|
||||
* Исправлена ошибка с дублированием товаров с WC
|
||||
|
||||
@ -138,6 +141,9 @@ API-ключ должен быть для отдельного магазина
|
||||
|
||||
== Upgrade Notice ==
|
||||
|
||||
= 3.3.2 =
|
||||
Добавлена настройка для активации задач в wp-cron
|
||||
|
||||
= 3.3.1 =
|
||||
Исправлена ошибка с дублированием товаров с WC
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Version: 3.3.1
|
||||
* Version: 3.3.2
|
||||
* WC requires at least: 3.0
|
||||
* WC tested up to: 3.4.3
|
||||
* Plugin Name: WooCommerce RetailCRM
|
||||
@ -36,19 +36,23 @@ if (!class_exists( 'WC_Integration_Retailcrm')) :
|
||||
* Construct the plugin.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action('plugins_loaded', array($this, 'load_plugin_textdomain'));
|
||||
$this->load_plugin_textdomain();
|
||||
|
||||
if ( class_exists( 'WC_Integration' ) ) {
|
||||
require_once( dirname( __FILE__ ) . '/include/class-wc-retailcrm-base.php' );
|
||||
require_once( dirname( __FILE__ ) . '/include/functions.php' );
|
||||
if (class_exists( 'WC_Integration' ) ) {
|
||||
require_once(dirname(__FILE__ ) . '/include/class-wc-retailcrm-base.php');
|
||||
require_once(dirname(__FILE__ ) . '/include/functions.php');
|
||||
add_filter('woocommerce_integrations', array( $this, 'add_integration'));
|
||||
} else {
|
||||
// throw an admin error if you like
|
||||
add_action('admin_notices', array($this, 'woocommerce_missing_notice'));
|
||||
}
|
||||
}
|
||||
|
||||
public function woocommerce_missing_notice() {
|
||||
echo '<div class="error"><p>Woocommerce is not installed</p></div>';
|
||||
}
|
||||
|
||||
public function load_plugin_textdomain() {
|
||||
load_plugin_textdomain('retailcrm', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
||||
load_plugin_textdomain('retailcrm', false, dirname(plugin_basename(__FILE__)) . '/languages/');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -15,28 +15,30 @@
|
||||
*
|
||||
*
|
||||
* @link https://wordpress.org/plugins/woo-retailcrm/
|
||||
* @version 3.3.1
|
||||
* @version 3.3.2
|
||||
*
|
||||
* @package RetailCRM
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
if (!defined('ABSPATH')) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
// If uninstall not called from WordPress, then exit.
|
||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||
if (!defined('WP_UNINSTALL_PLUGIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
|
||||
wp_clear_scheduled_hook( 'retailcrm_icml' );
|
||||
wp_clear_scheduled_hook( 'retailcrm_history' );
|
||||
wp_clear_scheduled_hook( 'retailcrm_inventories' );
|
||||
wp_clear_scheduled_hook('retailcrm_icml');
|
||||
wp_clear_scheduled_hook('retailcrm_history');
|
||||
wp_clear_scheduled_hook('retailcrm_inventories');
|
||||
|
||||
// Delete options.
|
||||
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name = 'woocommerce_integration-retailcrm_settings';" );
|
||||
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name = 'woocommerce_integration-retailcrm_settings';");
|
||||
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name = 'retailcrm_customers_history_since_id';");
|
||||
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name = 'retailcrm_orders_history_since_id';");
|
||||
|
||||
// Clear any cached data that has been removed
|
||||
wp_cache_flush();
|
||||
|
Loading…
x
Reference in New Issue
Block a user