1
0
mirror of synced 2025-01-31 07:11:42 +03:00

Bug fix for php5.3, catalog options (#27)

* Bug fix for php5.3, catalog options
* Product price in order from cart
This commit is contained in:
Akolzin Dmitry 2017-11-24 16:04:28 +03:00 committed by Alex Lushpai
parent 59841e21e4
commit 9851b29f04
6 changed files with 87 additions and 40 deletions

View File

@ -295,9 +295,9 @@
*
* @return WC_Retailcrm_Response
*/
public function customDictionariesList(array $filter = [], $limit = null, $page = null)
public function customDictionariesList(array $filter = array(), $limit = null, $page = null)
{
$parameters = [];
$parameters = array();
if (count($filter)) {
$parameters['filter'] = $filter;

View File

@ -83,6 +83,24 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
'desc_tip' => true,
);
$this->form_fields[] = array(
'title' => __( 'Настройки каталога', 'woocommerce' ),
'type' => 'title',
'description' => '',
'id' => 'catalog_options'
);
foreach (get_post_statuses() as $status_key => $status_value) {
$this->form_fields['p_' . $status_key] = array(
'title' => __( $status_value, 'textdomain' ),
'label' => __( ' ', 'textdomain' ),
'description' => '',
'class' => 'checkbox',
'type' => 'checkbox',
'desc_tip' => true,
);
}
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(

View File

@ -74,7 +74,8 @@ if ( ! class_exists( 'WC_Retailcrm_Icml' ) ) :
unset($categories);
}
$this->get_wc_products_taxonomies();
$status_args = $this->checkPostStatuses();
$this->get_wc_products_taxonomies($status_args);
$dom = dom_import_simplexml(simplexml_load_file($this->tmpFile))->ownerDocument;
$dom->formatOutput = true;
$formatted = $dom->saveXML();
@ -310,13 +311,24 @@ if ( ! class_exists( 'WC_Retailcrm_Icml' ) ) :
*
* @return array
*/
private function get_wc_products_taxonomies() {
private function get_wc_products_taxonomies($status_args) {
if (!$status_args) {
$status_args = array('publish');
}
$full_product_list = array();
$offset = 0;
$limit = 100;
do {
$loop = new WP_Query(array('post_type' => array('product', 'product_variation'), 'posts_per_page' => $limit, 'offset' => $offset));
$loop = new WP_Query(
array(
'post_type' => array('product', 'product_variation'),
'post_status' => $status_args,
'posts_per_page' => $limit,
'offset' => $offset
)
);
while ($loop->have_posts()) : $loop->the_post();
$theid = get_the_ID();
@ -484,6 +496,19 @@ if ( ! class_exists( 'WC_Retailcrm_Icml' ) ) :
return wc_get_price_including_tax($product);
}
}
private function checkPostStatuses() {
$options = get_option( 'woocommerce_integration-retailcrm_settings' );
$status_args = array();
foreach (get_post_statuses() as $key => $value) {
if (isset($options['p_' . $key]) && $options['p_' . $key] == 'yes') {
$status_args[] = $key;
}
}
return $status_args;
}
}
endif;

View File

@ -247,7 +247,7 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) :
*/
public function getOrderData($order_id) {
$order = new WC_Order( $order_id );
$order_data_arr = [];
$order_data_arr = array();
if (version_compare(get_option('woocommerce_db_version'), '3.0', '<' )) {
$order_data_arr['id'] = $order->id;
@ -306,7 +306,7 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) :
$order_data['paymentType'] = $this->retailcrm_settings[$order_data_info['payment_method']];
}
if(!empty($order->get_items( 'shipping' )) && $order->get_items( 'shipping' ) != '') {
if ($order->get_items( 'shipping' )) {
$shipping = end($order->get_items( 'shipping' ));
$shipping_code = explode(':', $shipping['method_id']);
$shipping_method = $shipping_code[0];
@ -372,18 +372,22 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) :
$_product = wc_get_product($uid);
if ($_product) {
$product_price = $item->get_total() ? $item->get_total() / $item->get_quantity() : 0;
$product_tax = $item->get_total_tax() ? $item->get_total_tax() / $item->get_quantity() : 0;
$price_item = $product_price + $product_tax;
if ($this->retailcrm_settings['api_version'] != 'v3') {
$order_item = array(
'offer' => array('externalId' => $uid),
'productName' => $item['name'],
'initialPrice' => (float)$_product->get_price(),
'initialPrice' => (float)$price_item,
'quantity' => $item['qty'],
);
} else {
$order_item = array(
'productId' => $uid,
'productName' => $item['name'],
'initialPrice' => (float)$_product->get_price(),
'initialPrice' => (float)$price_item,
'quantity' => $item['qty'],
);
}

View File

@ -1,6 +1,6 @@
<?php
/**
* Version: 1.2.1
* Version: 1.2.3
* Plugin Name: WooCommerce RetailCRM
* Plugin URI: https://wordpress.org/plugins/woo-retailcrm/
* Description: Integration plugin for WooCommerce & RetailCRM

View File

@ -14,8 +14,8 @@
* - Repeat things for multisite. Once for a single site in the network, once sitewide.
*
*
* @link https://wordpress.org/plugins/retailcrm/
* @since 1.1
* @link https://wordpress.org/plugins/woo-retailcrm/
* @since 1.2.1
*
* @package RetailCRM
*/