Setting payment amount transfer
This commit is contained in:
parent
f5adbfc367
commit
295d89490c
@ -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
|
||||
|
||||
|
5
Makefile
5
Makefile
@ -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
|
||||
|
@ -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`
|
||||
|
@ -10,7 +10,6 @@ services:
|
||||
user: ${UID:-1000}:${GID:-1000}
|
||||
depends_on:
|
||||
- mysql
|
||||
entrypoint: make local_test
|
||||
env_file:
|
||||
- ./.env
|
||||
environment:
|
||||
|
@ -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"
|
||||
|
@ -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 "Передача суммы оплаты"
|
||||
|
@ -144,6 +144,15 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
|
||||
'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',
|
||||
|
@ -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()
|
||||
);
|
||||
@ -51,9 +50,13 @@ class WC_Retailcrm_Order_Payment extends WC_Retailcrm_Abstracts_Data
|
||||
*/
|
||||
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;
|
||||
|
Binary file not shown.
Binary file not shown.
@ -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
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* @link https://wordpress.org/plugins/woo-retailcrm/
|
||||
* @version 3.5.4
|
||||
* @version 3.6.0
|
||||
*
|
||||
* @package RetailCRM
|
||||
*/
|
||||
|
@ -32,6 +32,25 @@ class WC_Retailcrm_Order_Payment_Test extends WC_Retailcrm_Test_Case_Helper
|
||||
|
||||
$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);
|
||||
|
@ -209,10 +209,15 @@ class WC_Retailcrm_Orders_Test extends WC_Retailcrm_Test_Case_Helper
|
||||
|
||||
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user