1
0
mirror of synced 2025-01-18 17:01:41 +03:00

Merge pull request #84 from sergeygw1990/master

v3.4.3
This commit is contained in:
Alex Lushpai 2019-02-25 12:01:38 +03:00 committed by GitHub
commit 90b4e5f608
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 93 additions and 15 deletions

View File

@ -1,3 +1,8 @@
## 2019-02-15 3.4.3
* Исправлено сохранение типа оплаты при создании заказа при обработке истории изменений на стороне WC
* Исправлено сохранение типа оплаты при изменении заказа при обработке истории изменений на стороне WC
* Исправлено подключение файлов методом checkCustomFile
## 2019-02-07 3.4.2
* Исправлено изменение типа оплаты на стороне WC
* Добавлен вывод неактивных типов оплаты в настройках

View File

@ -1 +1 @@
3.4.2
3.4.3

View File

@ -117,7 +117,7 @@ if (!class_exists('WC_Retailcrm_Base')) {
return WP_CONTENT_DIR . '/retailcrm-custom/class-wc-retailcrm-' . $file . '.php';
}
return 'class-wc-retailcrm-' . $file . '.php';
return WP_PLUGIN_DIR . '/woo-retailcrm/include/class-wc-retailcrm-' . $file . '.php';
}
public function generate_icml() {

View File

@ -375,7 +375,7 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) :
$payment_types = $payment->payment_gateways();
if (isset($payment_types[$options[$order['paymentType']]])) {
$order->set_payment_method($payment_types[$options[$order['paymentType']]]);
$wc_order->set_payment_method($payment_types[$options[$order['paymentType']]]);
}
}
}
@ -503,18 +503,17 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) :
$payment_types = $payment->payment_gateways();
$payments = $order['payments'];
$paymentType = end($payments);
if (isset($options[$paymentType['type']]) && isset($payment_types[$options[$paymentType['type']]])) {
$wc_order->set_payment_method($payment_types[$options[$paymentType['type']]]);
}
}
}
} else {
if (isset($order_record['paymentType']) && $order['paymentType']) {
if (isset($order['paymentType']) && $order['paymentType']) {
$payment = WC_Payment_Gateways::instance();
$payment_types = $payment->payment_gateways();
if (isset($options[$order_record['paymentType']]) && isset($payment_types[$options[$order_record['paymentType']]])) {
if (isset($options[$order['paymentType']]) && isset($payment_types[$options[$order['paymentType']]])) {
$wc_order->set_payment_method($payment_types[$options[$order['paymentType']]]);
}
}
@ -568,6 +567,8 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) :
'externalId' => (int) $wc_order->get_id()
);
$wc_order->save();
$this->retailcrm->ordersFixExternalIds($ids);
return $wc_order->get_id();
@ -580,8 +581,8 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) :
*/
public static function assemblyOrder($orderHistory)
{
if (file_exists(WP_CONTENT_DIR . '/plugins/woo-retailcrm/config/objects.xml')) {
$objects = simplexml_load_file(WP_CONTENT_DIR . '/plugins/woo-retailcrm/config/objects.xml');
if (file_exists(__DIR__ . '/../config/objects.xml')) {
$objects = simplexml_load_file(__DIR__ . '/../config/objects.xml');
foreach($objects->fields->field as $object) {
$fields[(string)$object["group"]][(string)$object["id"]] = (string)$object;
}

View File

@ -45,6 +45,10 @@ API-ключ должен быть для отдельного магазина
2. В появившихся списках справочников настройте соответствие способов доставки и оплаты, а так же статусов заказов. Отметьте галочку "Выгружать остатки", если хотите выгружать остатки из Retailcrm в магазин (подробнее смотрите в описании).
== Changelog ==
= 3.4.3 =
* Исправлено сохранение типа оплаты при создании заказа по истории на стороне WC
* Исправлено сохранение типа оплаты при ризменении заказа по истории на стороне WC
= 3.4.2 =
* Исправлено изменение типа оплаты на стороне WC
* Добавлен вывод неактивных типов оплаты в настройках

View File

@ -1,6 +1,6 @@
<?php
/**
* Version: 3.4.1
* Version: 3.4.3
* WC requires at least: 3.0
* WC tested up to: 3.4.3
* Plugin Name: WooCommerce RetailCRM

View File

@ -15,7 +15,7 @@
*
*
* @link https://wordpress.org/plugins/woo-retailcrm/
* @version 3.4.1
* @version 3.4.3
*
* @package RetailCRM
*/

View File

@ -66,12 +66,13 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
$retailcrm_history = new \WC_Retailcrm_History($this->apiMock);
$retailcrm_history->getHistory();
$orders = wc_get_orders(array('numberposts' => 10));
$orders = wc_get_orders(array('numberposts' => -1));
$order_added = end($orders);
$order_added_items = $order_added->get_items();
$order_added_item = reset($order_added_items);
$shipping_address = $order_added->get_address('shipping');
$billing_address = $order_added->get_address('billing');
$options = get_option(\WC_Retailcrm_Base::$option_key);
$this->assertEquals(self::STATUS_1, $options[$order_added->get_status()]);
@ -90,6 +91,7 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
$this->assertNotEmpty($billing_address['city']);
$this->assertNotEmpty($billing_address['country']);
$this->assertNotEmpty($billing_address['state']);
$this->assertEquals('payment4', $options[$order_added->get_payment_method()]);
}
/**
@ -136,7 +138,7 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
* @dataProvider dataProvider
* @param $api_version
*/
public function test_history_order_update_status($api_version)
public function test_history_order_update($api_version)
{
$this->setOptions($api_version);
@ -153,7 +155,7 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
$order = WC_Helper_Order::create_order(0);
$this->ordersHistoryResponse->setResponse(
$this->get_history_data_status_update($order->get_id())
$this->get_history_data_update($order->get_id(), $api_version)
);
$this->apiMock->expects($this->any())->method('customersHistory')->willReturn($this->customersHistoryResponse);
@ -166,6 +168,7 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
$options = get_option(\WC_Retailcrm_Base::$option_key);
$this->assertEquals(self::STATUS_2, $options[$order_updated->get_status()]);
$this->assertEquals('payment2', $options[$order_updated->get_payment_method()]);
}
public function dataProvider()
@ -289,6 +292,14 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
'purchasePrice' => 50
)
),
'paymentType' => 'payment4',
'payments' => array(
array(
'id'=> 1,
'type'=> 'payment4',
'amount'=> 100,
)
),
'fromApi' => false,
'length' => 0,
'width' => 0,
@ -351,9 +362,9 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
);
}
private function get_history_data_status_update($order_id)
private function get_history_data_update($order_id, $api_version)
{
return array(
$history = array(
'success' => true,
'history' => array(
array(
@ -380,5 +391,62 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
)
)
);
$payment_v5 = array(
'id' => 4,
'createdAt' => '2018-01-01 00:03:00',
'source' => 'user',
'user' => array(
'id' => 1
),
'field' => 'payments',
'oldValue' => null,
'newValue' => array(
'code' => 'payment2'
),
'order' => array(
'id' => 2,
'externalId' => $order_id,
'managerId' => 6,
'site' => 'test-com',
'status' => self::STATUS_2
),
'payment' => array(
'id' => 1,
'type' => 'payment2',
"amount" => 100
)
);
$payment_v4 = array(
'id' => 4,
'createdAt' => '2018-01-01 00:03:00',
'source' => 'user',
'user' => array(
'id' => 1
),
'field' => 'payment_type',
'oldValue' => null,
'newValue' => array(
'code' => 'payment2'
),
'order' => array(
'id' => 2,
'externalId' => $order_id,
'managerId' => 6,
'site' => 'test-com',
'status' => self::STATUS_2
),
);
if ($api_version == 'v4') {
array_push($history['history'], $payment_v4);
}
if ($api_version == 'v5') {
array_push($history['history'], $payment_v5);
}
return $history;
}
}