Skip to content

Commit

Permalink
Since id, order methods in history, fix icml generate for php 7.2 (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
iyzoer authored and gwinn committed Feb 19, 2018
1 parent 83cab09 commit b77381c
Show file tree
Hide file tree
Showing 7 changed files with 324 additions and 98 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## 2018-02-19 v.2.0.6
* Исправлено возникновение Warning на PHP 7.2 при генерации каталога товаров
* Добавлена настройка выгрузки заказов из RetailCRM с определенными способами оформления
* Выгрузка изменений из RetailCRM осуществляется по sinceId

## 2018-02-02 v.2.0.5
* Исправлен неверный подсчет скидки на товары
133 changes: 127 additions & 6 deletions woo-retailcrm/include/class-wc-retailcrm-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,47 @@ public function init_form_fields() {

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') {
add_action('admin_print_footer_scripts', array($this, 'show_blocks'), 99);

$retailcrm = new WC_Retailcrm_Proxy(
$this->get_option( 'api_url' ),
$this->get_option( 'api_key' ),
$this->get_option( 'api_version')
);

/**
* Order methods options
*/
$order_methods_option = array();
$order_methods_list = $retailcrm->orderMethodsList();

if ($order_methods_list->isSuccessful()) {
foreach ($order_methods_list['orderMethods'] as $order_method) {
if ($order_method['active'] == false) {
continue;
}

$order_methods_option[$order_method['code']] = $order_method['name'];
}

$this->form_fields[] = array(
'title' => __( 'Способы оформления заказа', 'woocommerce' ),
'type' => 'heading',
'description' => '',
'id' => 'order_methods_options'
);

$this->form_fields['order_methods'] = array(
'label' => __( ' ', 'textdomain' ),
'title' => 'Способы оформления заказа, доступные для выгрузки из RetailCRM',
'class' => '',
'type' => 'multiselect',
'description' => 'Выберите способы оформления для заказов, которые будут выгружаться из RetailCRM на сайт',
'options' => $order_methods_option,
'select_buttons' => true
);
}

/**
* Shipping options
*/
Expand All @@ -124,7 +159,7 @@ public function init_form_fields() {

$this->form_fields[] = array(
'title' => __( 'Способы доставки', 'woocommerce' ),
'type' => 'title',
'type' => 'heading',
'description' => '',
'id' => 'shipping_options'
);
Expand Down Expand Up @@ -159,7 +194,7 @@ public function init_form_fields() {

$this->form_fields[] = array(
'title' => __( 'Способы оплаты', 'woocommerce' ),
'type' => 'title',
'type' => 'heading',
'description' => '',
'id' => 'payment_options'
);
Expand Down Expand Up @@ -196,7 +231,7 @@ public function init_form_fields() {

$this->form_fields[] = array(
'title' => __( 'Статусы', 'woocommerce' ),
'type' => 'title',
'type' => 'heading',
'description' => '',
'id' => 'statuses_options'
);
Expand All @@ -219,7 +254,7 @@ public function init_form_fields() {
*/
$this->form_fields[] = array(
'title' => __( 'Настройки выгрузки остатков', 'woocommerce' ),
'type' => 'title',
'type' => 'heading',
'description' => '',
'id' => 'invent_options'
);
Expand All @@ -240,7 +275,7 @@ public function init_form_fields() {
if (!isset($options['uploads'])) {
$this->form_fields[] = array(
'title' => __( 'Выгрузка клиентов и заказов', 'woocommerce' ),
'type' => 'title',
'type' => 'heading',
'description' => '',
'id' => 'upload_options'
);
Expand Down Expand Up @@ -277,6 +312,14 @@ public function init_form_fields() {
}
}

/**
* Generate html button
*
* @param string $key
* @param array $data
*
* @return string
*/
public function generate_button_html( $key, $data ) {
$field = $this->plugin_id . $this->id . '_' . $key;
$defaults = array(
Expand Down Expand Up @@ -309,6 +352,44 @@ public function generate_button_html( $key, $data ) {
return ob_get_clean();
}

/**
* Generate html title block settings
*
* @param string $key
* @param array $data
*
* @return string
*/
public function generate_heading_html($key, $data) {
$field_key = $this->get_field_key( $key );
$defaults = array(
'title' => '',
'class' => '',
);

$data = wp_parse_args( $data, $defaults );

ob_start();
?>
</table>
<h2 class="wc-settings-sub-title retailcrm_hidden <?php echo esc_attr( $data['class'] ); ?>" id="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <span style="opacity:0.5;float: right;">&#11015;</span></h2>
<?php if ( ! empty( $data['description'] ) ) : ?>
<p><?php echo wp_kses_post( $data['description'] ); ?></p>
<?php endif; ?>
<table class="form-table" style="display: none;">
<?php

return ob_get_clean();
}

/**
* Validate API version
*
* @param string $key
* @param string $value
*
* @return string
*/
public function validate_api_version_field( $key, $value ) {
$post = $this->get_post_data();

Expand All @@ -334,6 +415,14 @@ public function validate_api_version_field( $key, $value ) {
}
}

/**
* Validate API url
*
* @param string $key
* @param string $value
*
* @return string
*/
public function validate_api_url_field( $key, $value ) {
$post = $this->get_post_data();
$api = new WC_Retailcrm_Proxy(
Expand All @@ -350,7 +439,15 @@ public function validate_api_url_field( $key, $value ) {

return $value;
}


/**
* Validate API key
*
* @param string $key
* @param string $value
*
* @return string
*/
public function validate_api_key_field( $key, $value ) {
$post = $this->get_post_data();
$api = new WC_Retailcrm_Proxy(
Expand All @@ -371,6 +468,30 @@ public function validate_api_key_field( $key, $value ) {

return $value;
}

/**
* Scritp show|hide block settings
*/
function show_blocks() {
?>
<script type="text/javascript">
jQuery('h2.retailcrm_hidden').hover().css({
'cursor':'pointer',
'width':'300px'
});
jQuery('h2.retailcrm_hidden').toggle(
function() {
jQuery(this).next('table.form-table').show(100);
jQuery(this).find('span').html('&#11014;');
},
function() {
jQuery(this).next('table.form-table').hide(100);
jQuery(this).find('span').html('&#11015;');
}
);
</script>
<?php
}
}

endif;
Loading

0 comments on commit b77381c

Please sign in to comment.