parent
ef796ebd75
commit
61ae452aec
@ -183,7 +183,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
|
||||
$order_methods_option = array();
|
||||
$order_methods_list = $this->apiClient->orderMethodsList();
|
||||
|
||||
if ($order_methods_list->isSuccessful()) {
|
||||
if (!empty($order_methods_list) && $order_methods_list->isSuccessful()) {
|
||||
foreach ($order_methods_list['orderMethods'] as $order_method) {
|
||||
if ($order_method['active'] == false) {
|
||||
continue;
|
||||
@ -217,7 +217,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
|
||||
$shipping_option_list = array();
|
||||
$retailcrm_shipping_list = $this->apiClient->deliveryTypesList();
|
||||
|
||||
if ($retailcrm_shipping_list->isSuccessful()) {
|
||||
if (!empty($retailcrm_shipping_list) && $retailcrm_shipping_list->isSuccessful()) {
|
||||
foreach ($retailcrm_shipping_list['deliveryTypes'] as $retailcrm_shipping_type) {
|
||||
$shipping_option_list[$retailcrm_shipping_type['code']] = $retailcrm_shipping_type['name'];
|
||||
}
|
||||
@ -252,7 +252,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
|
||||
$payment_option_list = array();
|
||||
$retailcrm_payment_list = $this->apiClient->paymentTypesList();
|
||||
|
||||
if ($retailcrm_payment_list->isSuccessful()) {
|
||||
if (!empty($retailcrm_payment_list) && $retailcrm_payment_list->isSuccessful()) {
|
||||
foreach ($retailcrm_payment_list['paymentTypes'] as $retailcrm_payment_type) {
|
||||
$payment_option_list[$retailcrm_payment_type['code']] = $retailcrm_payment_type['name'];
|
||||
}
|
||||
@ -285,7 +285,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
|
||||
$statuses_option_list = array();
|
||||
$retailcrm_statuses_list = $this->apiClient->statusesList();
|
||||
|
||||
if ($retailcrm_statuses_list->isSuccessful()) {
|
||||
if (!empty($retailcrm_statuses_list) && $retailcrm_statuses_list->isSuccessful()) {
|
||||
foreach ($retailcrm_statuses_list['statuses'] as $retailcrm_status) {
|
||||
$statuses_option_list[$retailcrm_status['code']] = $retailcrm_status['name'];
|
||||
}
|
||||
@ -587,7 +587,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
|
||||
|
||||
$response = $api->apiVersions();
|
||||
|
||||
if ($response && $response->isSuccessful()) {
|
||||
if (!empty($response) && $response->isSuccessful()) {
|
||||
if (!in_array($versionMap[$value], $response['versions'])) {
|
||||
WC_Admin_Settings::add_error( esc_html__( 'The selected API version is unavailable', 'retailcrm' ) );
|
||||
$value = '';
|
||||
|
@ -47,7 +47,7 @@ if ( ! class_exists( 'WC_Retailcrm_Proxy' ) ) :
|
||||
try {
|
||||
$response = call_user_func_array(array($this->retailcrm, $method), $arguments);
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
if (!empty($response) && $response->isSuccessful()) {
|
||||
$result = ' Ok';
|
||||
} else {
|
||||
$result = sprintf(
|
||||
|
@ -249,9 +249,9 @@ if (!class_exists('WC_Retailcrm_Base')) {
|
||||
}
|
||||
|
||||
$wcCustomer = new WC_Customer($customer_id);
|
||||
$resp = $client->customersList(array('email' => $wcCustomer->get_billing_email()));
|
||||
$response = $client->customersList(array('email' => $wcCustomer->get_billing_email()));
|
||||
|
||||
if ($resp && $resp->isSuccessful() && isset($resp['customers']) && count($resp['customers']) > 0) {
|
||||
if ((!empty($response) && $response->isSuccessful()) && isset($response['customers']) && count($response['customers']) > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ if (!class_exists('WC_Retailcrm_Customers')) :
|
||||
$this->processCustomer($customer);
|
||||
$response = $this->retailcrm->customersCreate($this->customer);
|
||||
|
||||
if ($response->isSuccessful() && isset($response['id'])) {
|
||||
if ((!empty($response) && $response->isSuccessful()) && isset($response['id'])) {
|
||||
return $response['id'];
|
||||
}
|
||||
}
|
||||
@ -182,7 +182,7 @@ if (!class_exists('WC_Retailcrm_Customers')) :
|
||||
$search = $this->retailcrm->customersList(array('email' => $filter['email']));
|
||||
}
|
||||
|
||||
if ($search->isSuccessful()) {
|
||||
if (!empty($search) && $search->isSuccessful()) {
|
||||
if (isset($search['customers'])) {
|
||||
if (empty($search['customers'])) {
|
||||
return false;
|
||||
|
@ -89,7 +89,7 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) :
|
||||
$response = $this->retailcrm->customersHistory(array('startDate' => $date));
|
||||
}
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
if (!empty($response) && $response->isSuccessful()) {
|
||||
if (empty($response['history'])) {
|
||||
return;
|
||||
}
|
||||
@ -190,7 +190,7 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) :
|
||||
$response = $this->retailcrm->ordersHistory(array('startDate' => $date));
|
||||
}
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
if (!empty($response) && $response->isSuccessful()) {
|
||||
if (empty($response['history'])) {
|
||||
return false;
|
||||
}
|
||||
@ -696,9 +696,11 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) :
|
||||
$order_items = array();
|
||||
if ($event == 'update') {
|
||||
$result = $this->retailcrm->ordersGet($order['externalId']);
|
||||
if ($result->isSuccessful()) {
|
||||
|
||||
if (!empty($result) && $result->isSuccessful()) {
|
||||
$orderCrm = $result['order'];
|
||||
}
|
||||
|
||||
$data = $orderCrm;
|
||||
}
|
||||
|
||||
|
@ -118,6 +118,7 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) :
|
||||
* @param $order_id
|
||||
*
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function orderCreate($order_id)
|
||||
{
|
||||
@ -202,7 +203,7 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) :
|
||||
|
||||
$response = $this->retailcrm->ordersEdit($this->order);
|
||||
|
||||
if ($response->isSuccessful() && $this->retailcrm_settings['api_version'] == 'v5') {
|
||||
if ((!empty($response) && $response->isSuccessful()) && $this->retailcrm_settings['api_version'] == 'v5') {
|
||||
$this->payment = $this->orderUpdatePaymentType($order);
|
||||
}
|
||||
|
||||
@ -224,7 +225,7 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) :
|
||||
|
||||
$response = $this->retailcrm->ordersGet($order->get_id());
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
if (!empty($response) && $response->isSuccessful()) {
|
||||
$retailcrmOrder = $response['order'];
|
||||
|
||||
foreach ($retailcrmOrder['payments'] as $payment_data) {
|
||||
@ -245,7 +246,7 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) :
|
||||
if (isset($payment) && $payment['type'] != $this->retailcrm_settings[$order->get_payment_method()]) {
|
||||
$response = $this->retailcrm->ordersPaymentDelete($payment['id']);
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
if (!empty($response) && $response->isSuccessful()) {
|
||||
$payment = $this->sendPayment($order);
|
||||
|
||||
return $payment;
|
||||
|
@ -120,7 +120,7 @@ class WC_Retailcrm_Plugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
if (!empty($response) && $response->isSuccessful()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -137,3 +137,4 @@ class WC_Retailcrm_Plugin {
|
||||
return self::$history_run;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,6 +122,21 @@ class WC_Retailcrm_Customers_Test extends WC_Retailcrm_Test_Case_Helper
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $retailcrm
|
||||
* @dataProvider dataProviderApiClient
|
||||
*/
|
||||
public function test_create_customer_empty_response($retailcrm)
|
||||
{
|
||||
$this->responseMock = null;
|
||||
$this->apiMock = null;
|
||||
|
||||
$retailcrm_customer = $this->getRetailcrmCustomer($retailcrm);
|
||||
$id = $retailcrm_customer->createCustomer($this->customer->get_id());
|
||||
|
||||
$this->assertEquals(null, $id);
|
||||
}
|
||||
|
||||
public function dataProviderApiClient()
|
||||
{
|
||||
$this->setUp();
|
||||
|
Loading…
x
Reference in New Issue
Block a user