1
0
Fork 0
mirror of synced 2025-04-06 07:13:33 +03:00

Add online consultant

This commit is contained in:
dima-uryvskiy 2020-05-27 11:32:48 +03:00
parent eef81f506b
commit 8f9862048c
5 changed files with 106 additions and 1 deletions

View file

@ -226,8 +226,21 @@ msgstr "Синхронизация остатков и связь товаров
msgid "Enable transferring the number to retailCRM"
msgstr "Активировать передачу номера в retailCRM"
msgid "Online Consultant"
msgstr "Онлайн консультант"
msgid "Enter consultant code"
msgstr "Введите код консультанта"
msgid "Enable this setting to activate online consultant"
msgstr "Активируйте эту настройку для активации Онлайн консультанта"
msgid "Activate Consultant"
msgstr "Активировать консультанта"
msgid "Transferring the order number"
msgstr "Передача номера заказа"
msgid "Transferring the payment amount"
msgstr "Передача суммы оплаты"

View file

@ -384,6 +384,28 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
'type' => 'input'
);
/**
* Online Consultant options
*/
$this->form_fields[] = array(
'title' => __('Online Consultant', 'retailcrm'),
'type' => 'heading',
'description' => ''
);
$this->form_fields["consultant_textarea"] = array(
'title' => __('Enter consultant code', 'retailcrm'),
'type' => 'textarea',
'description' => ''
);
$this->form_fields["consultant_checkbox"] = array(
'title' => __('Online Consultant', 'retailcrm'),
'label' => __('Activate Consultant', 'retailcrm'),
'type' => 'checkbox',
'description' => __('Enable this setting to activate online consultant', 'retailcrm')
);
/**
* Uploads options
*/

20
src/include/class-wc-retailcrm-base.php Normal file → Executable file
View file

@ -86,6 +86,7 @@ if (!class_exists('WC_Retailcrm_Base')) {
add_action('wp_print_scripts', array($this, 'initialize_analytics'), 98);
add_action('wp_print_scripts', array($this, 'initialize_daemon_collector'), 99);
add_action('wp_print_footer_scripts', array($this, 'send_analytics'), 99);
add_action('wp_print_footer_scripts', array($this, 'add_online_consultant'));
if (!$this->get_option('deactivate_update_order')
|| $this->get_option('deactivate_update_order') == static::NO
@ -245,7 +246,7 @@ if (!class_exists('WC_Retailcrm_Base')) {
$client = $this->getApiClient();
if (empty($client)) {
return;
return;
}
$wcCustomer = new WC_Customer($customer_id);
@ -396,5 +397,22 @@ if (!class_exists('WC_Retailcrm_Base')) {
}
}
}
/**
* Add online consultant
*/
public function add_online_consultant()
{
if (!class_exists('WC_Retailcrm_Online_Consultant')) {
include_once(static::checkCustomFile('online-consultant'));
}
if ($this->get_option('consultant_checkbox') == static::YES && $this->get_option('consultant_textarea')) {
$retailcrm_consultant = WC_Retailcrm_Online_Consultant::getInstance($this->settings);
echo $retailcrm_consultant->initialize_consultant();
} else {
echo '';
}
}
}
}

View file

@ -0,0 +1,52 @@
<?php
/**
* RetailCRM Integration.
*
* @package WC_Retailcrm_Online_Consultant
* @category Integration
* @author RetailCRM
*/
if (!class_exists('WC_Retailcrm_Online_Consultant')) {
/**
* WC_Retailcrm_Online_Consultant
*/
class WC_Retailcrm_Online_Consultant {
private static $instance;
private $options;
/**
* @param array $options
* Online_Consultant
* @return WC_Retailcrm_Online_Consultant
*/
public static function getInstance($options = array())
{
if (self::$instance === null) {
self::$instance = new self($options);
}
return self::$instance;
}
/**
* WC_Retailcrm_Online_Consultant constructor.
*
* @param array $options
*/
private function __construct($options = array())
{
$this->options = $options;
}
/**
* Initialize online consultant
* @return string
*/
public function initialize_consultant()
{
return apply_filters('retailcrm_initialize_consultant', "<script>{$this->options[consultant_textarea]}</script>");
}
}
}

Binary file not shown.