1
0
mirror of synced 2025-01-18 17:01:41 +03:00

Send activate/deactivate information to crm

This commit is contained in:
Akolzin Dmitry 2018-09-05 11:13:32 +03:00
parent 7c6e55c60a
commit 83b668deb3
2 changed files with 20 additions and 5 deletions

View File

@ -940,6 +940,11 @@ if (!class_exists('WC_Retailcrm_Base')) {
);
}
/**
* Deactivate module in marketplace retailCRM
*
* @return void
*/
public function deactivate()
{
$api_client = $this->getApiClient();
@ -947,9 +952,18 @@ if (!class_exists('WC_Retailcrm_Base')) {
WC_Retailcrm_Plugin::integration_module($api_client, $clientId, false);
}
/**
* @param $settings
*
* @return void
*/
private function activate_integration($settings)
{
$clientId = get_option('retailcrm_client_id');
$client_id = get_option('retailcrm_client_id');
if (!$client_id) {
$client_id = hash('md5', date('Y-m-d H:i:s'));
}
if ($settings['api_url'] && $settings['api_key'] && $settings['api_version']) {
$api_client = new WC_Retailcrm_Proxy(
@ -958,10 +972,11 @@ if (!class_exists('WC_Retailcrm_Base')) {
$settings['api_version']
);
$result = WC_Retailcrm_Plugin::integration_module($api_client);
$result = WC_Retailcrm_Plugin::integration_module($api_client, $client_id);
if ($result) {
update_option('retailcrm_active_in_crm', true);
update_option('retailcrm_client_id', $client_id);
}
}
}

View File

@ -81,19 +81,19 @@ class WC_Retailcrm_Plugin {
* Edit configuration in CRM
*
* @param WC_Retailcrm_Proxy $api_client
* @param string $cliendId
* @param string $cliend_id
* @param bool $active
*
* @return boolean
*/
public static function integration_module($api_client, $cliendId, $active = true)
public static function integration_module($api_client, $cliend_id, $active = true)
{
if (!$api_client) {
return false;
}
$configuration = array(
'clientId' => $cliendId,
'clientId' => $cliend_id,
'code' => 'woocommerce',
'integrationCode' => 'woocommerce',
'active' => $active,