Review fixes
This commit is contained in:
parent
ede11fc335
commit
8d058e246b
7 changed files with 19 additions and 93 deletions
|
@ -274,15 +274,6 @@ msgstr "Presionando el botón «Exportar» puedes descargar a todos los pedidos
|
|||
msgid "Debug information"
|
||||
msgstr "Información Debug"
|
||||
|
||||
msgid "Debug mode"
|
||||
msgstr "Modo de depuración"
|
||||
|
||||
msgid "Enable debug mode in module"
|
||||
msgstr "Activar el modo de depuración en el módulo"
|
||||
|
||||
msgid "Is required to enable debug mode for advanced logs"
|
||||
msgstr "Se requiere el modo de depuración para habilitar el registro avanzado de logs"
|
||||
|
||||
msgid "Custom fields"
|
||||
msgstr "Campos personalizados"
|
||||
|
||||
|
|
|
@ -283,15 +283,6 @@ msgstr "Вы можете экспортировать все заказы и к
|
|||
msgid "Debug information"
|
||||
msgstr "Отладочная информация"
|
||||
|
||||
msgid "Debug mode"
|
||||
msgstr "Режим отладки"
|
||||
|
||||
msgid "Enable debug mode in module"
|
||||
msgstr "Активировать режим отладки в модуле"
|
||||
|
||||
msgid "Is required to enable debug mode for advanced logs"
|
||||
msgstr "Требуется включить режим отладки для расширенного логирования"
|
||||
|
||||
msgid "Custom fields"
|
||||
msgstr "Пользовательские поля"
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ if (!class_exists('WC_Retailcrm_Proxy')) :
|
|||
{
|
||||
$this->corporateEnabled = $corporateEnabled;
|
||||
|
||||
if ( ! class_exists( 'WC_Retailcrm_Client_V5' ) ) {
|
||||
if (!class_exists('WC_Retailcrm_Client_V5')) {
|
||||
include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-client-v5.php'));
|
||||
}
|
||||
|
||||
|
@ -29,11 +29,9 @@ if (!class_exists('WC_Retailcrm_Proxy')) :
|
|||
}
|
||||
|
||||
/**
|
||||
* getCorporateEnabled
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getCorporateEnabled()
|
||||
public function getCorporateEnabled(): bool
|
||||
{
|
||||
return $this->corporateEnabled;
|
||||
}
|
||||
|
@ -43,7 +41,7 @@ if (!class_exists('WC_Retailcrm_Proxy')) :
|
|||
*
|
||||
* @return string[]
|
||||
*/
|
||||
private function methodsWithoutFullLog()
|
||||
private function methodsWithoutFullLog(): array
|
||||
{
|
||||
$methodsList = [
|
||||
'statusesList',
|
||||
|
@ -67,7 +65,6 @@ if (!class_exists('WC_Retailcrm_Proxy')) :
|
|||
$called = sprintf('%s::%s', get_class($this->retailcrm), $method);
|
||||
|
||||
try {
|
||||
/** @var \WC_Retailcrm_Response $response */
|
||||
$response = $this->getResponse($method, $arguments);
|
||||
|
||||
if (is_string($response)) {
|
||||
|
@ -99,7 +96,7 @@ if (!class_exists('WC_Retailcrm_Proxy')) :
|
|||
{
|
||||
WC_Retailcrm_Logger::info(
|
||||
$method,
|
||||
count($arguments) === 0 ? '[no params]' : '[with params]',
|
||||
$arguments === [] ? '[no params]' : '[with params]',
|
||||
['params' => $arguments],
|
||||
WC_Retailcrm_Logger::REQUEST
|
||||
);
|
||||
|
@ -125,7 +122,6 @@ if (!class_exists('WC_Retailcrm_Proxy')) :
|
|||
WC_Retailcrm_Logger::RESPONSE
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
WC_Retailcrm_Logger::error(
|
||||
$method,
|
||||
|
|
|
@ -60,6 +60,7 @@ if (class_exists('WC_Retailcrm_Uploader') === false) {
|
|||
public function uploadSelectedOrders()
|
||||
{
|
||||
$ids = $_GET['order_ids_retailcrm'];
|
||||
|
||||
WC_Retailcrm_Logger::info(__METHOD__, 'Selected order IDs: ' . json_encode($ids));
|
||||
|
||||
if (!empty($ids)) {
|
||||
|
|
|
@ -38,29 +38,17 @@ if (!class_exists('WC_Retailcrm_Logger') && class_exists('WC_Log_Levels')) :
|
|||
private static $logIdentifier;
|
||||
|
||||
/**
|
||||
* Current called hook name
|
||||
*
|
||||
* @var string $currentHook
|
||||
*/
|
||||
private static $currentHook;
|
||||
|
||||
/**
|
||||
* First called action time
|
||||
*
|
||||
* @var float $startTime
|
||||
*/
|
||||
private static $startTime;
|
||||
|
||||
/**
|
||||
* WC_Retailcrm_Logger constructor.
|
||||
*/
|
||||
private function __construct() {}
|
||||
|
||||
/**
|
||||
* Instantiates logger with file handler.
|
||||
*
|
||||
* @return \WC_Logger_Interface
|
||||
*/
|
||||
private static function getInstance(): WC_Logger_Interface
|
||||
{
|
||||
if (!static::$instance instanceof WC_Logger) {
|
||||
|
@ -70,22 +58,12 @@ if (!class_exists('WC_Retailcrm_Logger') && class_exists('WC_Log_Levels')) :
|
|||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $additionalHandlers
|
||||
*/
|
||||
public static function setAdditionalHandlers($additionalHandlers)
|
||||
public static function setAdditionalHandlers(array $additionalHandlers): void
|
||||
{
|
||||
self::$additionalHandlers = $additionalHandlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called in base class for action hooks
|
||||
*
|
||||
* @param string $action
|
||||
* @param $id
|
||||
* @return void
|
||||
*/
|
||||
public static function setHook(string $action, $id = null)
|
||||
public static function setHook(string $action, $id = null): void
|
||||
{
|
||||
static::$currentHook = $id === null ? $action : sprintf('%s-%d', $action, (int) $id);
|
||||
}
|
||||
|
@ -108,15 +86,7 @@ if (!class_exists('WC_Retailcrm_Logger') && class_exists('WC_Log_Levels')) :
|
|||
return static::$startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception logging
|
||||
*
|
||||
* @param string $method
|
||||
* @param Throwable $exception
|
||||
* @param string $additionalMessage
|
||||
* @return void
|
||||
*/
|
||||
public static function exception(string $method, Throwable $exception, string $additionalMessage = '')
|
||||
public static function exception(string $method, Throwable $exception, string $additionalMessage = ''): void
|
||||
{
|
||||
self::error(
|
||||
$method,
|
||||
|
@ -132,42 +102,17 @@ if (!class_exists('WC_Retailcrm_Logger') && class_exists('WC_Log_Levels')) :
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Error logging
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $message
|
||||
* @param null|string $type
|
||||
* @param array $context
|
||||
*/
|
||||
public static function error(string $method, string $message, array $context = [], $type = null)
|
||||
public static function error(string $method, string $message, array $context = [], $type = null): void
|
||||
{
|
||||
self::log($method, $message, $context, $type, WC_Log_Levels::ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Info logging
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $message
|
||||
* @param null|string $type
|
||||
* @param array $context
|
||||
*/
|
||||
public static function info(string $method, string $message, array $context = [], $type = null)
|
||||
public static function info(string $method, string $message, array $context = [], $type = null): void
|
||||
{
|
||||
self::log($method, $message, $context, $type, WC_Log_Levels::INFO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular logging function.
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $message
|
||||
* @param string|null $type
|
||||
* @param array $context
|
||||
* @param string|null $level
|
||||
*/
|
||||
private static function log(string $method, string $message, array $context = [], $type = null, $level = 'info')
|
||||
private static function log(string $method, string $message, array $context = [], $type = null, $level = 'info'): void
|
||||
{
|
||||
$time = self::getStartTime();
|
||||
$context['time'] = round((microtime(true) - $time), 3);
|
||||
|
|
|
@ -62,11 +62,14 @@ class WC_Retailcrm_Order_Payment extends WC_Retailcrm_Abstracts_Data
|
|||
|
||||
if ($order->is_paid()) {
|
||||
if ($order->get_status() != 'completed' && $order->get_payment_method() == 'cod') {
|
||||
$logMessage = 'Payment for order: ' . $order->get_id() . '. ' .
|
||||
'Payment status cannot be changed as it is cash (or other payment method) on delivery. ' .
|
||||
'The status will be changed when the order is in status completed.'
|
||||
;
|
||||
WC_Retailcrm_Logger::info(__METHOD__, $logMessage);
|
||||
WC_Retailcrm_Logger::info(
|
||||
__METHOD__,
|
||||
sprintf('Payment for order: %s. ' .
|
||||
'Payment status cannot be changed as it is cash (or other payment method) on delivery. ' .
|
||||
'The status will be changed when the order is in status completed.',
|
||||
$order->get_id()
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$paymentData['status'] = 'paid';
|
||||
|
||||
|
|
|
@ -119,7 +119,6 @@ class WC_Retailcrm_Base_Test extends WC_Retailcrm_Test_Case_Helper
|
|||
$this->assertArrayHasKey('export_selected_orders_ids', $this->baseRetailcrm->form_fields);
|
||||
$this->assertArrayHasKey('export_selected_orders_btn', $this->baseRetailcrm->form_fields);
|
||||
|
||||
//Debug info
|
||||
$this->assertArrayHasKey('debug-info', $this->baseRetailcrm->form_fields);
|
||||
|
||||
//Other settings
|
||||
|
|
Loading…
Add table
Reference in a new issue