Closes #201. Remove payments with empty payment type (#208)

This commit is contained in:
Akolzin Dmitry 2020-12-03 12:07:20 +03:00 committed by GitHub
parent 75fc11c6f9
commit 29bdecfc96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View File

@ -120,7 +120,9 @@ class RetailcrmOrderConverter {
); );
} }
$this->data['payments'][] = $payment; if (!empty($payment['type'])) {
$this->data['payments'][] = $payment;
}
return $this; return $this;
} }

View File

@ -72,6 +72,35 @@ class RetailcrmOrderConverterTest extends TestCase {
$this->assertEquals('cod', $order['payments'][0]['type']); $this->assertEquals('cod', $order['payments'][0]['type']);
} }
public function testSetEmptyPayment() {
$order_checkout_model = $this->loadModel('checkout/order');
$order_account_model = $this->loadModel('account/order');
$order_data = $order_checkout_model->getOrder(static::ORDER_WITH_CUST_ID);
$products = $order_account_model->getOrderProducts(static::ORDER_WITH_CUST_ID);
$totals = $order_account_model->getOrderTotals(static::ORDER_WITH_CUST_ID);
foreach ($products as $key => $product) {
$productOptions = $order_account_model->getOrderOptions(static::ORDER_WITH_CUST_ID, $product['order_product_id']);
if (!empty($productOptions)) {
$products[$key]['option'] = $productOptions;
}
}
$converter = \retailcrm\factory\OrderConverterFactory::create(static::$registry);
unset($order_data['payment_code']);
$order = $converter->initOrderData(
$order_data,
$products,
$totals
)->setPayment()->getOrder();
$this->assertArrayNotHasKey('payments', $order);
}
public function testSetDelivery() { public function testSetDelivery() {
$order_checkout_model = $this->loadModel('checkout/order'); $order_checkout_model = $this->loadModel('checkout/order');
$order_account_model = $this->loadModel('account/order'); $order_account_model = $this->loadModel('account/order');