| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Description of AliexpressError |
| 5 |
* |
| 6 |
* @author Ali2Woo Team |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace AliNext_Lite;; |
| 10 |
|
| 11 |
class AliexpressError |
| 12 |
{ |
| 13 |
const B_DROPSHIPPER_DELIVERY_ADDRESS_VALIDATE_FAIL = 'B_DROPSHIPPER_DELIVERY_ADDRESS_VALIDATE_FAIL'; |
| 14 |
const ERROR_WHEN_BUILD_FOR_PLACE_ORDER = 'ERROR_WHEN_BUILD_FOR_PLACE_ORDER'; |
| 15 |
const DELIVERY_METHOD_NOT_EXIST = 'DELIVERY_METHOD_NOT_EXIST'; |
| 16 |
const INVALID_SESSION = 'Invalid session'; |
| 17 |
|
| 18 |
public static function message($error) |
| 19 |
{ |
| 20 |
$error_code = esc_html__('Aliexpress error', 'ali2woo'); |
| 21 |
if (is_array($error) && !empty($error['error_code'])) { |
| 22 |
$error_code = $error['error_code']; |
| 23 |
} else if (is_scalar($error) && !empty($error)) { |
| 24 |
$error_code = $error; |
| 25 |
} else if (is_array($error) && !empty($error['error_response']['msg'])) { |
| 26 |
$error_code = $error['error_response']['msg']; |
| 27 |
} else if (is_array($error) && !empty($error['msg'])) { |
| 28 |
$error_code = $error['msg']; |
| 29 |
} |
| 30 |
|
| 31 |
switch ($error_code) { |
| 32 |
case self::B_DROPSHIPPER_DELIVERY_ADDRESS_VALIDATE_FAIL: |
| 33 |
return esc_html__('Invalid shipping address', 'ali2woo'); |
| 34 |
case self::ERROR_WHEN_BUILD_FOR_PLACE_ORDER: |
| 35 |
return esc_html__('Check if each product (or its variant) in your order is still available and in-stock on AliExpress', 'ali2woo'); |
| 36 |
case self::DELIVERY_METHOD_NOT_EXIST: |
| 37 |
return esc_html__('Invalid shipping method', 'ali2woo'); |
| 38 |
case self::INVALID_SESSION: |
| 39 |
return esc_html__('Invalid session', 'ali2woo'); |
| 40 |
default: |
| 41 |
return $error_code; |
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
|