1
0
mirror of synced 2025-03-24 17:13:54 +03:00

ICML catalog settings updating

This commit is contained in:
Dima Uryvskiy 2021-07-27 13:09:30 +03:00 committed by GitHub
parent 6ad9fc2661
commit 4ef67f595e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -107,6 +107,16 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
)
);
$post = $this->get_post_data();
$apiUrl = !empty($post[$this->plugin_id . $this->id . '_api_url']) ? $post[$this->plugin_id . $this->id . '_api_url'] : null;
$apiKey = !empty($post[$this->plugin_id . $this->id . '_api_key']) ? $post[$this->plugin_id . $this->id . '_api_key'] : null;
if ($this->apiClient) {
if (isset($_GET['page']) && $_GET['page'] == 'wc-settings'
&& isset($_GET['tab']) && $_GET['tab'] == 'integration'
) {
add_action('admin_print_footer_scripts', array($this, 'show_blocks'), 99);
$this->form_fields[] = array(
'title' => __( 'API settings', 'retailcrm' ),
'type' => 'title',
@ -141,7 +151,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
$this->form_fields[] = array(
'title' => __( 'Catalog settings', 'retailcrm' ),
'type' => 'title',
'type' => 'heading',
'description' => '',
'id' => 'catalog_options'
);
@ -157,12 +167,6 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
);
}
if ($this->apiClient) {
if (isset($_GET['page']) && $_GET['page'] == 'wc-settings'
&& isset($_GET['tab']) && $_GET['tab'] == 'integration'
) {
add_action('admin_print_footer_scripts', array($this, 'show_blocks'), 99);
/**
* Client roles options
*/
@ -550,6 +554,18 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
'class' => 'debug_info_options'
);
}
} elseif (empty($apiUrl) === false && empty($apiKey) === false) {
$api = new WC_Retailcrm_Proxy(
$apiUrl,
$apiKey,
$this->get_option('corporate_enabled', 'no') === 'yes'
);
$response = $api->apiVersions();
if ($response->isSuccessful()) {
header("Refresh:0");
}
}
}