Fix api request (#15)
This commit is contained in:
parent
3ce1885da0
commit
88f502a878
@ -84,161 +84,162 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($this->get_option( 'api_url' ) != '' && $this->get_option( 'api_key' ) != '') {
|
if ($this->get_option( 'api_url' ) != '' && $this->get_option( 'api_key' ) != '') {
|
||||||
|
if (isset($_GET['page']) && $_GET['page'] == 'wc-settings' && isset($_GET['tab']) && $_GET['tab'] == 'integration') {
|
||||||
$retailcrm = new WC_Retailcrm_Proxy(
|
$retailcrm = new WC_Retailcrm_Proxy(
|
||||||
$this->get_option( 'api_url' ),
|
$this->get_option( 'api_url' ),
|
||||||
$this->get_option( 'api_key' ),
|
$this->get_option( 'api_key' ),
|
||||||
$this->get_option( 'api_version')
|
$this->get_option( 'api_version')
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shipping options
|
|
||||||
*/
|
|
||||||
$shipping_option_list = array();
|
|
||||||
$retailcrm_shipping_list = $retailcrm->deliveryTypesList();
|
|
||||||
|
|
||||||
if ($retailcrm_shipping_list->isSuccessful()) {
|
|
||||||
foreach ($retailcrm_shipping_list['deliveryTypes'] as $retailcrm_shipping_type) {
|
|
||||||
$shipping_option_list[$retailcrm_shipping_type['code']] = $retailcrm_shipping_type['name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$wc_shipping = new WC_Shipping();
|
|
||||||
$wc_shipping_list = $wc_shipping->get_shipping_methods();
|
|
||||||
|
|
||||||
$this->form_fields[] = array(
|
|
||||||
'title' => __( 'Способы доставки', 'woocommerce' ),
|
|
||||||
'type' => 'title',
|
|
||||||
'description' => '',
|
|
||||||
'id' => 'shipping_options'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ( $wc_shipping_list as $shipping ) {
|
/**
|
||||||
if ( isset( $shipping->enabled ) && $shipping->enabled == 'yes' ) {
|
* Shipping options
|
||||||
$key = $shipping->id;
|
*/
|
||||||
$name = $key;
|
$shipping_option_list = array();
|
||||||
$this->form_fields[$name] = array(
|
$retailcrm_shipping_list = $retailcrm->deliveryTypesList();
|
||||||
'title' => __( $shipping->method_title, 'textdomain' ),
|
|
||||||
'description' => __( $shipping->method_description, 'textdomain' ),
|
if ($retailcrm_shipping_list->isSuccessful()) {
|
||||||
|
foreach ($retailcrm_shipping_list['deliveryTypes'] as $retailcrm_shipping_type) {
|
||||||
|
$shipping_option_list[$retailcrm_shipping_type['code']] = $retailcrm_shipping_type['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$wc_shipping = new WC_Shipping();
|
||||||
|
$wc_shipping_list = $wc_shipping->get_shipping_methods();
|
||||||
|
|
||||||
|
$this->form_fields[] = array(
|
||||||
|
'title' => __( 'Способы доставки', 'woocommerce' ),
|
||||||
|
'type' => 'title',
|
||||||
|
'description' => '',
|
||||||
|
'id' => 'shipping_options'
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ( $wc_shipping_list as $shipping ) {
|
||||||
|
if ( isset( $shipping->enabled ) && $shipping->enabled == 'yes' ) {
|
||||||
|
$key = $shipping->id;
|
||||||
|
$name = $key;
|
||||||
|
$this->form_fields[$name] = array(
|
||||||
|
'title' => __( $shipping->method_title, 'textdomain' ),
|
||||||
|
'description' => __( $shipping->method_description, 'textdomain' ),
|
||||||
|
'css' => 'min-width:350px;',
|
||||||
|
'class' => 'select',
|
||||||
|
'type' => 'select',
|
||||||
|
'options' => $shipping_option_list,
|
||||||
|
'desc_tip' => true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Payment options
|
||||||
|
*/
|
||||||
|
$payment_option_list = array();
|
||||||
|
$retailcrm_payment_list = $retailcrm->paymentTypesList();
|
||||||
|
|
||||||
|
if ($retailcrm_payment_list->isSuccessful()) {
|
||||||
|
foreach ($retailcrm_payment_list['paymentTypes'] as $retailcrm_payment_type) {
|
||||||
|
$payment_option_list[$retailcrm_payment_type['code']] = $retailcrm_payment_type['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$wc_payment = new WC_Payment_Gateways();
|
||||||
|
|
||||||
|
$this->form_fields[] = array(
|
||||||
|
'title' => __( 'Способы оплаты', 'woocommerce' ),
|
||||||
|
'type' => 'title',
|
||||||
|
'description' => '',
|
||||||
|
'id' => 'payment_options'
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ( $wc_payment->payment_gateways as $payment ) {
|
||||||
|
if ( isset( $payment->enabled ) && $payment->enabled == 'yes' ) {
|
||||||
|
$key = $payment->id;
|
||||||
|
$name = $key;
|
||||||
|
$this->form_fields[$name] = array(
|
||||||
|
'title' => __( $payment->method_title, 'textdomain' ),
|
||||||
|
'description' => __( $payment->method_description, 'textdomain' ),
|
||||||
|
'css' => 'min-width:350px;',
|
||||||
|
'class' => 'select',
|
||||||
|
'type' => 'select',
|
||||||
|
'options' => $payment_option_list,
|
||||||
|
'desc_tip' => true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Statuses options
|
||||||
|
*/
|
||||||
|
$statuses_option_list = array();
|
||||||
|
$retailcrm_statuses_list = $retailcrm->statusesList();
|
||||||
|
|
||||||
|
if ($retailcrm_statuses_list->isSuccessful()) {
|
||||||
|
foreach ($retailcrm_statuses_list['statuses'] as $retailcrm_status) {
|
||||||
|
$statuses_option_list[$retailcrm_status['code']] = $retailcrm_status['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$wc_statuses = wc_get_order_statuses();
|
||||||
|
|
||||||
|
$this->form_fields[] = array(
|
||||||
|
'title' => __( 'Статусы', 'woocommerce' ),
|
||||||
|
'type' => 'title',
|
||||||
|
'description' => '',
|
||||||
|
'id' => 'statuses_options'
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ( $wc_statuses as $idx => $name ) {
|
||||||
|
$uid = str_replace('wc-', '', $idx);
|
||||||
|
$this->form_fields[$uid] = array(
|
||||||
|
'title' => __( $name, 'textdomain' ),
|
||||||
'css' => 'min-width:350px;',
|
'css' => 'min-width:350px;',
|
||||||
'class' => 'select',
|
'class' => 'select',
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'options' => $shipping_option_list,
|
'options' => $statuses_option_list,
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Payment options
|
|
||||||
*/
|
|
||||||
$payment_option_list = array();
|
|
||||||
$retailcrm_payment_list = $retailcrm->paymentTypesList();
|
|
||||||
|
|
||||||
if ($retailcrm_payment_list->isSuccessful()) {
|
|
||||||
foreach ($retailcrm_payment_list['paymentTypes'] as $retailcrm_payment_type) {
|
|
||||||
$payment_option_list[$retailcrm_payment_type['code']] = $retailcrm_payment_type['name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$wc_payment = new WC_Payment_Gateways();
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inventories options
|
||||||
|
*/
|
||||||
$this->form_fields[] = array(
|
$this->form_fields[] = array(
|
||||||
'title' => __( 'Способы оплаты', 'woocommerce' ),
|
'title' => __( 'Настройки остатков', 'woocommerce' ),
|
||||||
'type' => 'title',
|
'type' => 'title',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'id' => 'payment_options'
|
'id' => 'invent_options'
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ( $wc_payment->payment_gateways as $payment ) {
|
$this->form_fields['sync'] = array(
|
||||||
if ( isset( $payment->enabled ) && $payment->enabled == 'yes' ) {
|
'label' => __( 'Выгружать остатки из CRM', 'textdomain' ),
|
||||||
$key = $payment->id;
|
'title' => 'Inventories',
|
||||||
$name = $key;
|
'class' => 'checkbox',
|
||||||
$this->form_fields[$name] = array(
|
'type' => 'checkbox',
|
||||||
'title' => __( $payment->method_title, 'textdomain' ),
|
'description' => 'Отметьте данный пункт, если хотите выгружать остатки товаров из CRM в магазин.'
|
||||||
'description' => __( $payment->method_description, 'textdomain' ),
|
|
||||||
'css' => 'min-width:350px;',
|
|
||||||
'class' => 'select',
|
|
||||||
'type' => 'select',
|
|
||||||
'options' => $payment_option_list,
|
|
||||||
'desc_tip' => true,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Statuses options
|
|
||||||
*/
|
|
||||||
$statuses_option_list = array();
|
|
||||||
$retailcrm_statuses_list = $retailcrm->statusesList();
|
|
||||||
|
|
||||||
if ($retailcrm_statuses_list->isSuccessful()) {
|
|
||||||
foreach ($retailcrm_statuses_list['statuses'] as $retailcrm_status) {
|
|
||||||
$statuses_option_list[$retailcrm_status['code']] = $retailcrm_status['name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$wc_statuses = wc_get_order_statuses();
|
|
||||||
|
|
||||||
$this->form_fields[] = array(
|
|
||||||
'title' => __( 'Статусы', 'woocommerce' ),
|
|
||||||
'type' => 'title',
|
|
||||||
'description' => '',
|
|
||||||
'id' => 'statuses_options'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ( $wc_statuses as $idx => $name ) {
|
/**
|
||||||
$uid = str_replace('wc-', '', $idx);
|
* Uploads options
|
||||||
$this->form_fields[$uid] = array(
|
*/
|
||||||
'title' => __( $name, 'textdomain' ),
|
$options = array_filter(get_option( 'woocommerce_integration-retailcrm_settings' ));
|
||||||
'css' => 'min-width:350px;',
|
|
||||||
'class' => 'select',
|
if (!isset($options['uploads'])) {
|
||||||
'type' => 'select',
|
$this->form_fields[] = array(
|
||||||
'options' => $statuses_option_list,
|
'title' => __( 'Выгрузка клиентов и заказов', 'woocommerce' ),
|
||||||
'desc_tip' => true,
|
'type' => 'title',
|
||||||
|
'description' => '',
|
||||||
|
'id' => 'upload_options'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->form_fields['upload-button'] = array(
|
||||||
|
'label' => 'Выгрузить',
|
||||||
|
'title' => __( 'Выгрузка клиентов и заказов', 'woocommerce-integration-retailcrm' ),
|
||||||
|
'type' => 'button',
|
||||||
|
'description' => __( 'Пакетная выгрузка существующих клиентов и заказов.', 'woocommerce-integration-retailcrm' ),
|
||||||
|
'desc_tip' => true,
|
||||||
|
'id' => 'uploads-retailcrm'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Inventories options
|
|
||||||
*/
|
|
||||||
$this->form_fields[] = array(
|
|
||||||
'title' => __( 'Настройки остатков', 'woocommerce' ),
|
|
||||||
'type' => 'title',
|
|
||||||
'description' => '',
|
|
||||||
'id' => 'invent_options'
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->form_fields['sync'] = array(
|
|
||||||
'label' => __( 'Выгружать остатки из CRM', 'textdomain' ),
|
|
||||||
'title' => 'Inventories',
|
|
||||||
'class' => 'checkbox',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'description' => 'Отметьте данный пункт, если хотите выгружать остатки товаров из CRM в магазин.'
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Uploads options
|
|
||||||
*/
|
|
||||||
$options = array_filter(get_option( 'woocommerce_integration-retailcrm_settings' ));
|
|
||||||
|
|
||||||
if (!isset($options['uploads'])) {
|
|
||||||
$this->form_fields[] = array(
|
|
||||||
'title' => __( 'Выгрузка клиентов и заказов', 'woocommerce' ),
|
|
||||||
'type' => 'title',
|
|
||||||
'description' => '',
|
|
||||||
'id' => 'upload_options'
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->form_fields['upload-button'] = array(
|
|
||||||
'label' => 'Выгрузить',
|
|
||||||
'title' => __( 'Выгрузка клиентов и заказов', 'woocommerce-integration-retailcrm' ),
|
|
||||||
'type' => 'button',
|
|
||||||
'description' => __( 'Пакетная выгрузка существующих клиентов и заказов.', 'woocommerce-integration-retailcrm' ),
|
|
||||||
'desc_tip' => true,
|
|
||||||
'id' => 'uploads-retailcrm'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,7 +368,9 @@ if ( ! class_exists( 'WC_Retailcrm_Icml' ) ) :
|
|||||||
|
|
||||||
if (!empty($attributes)) {
|
if (!empty($attributes)) {
|
||||||
foreach ($attributes as $attribute_name => $attribute) {
|
foreach ($attributes as $attribute_name => $attribute) {
|
||||||
$attributeValue = end(get_post_meta($product->get_id(), 'attribute_'.$attribute_name));
|
$id_product = $product->get_id();
|
||||||
|
$arrAttributeValue = get_post_meta($id_product, 'attribute_'.$attribute_name);
|
||||||
|
$attributeValue = end($arrAttributeValue);
|
||||||
if ($attribute['is_visible'] == 1 && !empty($attribute['value'])) {
|
if ($attribute['is_visible'] == 1 && !empty($attribute['value'])) {
|
||||||
$params[] = array(
|
$params[] = array(
|
||||||
'code' => $attribute_name,
|
'code' => $attribute_name,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user