Skip to content

Commit

Permalink
Merge pull request #124 from iyzoer/master
Browse files Browse the repository at this point in the history
Setting payment amount transfer
  • Loading branch information
gwinn authored Mar 25, 2020
2 parents f5adbfc + 3475f36 commit 8897973
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 14 deletions.
1 change: 1 addition & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RUN apt-get install -y zlib1g-dev libpq-dev git libicu-dev libxml2-dev libpng-de
&& docker-php-ext-install xsl \
&& docker-php-ext-install mbstring

RUN apt-get install -y gettext
RUN apt-get install -y subversion
RUN apt-get install -y wget

Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ endif

local_test: install
phpunit -c phpunit.xml.dist

run_tests:
docker-compose --no-ansi up -d --build mysql
docker-compose --no-ansi run --rm --no-deps app make local_test
docker-compose stop
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ Integration plugin for WooCommerce and [retailCRM](http://retailcrm.ru)

#### Local testing

To local testing run `docker-compose up`
To local testing run `make run_tests`
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.5.6
3.6.0
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ services:
user: ${UID:-1000}:${GID:-1000}
depends_on:
- mysql
entrypoint: make local_test
env_file:
- ./.env
environment:
Expand Down
5 changes: 4 additions & 1 deletion resources/pot/retailcrm-es_ES.pot
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,7 @@ msgid "Enable transferring the number to retailCRM"
msgstr "Activar la transferencia de números en retailCRM"

msgid "Transferring the order number"
msgstr "Transferencia de un número de pedido"
msgstr "Transferencia de un número de pedido"

msgid "Transferring the payment amount"
msgstr "Transferencia de un monto de pago"
5 changes: 4 additions & 1 deletion resources/pot/retailcrm-ru_RU.pot
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,7 @@ msgid "Enable transferring the number to retailCRM"
msgstr "Активировать передачу номера в retailCRM"

msgid "Transferring the order number"
msgstr "Передача номера заказа"
msgstr "Передача номера заказа"

msgid "Transferring the payment amount"
msgstr "Передача суммы оплаты"
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ public function init_form_fields()
'desc_tip' => true,
);

$this->form_fields['send_payment_amount'] = array(
'title' => __( 'Transferring the payment amount', 'retailcrm' ),
'label' => ' ',
'description' => '',
'class' => 'checkbox',
'type' => 'checkbox',
'desc_tip' => true,
);

$this->form_fields[] = array(
'title' => __( 'Catalog settings', 'retailcrm' ),
'type' => 'title',
Expand Down
11 changes: 7 additions & 4 deletions src/include/order/class-wc-retailcrm-order-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class WC_Retailcrm_Order_Payment extends WC_Retailcrm_Abstracts_Data
/** @var array */
protected $data = array(
'externalId' => '',
'amount' => 0.00,
'type' => '',
'order' => array()
);
Expand Down Expand Up @@ -51,9 +50,13 @@ public function __construct($settings)
*/
public function build($order, $externalId = false)
{
$data = array(
'amount' => (double) $order->get_total()
);
$data = array();

if (!empty($this->settings['send_payment_amount'])
&& $this->settings['send_payment_amount'] === WC_Retailcrm_Base::YES
) {
$data['amount'] = (double) $order->get_total();
}

if (!$this->is_new) {
$data['externalId'] = $externalId;
Expand Down
Binary file modified src/languages/retailcrm-es_ES.mo
Binary file not shown.
Binary file modified src/languages/retailcrm-ru_RU.mo
Binary file not shown.
10 changes: 8 additions & 2 deletions src/readme.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
=== Woocommerce RetailCRM ===
=== Woocommerce retailCRM ===
Contributors: retailCRM
Donate link: http://retailcrm.ru/
Tags: Интеграция, Retailcrm
Tags: Интеграция, retailCRM
Requires PHP: 5.3
Requires at least: 4.4
Tested up to: 5.3
Expand Down Expand Up @@ -46,6 +46,9 @@ API-ключ должен быть для отдельного магазина

== Changelog ==

= 3.6.0 =
* Добавлена настройка передачи суммы оплаты в retailCRM

= 3.5.2 =
* Исправлен баг с выгрузкой заказов в retailCRM

Expand Down Expand Up @@ -192,6 +195,9 @@ API-ключ должен быть для отдельного магазина
* Исправелены ошибки.

== Upgrade Notice ==
= 3.6.0 =
Добавлена возможность отключить передачу суммы оплаты в retailCRM, тогда сумма будет рассчитываться в retailCRM

= 3.4.2 =
Исправлено изменение типа оплаты на стороне WC
Добавлен вывод неактивных типов оплаты в настройках
Expand Down
2 changes: 1 addition & 1 deletion src/retailcrm.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Version: 3.5.4
* Version: 3.6.0
* WC requires at least: 3.0
* WC tested up to: 3.9.3
* Plugin Name: WooCommerce RetailCRM
Expand Down
2 changes: 1 addition & 1 deletion src/uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*
* @link https://wordpress.org/plugins/woo-retailcrm/
* @version 3.5.4
* @version 3.6.0
*
* @package RetailCRM
*/
Expand Down
19 changes: 19 additions & 0 deletions tests/order/test-wc-retailcrm-order-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ public function test_build($externalId)

$data = $order_payment->build($this->order, $externalId)->get_data();

$this->assertArrayHasKey('externalId', $data);
$this->assertArrayHasKey('type', $data);
$this->assertArrayNotHasKey('amount', $data);
$this->assertArrayHasKey('order', $data);
}

/**
* @param mixed $externalId
*
* @dataProvider dataProvider
*/
public function test_build_with_amount($externalId)
{
$settings = $this->getOptions();
$settings['send_payment_amount'] = 'yes';
$order_payment = new WC_Retailcrm_Order_Payment($settings);

$data = $order_payment->build($this->order, $externalId)->get_data();

$this->assertArrayHasKey('externalId', $data);
$this->assertArrayHasKey('type', $data);
$this->assertArrayHasKey('amount', $data);
Expand Down
7 changes: 6 additions & 1 deletion tests/test-wc-retailcrm-orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,15 @@ public function test_update_order($isSuccessful, $retailcrm, $apiVersion)

if (!empty($payment)) {
$this->assertArrayHasKey('type', $payment);
$this->assertArrayHasKey('amount', $payment);
$this->assertArrayHasKey('order', $payment);
$this->assertArrayHasKey('externalId', $payment);
$this->assertEquals('payment1', $payment['type']);

if (!empty($this->options['send_payment_amount']) && $this->options['send_payment_amount'] == 'yes') {
$this->assertArrayHasKey('amount', $payment);
} else {
$this->assertArrayNotHasKey('amount', $payment);
}
}
}
} else {
Expand Down

0 comments on commit 8897973

Please sign in to comment.