diff --git a/src/assets/js/retailcrm-loyalty-actions.js b/src/assets/js/retailcrm-loyalty-actions.js index a45233f..256fadf 100644 --- a/src/assets/js/retailcrm-loyalty-actions.js +++ b/src/assets/js/retailcrm-loyalty-actions.js @@ -32,7 +32,7 @@ jQuery(function() { } jQuery.ajax({ - url: LoyaltyUrl.url + '/admin-ajax.php?action=register_customer_loyalty', + url: loyaltyUrl.url + '/admin-ajax.php?action=register_customer_loyalty', method: 'POST', timeout: 0, data: {ajax: 1, phone: phone.val(), userId: customerId}, @@ -63,7 +63,7 @@ jQuery(function() { } jQuery.ajax({ - url: LoyaltyUrl.url + '/admin-ajax.php?action=activate_customer_loyalty', + url: loyaltyUrl.url + '/admin-ajax.php?action=activate_customer_loyalty', method: 'POST', timeout: 0, data: {ajax: 1, loyaltyId: loyaltyId}, diff --git a/src/include/class-wc-retailcrm-base.php b/src/include/class-wc-retailcrm-base.php index 7fbbad6..1da1e60 100644 --- a/src/include/class-wc-retailcrm-base.php +++ b/src/include/class-wc-retailcrm-base.php @@ -898,7 +898,7 @@ if (!class_exists('WC_Retailcrm_Base')) { wp_register_script($jsScript, $jsScriptsPath . $jsScript . '.js', false, '0.1'); wp_enqueue_script($jsScript, $jsScriptsPath . $jsScript . '.js', '', '', true); - wp_localize_script($jsScript, 'LoyaltyUrl', $loyaltyUrl); + wp_localize_script($jsScript, 'loyaltyUrl', $loyaltyUrl); wp_localize_script($jsScript, 'customerId', $userId); wp_localize_script($jsScript, 'messagePhone', $messagePhone); wp_localize_script($jsScript, 'termsLoyalty', $this->settings['loyalty_terms']); diff --git a/tests/datasets/data-loyalty-retailcrm.php b/tests/datasets/data-loyalty-retailcrm.php index 8c3c5bb..ef9044f 100644 --- a/tests/datasets/data-loyalty-retailcrm.php +++ b/tests/datasets/data-loyalty-retailcrm.php @@ -19,24 +19,58 @@ class DataLoyaltyRetailCrm public static function getDataLoyalty() { return [ - 'id' => 1, - 'level' => [ - 'name' => 'Test level', - 'privilegeSize' => 5, - 'privilegeSizePromo' => 3, - 'type' => 'bonus_converting' + [ + 'isSuccessful' => true, + 'body' => json_encode(['loyaltyAccounts' => []]), + 'expected' => 'id="loyaltyRegisterForm"' ], - 'amount' => 1000, - 'cardNumber' => '12345', - 'activatedAt' => '2024-04-10 15:00:00', - 'nextLevelSum' => 15000, - 'loyalty' => [ - 'currency' => 'USD' + [ + 'isSuccessful' => true, + 'body' => json_encode( + [ + 'loyaltyAccounts' => [ + 0 => [ + 'active' => false, + 'customer' => [ + 'externalId' => 1 + ], + 'id' => 1 + ] + ] + ] + ), + 'expected' => 'id="loyaltyActivateForm"' ], - 'customer' => [ - 'externalId' => 1 + [ + 'isSuccessful' => true, + 'body' => json_encode( + [ + 'loyaltyAccounts' => [ + 0 => [ + 'id' => 1, + 'level' => [ + 'name' => 'Test level', + 'privilegeSize' => 5, + 'privilegeSizePromo' => 3, + 'type' => 'bonus_converting' + ], + 'amount' => 1000, + 'cardNumber' => '12345', + 'activatedAt' => '2024-04-10 15:00:00', + 'nextLevelSum' => 15000, + 'loyalty' => [ + 'currency' => 'USD' + ], + 'customer' => [ + 'externalId' => 1 + ], + 'active' => true + ] + ] + ] + ), + 'expected' => 'Ordinary products: accrual of 1 bonus for each' ], - 'active' => true ]; } } diff --git a/tests/test-wc-retailcrm-loyalty.php b/tests/test-wc-retailcrm-loyalty.php index 93d40b0..9e6f653 100644 --- a/tests/test-wc-retailcrm-loyalty.php +++ b/tests/test-wc-retailcrm-loyalty.php @@ -87,34 +87,6 @@ class WC_Retailcrm_Loyalty_Test extends WC_Retailcrm_Test_Case_Helper public function responseLoyalty() { - return [ - [ - 'isSuccessful' => true, - 'body' => json_encode(['loyaltyAccounts' => []]), - 'expected' => 'id="loyaltyRegisterForm"' - ], - [ - 'isSuccessful' => true, - 'body' => json_encode( - [ - 'loyaltyAccounts' => [ - 0 => [ - 'active' => false, - 'customer' => [ - 'externalId' => 1 - ], - 'id' => 1 - ] - ] - ] - ), - 'expected' => 'id="loyaltyActivateForm"' - ], - [ - 'isSuccessful' => true, - 'body' => json_encode(['loyaltyAccounts' => [0 => DataLoyaltyRetailCrm::getDataLoyalty()]]), - 'expected' => 'accrual of 1 bonus for each' - ] - ]; + return DataLoyaltyRetailCrm::getDataLoyalty(); } }