commit
5120740c83
@ -191,22 +191,59 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
'description' => 'Отметьте данный пункт, если хотите выгружать остатки товаров из CRM в магазин.'
|
'description' => 'Отметьте данный пункт, если хотите выгружать остатки товаров из CRM в магазин.'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->form_fields[] = array(
|
$options = array_filter(get_option( 'woocommerce_integration-ecomlogic_settings' ));
|
||||||
'title' => __( 'Настройки выгрузки', 'woocommerce' ),
|
|
||||||
'type' => 'title',
|
|
||||||
'description' => '',
|
|
||||||
'id' => 'upload_options'
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->form_fields['uploadToCrm'] = array(
|
if (!isset($options['uploads'])) {
|
||||||
'label' => __( 'Выгрузить все заказы и клиентов', 'textdomain' ),
|
$this->form_fields[] = array(
|
||||||
'title' => 'Выгрузка заказов и клиентов',
|
'title' => __( 'Выгрузка клиентов и заказов', 'woocommerce' ),
|
||||||
'class' => 'checkbox',
|
'type' => 'title',
|
||||||
'type' => 'checkbox',
|
'description' => '',
|
||||||
'description' => 'Поставьте галочку, и нажмите сохранить, чтобы выгрузить все существующие заказы и клиентов.'
|
'id' => 'upload_options'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->form_fields['upload-button'] = array(
|
||||||
|
'label' => 'Выгрузить',
|
||||||
|
'title' => __( 'Выгрузка клиентов и заказов', 'woocommerce-integration-ecomlogic' ),
|
||||||
|
'type' => 'button',
|
||||||
|
'description' => __( 'Пакетная выгрузка существующих клиентов и заказов.', 'woocommerce-integration-ecomlogic' ),
|
||||||
|
'desc_tip' => true,
|
||||||
|
'id' => 'uploads-ecomlogic'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function generate_button_html( $key, $data ) {
|
||||||
|
$field = $this->plugin_id . $this->id . '_' . $key;
|
||||||
|
$defaults = array(
|
||||||
|
'class' => 'button-secondary',
|
||||||
|
'css' => '',
|
||||||
|
'custom_attributes' => array(),
|
||||||
|
'desc_tip' => false,
|
||||||
|
'description' => '',
|
||||||
|
'title' => '',
|
||||||
|
);
|
||||||
|
|
||||||
|
$data = wp_parse_args( $data, $defaults );
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
?>
|
||||||
|
<tr valign="top">
|
||||||
|
<th scope="row" class="titledesc">
|
||||||
|
<label for="<?php echo esc_attr( $field ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
|
||||||
|
<?php echo $this->get_tooltip_html( $data ); ?>
|
||||||
|
</th>
|
||||||
|
<td class="forminp">
|
||||||
|
<fieldset>
|
||||||
|
<legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['label'] ); ?></span></legend>
|
||||||
|
<button id="<?php echo $data['id']; ?>" class="<?php echo esc_attr( $data['class'] ); ?>" type="button" name="<?php echo esc_attr( $field ); ?>" id="<?php echo esc_attr( $field ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" <?php echo $this->get_custom_attribute_html( $data ); ?>><?php echo wp_kses_post( $data['label'] ); ?></button>
|
||||||
|
<?php echo $this->get_description_html( $data ); ?>
|
||||||
|
</fieldset>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
return ob_get_clean();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
@ -294,32 +294,23 @@ function upload_to_crm() {
|
|||||||
|
|
||||||
$options = array_filter(get_option( 'woocommerce_integration-retailcrm_settings' ));
|
$options = array_filter(get_option( 'woocommerce_integration-retailcrm_settings' ));
|
||||||
|
|
||||||
if ($options['uploadToCrm'] == 'yes' && !isset($options['uploaded'])) {
|
$orders = new WC_Retailcrm_Orders();
|
||||||
$options['uploadToCrm'] = 'no';
|
$customers = new WC_Retailcrm_Customers();
|
||||||
$options['uploaded'] = 'yes';
|
$customers->customersUpload();
|
||||||
|
$orders->ordersUpload();
|
||||||
|
|
||||||
$orders = new WC_Retailcrm_Orders();
|
$options['uploads'] = 'yes';
|
||||||
$customers = new WC_Retailcrm_Customers();
|
update_option('woocommerce_integration-ecomlogic_settings', $options);
|
||||||
$customers->customersUpload();
|
|
||||||
$orders->ordersUpload();
|
|
||||||
|
|
||||||
update_option('woocommerce_integration-retailcrm_settings', $options);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($options['uploaded'])) {
|
|
||||||
$options['uploadToCrm'] = 'no';
|
|
||||||
update_option('woocommerce_integration-retailcrm_settings', $options);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajax_upload() {
|
function ajax_upload() {
|
||||||
$ajax_url = admin_url('admin-ajax.php');
|
$ajax_url = admin_url('admin-ajax.php');
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" >
|
<script type="text/javascript" >
|
||||||
jQuery(document).ready(function($) {
|
jQuery('#uploads-ecomlogic').bind('click', function() {
|
||||||
$.ajax({
|
jQuery.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "<?php echo $ajax_url; ?>?action=do_upload",
|
url: '<?php echo $ajax_url; ?>?action=do_upload',
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
console.log('AJAX response : ',response);
|
console.log('AJAX response : ',response);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user