diff --git a/Api/CustomerAttributeInterface.php b/Api/CustomerAttributeInterface.php index 0fbe87b..0c56afa 100755 --- a/Api/CustomerAttributeInterface.php +++ b/Api/CustomerAttributeInterface.php @@ -1,6 +1,6 @@ getParentBlock()->addTotal( new DataObject( [ - 'code' => 'zinrelo_discount', + 'code' => 'trueloyal_discount', 'strong' => $this->getStrong(), 'value' => $totalAmount["value"], 'base_value' => $totalAmount["value"], diff --git a/Block/Adminhtml/Sales/Order/ZinreloCreditMemoViewDiscount.php b/Block/Adminhtml/Sales/Order/TrueLoyalCreditMemoViewDiscount.php similarity index 85% rename from Block/Adminhtml/Sales/Order/ZinreloCreditMemoViewDiscount.php rename to Block/Adminhtml/Sales/Order/TrueLoyalCreditMemoViewDiscount.php index 6c8e5db..60f77cd 100755 --- a/Block/Adminhtml/Sales/Order/ZinreloCreditMemoViewDiscount.php +++ b/Block/Adminhtml/Sales/Order/TrueLoyalCreditMemoViewDiscount.php @@ -1,14 +1,14 @@ getParentBlock()->addTotal( new DataObject( [ - 'code' => 'zinrelo_discount', + 'code' => 'trueloyal_discount', 'strong' => $this->getStrong(), 'value' => $totalAmount["value"], 'base_value' => $totalAmount["value"], diff --git a/Block/Adminhtml/Sales/Order/ZinreloDiscount.php b/Block/Adminhtml/Sales/Order/TrueLoyalDiscount.php similarity index 89% rename from Block/Adminhtml/Sales/Order/ZinreloDiscount.php rename to Block/Adminhtml/Sales/Order/TrueLoyalDiscount.php index 87a5e90..bb44108 100755 --- a/Block/Adminhtml/Sales/Order/ZinreloDiscount.php +++ b/Block/Adminhtml/Sales/Order/TrueLoyalDiscount.php @@ -1,13 +1,13 @@ getParentBlock()->addTotal( new DataObject( [ - 'code' => 'zinrelo_discount', + 'code' => 'trueloyal_discount', 'strong' => $this->getStrong(), 'value' => $totalAmount["value"], 'base_value' => $totalAmount["value"], diff --git a/Block/Adminhtml/Sales/Order/ZinreloInvoiceCreateDiscount.php b/Block/Adminhtml/Sales/Order/TrueLoyalInvoiceCreateDiscount.php similarity index 90% rename from Block/Adminhtml/Sales/Order/ZinreloInvoiceCreateDiscount.php rename to Block/Adminhtml/Sales/Order/TrueLoyalInvoiceCreateDiscount.php index b89e98d..ac8e68a 100755 --- a/Block/Adminhtml/Sales/Order/ZinreloInvoiceCreateDiscount.php +++ b/Block/Adminhtml/Sales/Order/TrueLoyalInvoiceCreateDiscount.php @@ -1,14 +1,14 @@ getParentBlock()->addTotal( new DataObject( [ - 'code' => 'zinrelo_discount', + 'code' => 'trueloyal_discount', 'strong' => $this->getStrong(), 'value' => $totalAmount["value"], 'base_value' => $totalAmount["value"], diff --git a/Block/Adminhtml/Sales/Order/ZinreloInvoiceViewDiscount.php b/Block/Adminhtml/Sales/Order/TrueLoyalInvoiceViewDiscount.php similarity index 85% rename from Block/Adminhtml/Sales/Order/ZinreloInvoiceViewDiscount.php rename to Block/Adminhtml/Sales/Order/TrueLoyalInvoiceViewDiscount.php index 5374756..6d9d93b 100755 --- a/Block/Adminhtml/Sales/Order/ZinreloInvoiceViewDiscount.php +++ b/Block/Adminhtml/Sales/Order/TrueLoyalInvoiceViewDiscount.php @@ -1,14 +1,14 @@ getParentBlock()->addTotal( new DataObject( [ - 'code' => 'zinrelo_discount', + 'code' => 'trueloyal_discount', 'strong' => $this->getStrong(), 'value' => $totalAmount["value"], 'base_value' => $totalAmount["value"], diff --git a/Block/Cart/RewardList.php b/Block/Cart/RewardList.php index d1f4525..a0e4400 100755 --- a/Block/Cart/RewardList.php +++ b/Block/Cart/RewardList.php @@ -1,11 +1,11 @@ logger = $logger; @@ -67,8 +67,8 @@ public function getFormAction() public function canCancelRedeem() { $quote = $this->helper->getQuote(); - $zinreloQuote = $this->helper->getZinreloQuoteByQuoteId($quote->getId()); - if (!empty($zinreloQuote->getRewardRulesData() && !empty($zinreloQuote->getRedeemRewardDiscount()))) { + $trueloyalQuote = $this->helper->getTrueLoyalQuoteByQuoteId($quote->getId()); + if (!empty($trueloyalQuote->getRewardRulesData() && !empty($trueloyalQuote->getRedeemRewardDiscount()))) { return true; } return false; diff --git a/Block/Dashboard.php b/Block/Dashboard.php index b15c48f..2f6cba0 100755 --- a/Block/Dashboard.php +++ b/Block/Dashboard.php @@ -1,9 +1,16 @@ config = $config; + $this->jwt = $jwt; + $this->customerFactory = $customerFactory; + $this->customerRepository = $customerRepository; + $this->sessionFactory = $sessionFactory; + $this->countryFactory = $countryFactory; + $this->store = $store; + $this->serializer = $serializer; + parent::__construct($context, $data); } /** @@ -33,7 +96,7 @@ public function __construct( * * @return bool */ - public function isModuleEnabled() + public function isModuleEnabled(): bool { return $this->config->isModuleEnabled(); } @@ -47,4 +110,137 @@ public function getPartnerId() { return $this->config->getPartnerId(); } + + /** + * Build and return a signed JWT for the current customer. + * Returns empty string if the customer is not eligible. + * + * @return string + */ + public function getJwtToken(): string + { + if ($this->config->isDashboardHiddenForGuests() && !$this->sessionFactory->create()->getCustomerId()) { + return ''; + } + + $key = $this->config->getApiKey(); + $apiKeyIdentifier = $this->config->getApiKeyIdentifier(); + $customerEmail = ""; + $customerFirstName = ""; + $customerLastName = ""; + $customerBirthDate = ""; + $street = []; + $city = ""; + $region = ""; + $postcode = ""; + $country = ""; + $telephone = ""; + $lang = ""; + $memberIdentifierValue = ""; + + $jsonConfigLanguage = $this->config->getConfigLanguage(); + $preferredLanguage = $this->config->getPreferredLanguage(); + if ($preferredLanguage) { + $lang = $preferredLanguage; + } elseif ($jsonConfigLanguage) { + $lang = $this->store->getLocale() ?? ""; + $configLanguage = $this->serializer->unserialize($jsonConfigLanguage); + $config = stristr($lang, "_", true); + if (isset($configLanguage[$config]) && $configLanguage[$config]) { + $lang = $configLanguage[$config]; + } else { + $lang = ""; + } + } + + $customerId = $this->sessionFactory->create()->getCustomerId(); + if ($customerId && !$this->config->isAutoEnrollmentEnabled()) { + $customerData = $this->customerRepository->getById($customerId); + $optInAttribute = $this->config->getOptInAttributeCode(); + $trueloyalOptedIn = $customerData->getCustomAttribute($optInAttribute); + if (!$trueloyalOptedIn || !$trueloyalOptedIn->getValue()) { + return ''; + } + } + + $customer = $this->customerFactory->create()->load($customerId); + if ($customer->getEntityId()) { + $billingAddress = $customer->getDefaultBillingAddress() + ? $customer->getDefaultBillingAddress()->getData() + : []; + $customerEmail = $customer->getEmail(); + $customerFirstName = $customer->getFirstname(); + $customerLastName = $customer->getLastname(); + $customerBirthDate = $customer->getDob(); + $pattern = '/(\d{4})-(\d{2})-(\d{2})/'; + if ($customerBirthDate && preg_match($pattern, $customerBirthDate)) { + $customerBirthDate = preg_replace($pattern, '$2/$3/$1', $customerBirthDate); + } + $telephone = $billingAddress['telephone'] ?? ""; + $city = $billingAddress['city'] ?? ""; + $region = $billingAddress['region'] ?? ""; + $postcode = $billingAddress['postcode'] ?? ""; + $street = isset($billingAddress['street']) ? explode("\n", $billingAddress['street']) : []; + $country = isset($billingAddress['country_id']) + ? $this->getCountryName($billingAddress['country_id']) + : ""; + $memberIdentifierValue = $this->config->getMemberIdentifierValue(); + } + + $customAttributes = []; + $customStoreIdKey = $this->config->getCustomMemberStoreId(); + $customStoreCodeKey = $this->config->getCustomMemberStoreCode(); + $customStoreCurrencyKey = $this->config->getCustomMemberStoreCurrency(); + if ($customStoreIdKey) { + $customAttributes[$customStoreIdKey] = $this->_storeManager->getGroup()->getId(); + } + if ($customStoreCodeKey) { + $customAttributes[$customStoreCodeKey] = $this->_storeManager->getGroup()->getCode(); + } + if ($customStoreCurrencyKey) { + $customAttributes[$customStoreCurrencyKey] = $this->config->getStoreCurrencyCode(); + } + + $payload = [ + 'member_id' => $memberIdentifierValue, + 'sub' => $apiKeyIdentifier, + 'email_address' => $customerEmail, + 'first_name' => $customerFirstName, + 'last_name' => $customerLastName, + 'phone_number' => $telephone + ? (preg_match('/^\+[0-9]{2}-[0-9]{10}+$/', $telephone) ? $telephone : "") + : "", + 'birthdate' => $customerBirthDate, + 'preferred_language' => $lang, + 'address' => [ + 'line1' => $street[0] ?? "", + 'line2' => $street[1] ?? ($street[0] ?? ""), + 'city' => $city, + 'state' => $region, + 'country' => $country, + 'postal_code' => $postcode, + ], + 'custom_attributes' => $customAttributes, + 'exp' => round(microtime(true) * 1000), + ]; + + $token = $this->jwt->encode($payload, $key, 'HS256'); + + if ($memberIdentifierValue) { + $this->config->setCookie($token); + } + + return $token; + } + + /** + * Get Country Name + * + * @param string $countryCode + * @return string + */ + private function getCountryName(string $countryCode): string + { + return $this->countryFactory->create()->loadByCode($countryCode)->getName(); + } } diff --git a/Block/Sales/CreditMemo/Discount.php b/Block/Sales/CreditMemo/Discount.php index 6464274..301319f 100755 --- a/Block/Sales/CreditMemo/Discount.php +++ b/Block/Sales/CreditMemo/Discount.php @@ -1,11 +1,11 @@ getParentBlock()->addTotal( new DataObject( [ - 'code' => 'zinrelo_discount', + 'code' => 'trueloyal_discount', 'strong' => $this->getStrong(), 'value' => $totalAmount["value"], 'base_value' => $totalAmount["value"], diff --git a/Block/Sales/CreditMemoPrint/Discount.php b/Block/Sales/CreditMemoPrint/Discount.php index a99265d..53d5529 100755 --- a/Block/Sales/CreditMemoPrint/Discount.php +++ b/Block/Sales/CreditMemoPrint/Discount.php @@ -1,12 +1,12 @@ getParentBlock()->addTotal( new DataObject( [ - 'code' => 'zinrelo_discount', + 'code' => 'trueloyal_discount', 'strong' => $this->getStrong(), 'value' => $totalAmount["value"], 'base_value' => $totalAmount["value"], diff --git a/Block/Sales/Invoice/Discount.php b/Block/Sales/Invoice/Discount.php index d08376c..8cf8ad3 100755 --- a/Block/Sales/Invoice/Discount.php +++ b/Block/Sales/Invoice/Discount.php @@ -1,11 +1,11 @@ getParentBlock()->addTotal( new DataObject( [ - 'code' => 'zinrelo_discount', + 'code' => 'trueloyal_discount', 'strong' => $this->getStrong(), 'value' => $totalAmount["value"], 'base_value' => $totalAmount["value"], diff --git a/Block/Sales/InvoicePrint/Discount.php b/Block/Sales/InvoicePrint/Discount.php index 8e833a2..b6a978d 100755 --- a/Block/Sales/InvoicePrint/Discount.php +++ b/Block/Sales/InvoicePrint/Discount.php @@ -1,12 +1,12 @@ getParentBlock()->addTotal( new DataObject( [ - 'code' => 'zinrelo_discount', + 'code' => 'trueloyal_discount', 'strong' => $this->getStrong(), 'value' => $totalAmount["value"], 'base_value' => $totalAmount["value"], diff --git a/Block/Sales/Order/Discount.php b/Block/Sales/Order/Discount.php index 69ca1ba..7a8c51c 100755 --- a/Block/Sales/Order/Discount.php +++ b/Block/Sales/Order/Discount.php @@ -1,11 +1,11 @@ getParentBlock()->addTotal( new DataObject( [ - 'code' => 'zinrelo_discount', + 'code' => 'trueloyal_discount', 'strong' => $this->getStrong(), 'value' => $totalAmount["value"], 'base_value' => $totalAmount["value"], diff --git a/Block/Sales/OrderPrint/Discount.php b/Block/Sales/OrderPrint/Discount.php index cecd7f3..a86c854 100755 --- a/Block/Sales/OrderPrint/Discount.php +++ b/Block/Sales/OrderPrint/Discount.php @@ -1,11 +1,11 @@ getParentBlock()->addTotal( new DataObject( [ - 'code' => 'zinrelo_discount', + 'code' => 'trueloyal_discount', 'strong' => $this->getStrong(), 'value' => $totalAmount["value"], 'base_value' => $totalAmount["value"], diff --git a/Controller/LoyaltyRewards/ApplyPoint.php b/Controller/LoyaltyRewards/ApplyPoint.php index 7ba2566..022ea81 100755 --- a/Controller/LoyaltyRewards/ApplyPoint.php +++ b/Controller/LoyaltyRewards/ApplyPoint.php @@ -1,6 +1,6 @@ request->getPost('redeem_reward'); $quote = $this->checkoutSession->getQuote(); - /*Managed Set zinrelo quote related to Data to custom table*/ + /*Managed Set trueloyal quote related to Data to custom table*/ $this->helper->setAbandonedCartSent($quote->getId(), 2); - $zinreloQuote = $this->helper->getZinreloQuoteByQuoteId($quote->getId()); + $trueloyalQuote = $this->helper->getTrueLoyalQuoteByQuoteId($quote->getId()); /*End*/ $resultJson = $this->jsonFactory->create(); $this->cart->setUpdatedAt()->save(); @@ -143,8 +143,8 @@ public function execute() $rewardRules = $this->helper->getRedeemRules(); if (!empty($rewardRules)) { try { - $zinreloQuote->setRewardRulesData($this->helper->jsonSerialize($rewardRules)); - $zinreloQuote->save(); + $trueloyalQuote->setRewardRulesData($this->helper->jsonSerialize($rewardRules)); + $trueloyalQuote->save(); } catch (Exception $e) { $this->logger->critical($e->getMessage()); } @@ -154,7 +154,7 @@ public function execute() $productId = $rewardData["product_id"]; $product = $this->product->load($productId); if (!$product->getEntityId() || $product->getStatus() != Status::STATUS_ENABLED) { - $this->unsetRewardRules($zinreloQuote); + $this->unsetRewardRules($trueloyalQuote); $this->messageManager->addError(__("Product that you are trying to add is not available.")); return $resultJson->setData([ 'success' => false @@ -170,7 +170,7 @@ public function execute() $redeemPoints = min($subTotal*$conversion_rate, max($rewardData['minimum_redemption_limit'], min($redeemPoints, $rewardData['maximum_redemption_limit']))); } else { - $this->unsetRewardRules($zinreloQuote); + $this->unsetRewardRules($trueloyalQuote); $this->messageManager->addError(__("Please enter the correct number of points to be redeemed.")); return $resultJson->setData([ 'success' => false @@ -178,21 +178,21 @@ public function execute() } $rewardData["points_to_be_redeemed"] = $redeemPoints; $rewardRules[$redeemReward]['points_to_be_redeemed'] = $redeemPoints; - $zinreloQuote->setRewardRulesData($this->helper->jsonSerialize($rewardRules)); - $zinreloQuote->save(); + $trueloyalQuote->setRewardRulesData($this->helper->jsonSerialize($rewardRules)); + $trueloyalQuote->save(); } $response = $this->getApiResponse($rewardData); if ($response["success"] && !empty($response["result"]["data"])) { $responseData = $response["result"]["data"]; if ($responseData["status"] === "pending") { - $this->saveQuoteData($zinreloQuote, $responseData, $redeemReward, $rewardData); + $this->saveQuoteData($trueloyalQuote, $responseData, $redeemReward, $rewardData); $this->messageManager->addSuccess(__('You have redeemed %1 successfully.', $rewardData['reward_name'])); return $resultJson->setData([ 'success' => true ]); } else { - $this->unsetRewardRules($zinreloQuote); + $this->unsetRewardRules($trueloyalQuote); $this->messageManager->addError( __("This reward rule can not be redeemed, try with another reward rule") ); @@ -201,7 +201,7 @@ public function execute() ]); } } else { - $this->unsetRewardRules($zinreloQuote); + $this->unsetRewardRules($trueloyalQuote); $this->messageManager->addError(__("This reward rule can not be redeemed, try with another reward rule")); return $resultJson->setData([ 'success' => false @@ -212,13 +212,13 @@ public function execute() /** * Delete reward relus from quote when getting error from response * - * @param ZinreloQuote $zinreloQuote + * @param TrueLoyalQuote $trueloyalQuote */ - public function unsetRewardRules($zinreloQuote) + public function unsetRewardRules($trueloyalQuote) { try { - $zinreloQuote->setRewardRulesData(''); - $zinreloQuote->save(); + $trueloyalQuote->setRewardRulesData(''); + $trueloyalQuote->save(); } catch (Exception $e) { $this->logger->critical($e->getMessage()); } @@ -246,9 +246,8 @@ public function getApiResponse($rewardData) */ public function getParamsData($rewardData) { - $customerEmail = $this->customerSession->getCustomer()->getEmail(); $params = [ - "member_id" => $customerEmail, + "member_id" => $this->helper->getMemberIdentifierValue(), "reward_id" => $rewardData["reward_id"], "transaction_attributes" => [ "reason" => "redeem", @@ -270,23 +269,23 @@ public function getParamsData($rewardData) /** * Save Quote Data * - * @param ZinreloQuote $zinreloQuote + * @param TrueLoyalQuote $trueloyalQuote * @param mixed $responseData * @param mixed $redeemReward * @param mixed $rewardData */ - public function saveQuoteData($zinreloQuote, $responseData, $redeemReward, $rewardData) + public function saveQuoteData($trueloyalQuote, $responseData, $redeemReward, $rewardData) { try { if ($rewardData["rule"] === "product_redemption" && !empty($rewardData["product_id"])) { $this->addToCartProductWithNewPrice($rewardData); } - $allRewardRules = $this->helper->json->unserialize($zinreloQuote->getRewardRulesData()); + $allRewardRules = $this->helper->json->unserialize($trueloyalQuote->getRewardRulesData()); $allRewardRules[$responseData["reward_info"]["reward_id"]]["id"] = $responseData["id"]; $encodedRule = $this->helper->json->serialize($allRewardRules); - $zinreloQuote->setRewardRulesData($encodedRule); - $zinreloQuote->setRedeemRewardDiscount($redeemReward); - $zinreloQuote->save(); + $trueloyalQuote->setRewardRulesData($encodedRule); + $trueloyalQuote->setRedeemRewardDiscount($redeemReward); + $trueloyalQuote->save(); } catch (Exception $e) { $this->logger->critical($e->getMessage()); } @@ -315,12 +314,12 @@ public function addToCartProductWithNewPrice($rewardData) $product->addCustomOption('additional_options', $this->serializer->serialize($additionalOptions)); $this->cart->addProduct($product, $params); $this->cart->save(); - /*Set free product to Zinrelo quote item*/ + /*Set free product to TrueLoyal quote item*/ $quoteItemCollection = $this->cart->getItems(); foreach ($quoteItemCollection as $item) { if($item->getProductId() == $productId && $item->getPrice() == 0) { - $zinreloQuoteItem = $this->helper->getZinreloQuoteItemByItemId($item->getId()); - $zinreloQuoteItem->setIsZinreloFreeProduct(1)->setQuoteItemId($item->getId())->save(); + $trueloyalQuoteItem = $this->helper->getTrueLoyalQuoteItemByItemId($item->getId()); + $trueloyalQuoteItem->setIsTrueLoyalFreeProduct(1)->setQuoteItemId($item->getId())->save(); break; } } diff --git a/Controller/LoyaltyRewards/Index.php b/Controller/LoyaltyRewards/Index.php index 056ebbd..c2b91f5 100755 --- a/Controller/LoyaltyRewards/Index.php +++ b/Controller/LoyaltyRewards/Index.php @@ -1,6 +1,10 @@ resultFactory->create(ResultFactory::TYPE_JSON); $jsonConfigLanguage = $this->helper->getConfigLanguage(); - if ($jsonConfigLanguage) { + $preferredLanguage = $this->helper->getPreferredLanguage(); + if ($preferredLanguage) { + $lang = $preferredLanguage; + } elseif ($jsonConfigLanguage) { $lang = $this->store->getLocale() ?? ""; $configLanguage = $this->serializer->unserialize($jsonConfigLanguage); $config = stristr($lang, "_", true); @@ -132,8 +139,8 @@ public function execute() if ($customerId && !$this->helper->isAutoEnrollmentEnabled() ) { $customerData = $this->customerRepository->getById($customerId); $opt_in_attribute = $this->helper->getOptInAttributeCode(); - $zinreloOptedIn = $customerData->getCustomAttribute($opt_in_attribute); - if (!$zinreloOptedIn || !$zinreloOptedIn->getValue()) { + $trueloyalOptedIn = $customerData->getCustomAttribute($opt_in_attribute); + if (!$trueloyalOptedIn || !$trueloyalOptedIn->getValue()) { return $resultJson->setData([]); } } @@ -152,10 +159,21 @@ public function execute() $postcode = $billingAddress['postcode'] ?? ""; $street = isset($billingAddress['street']) ? explode("\n", $billingAddress['street']) : []; $country = isset($billingAddress['country_id']) ? $this->getCountryName($billingAddress['country_id']) : ""; + $storeId = (string)$customer->getStoreId(); + $storeCurrency = $this->helper->getStoreCurrencyCode(); + $memberIdentifierValue = $this->helper->getMemberIdentifierValue(); + } + $customAttributes = []; + $customStoreIdKey = $this->helper->getCustomMemberStoreId(); + $customStoreCurrencyKey = $this->helper->getCustomMemberStoreCurrency(); + if ($customStoreIdKey) { + $customAttributes[$customStoreIdKey] = $storeId ?? ''; + } + if ($customStoreCurrencyKey) { + $customAttributes[$customStoreCurrencyKey] = $storeCurrency ?? ''; } - $payload = [ - 'member_id' => $customerEmail, + 'member_id' => $memberIdentifierValue ?? '', 'sub' => $apiKeyIdentifier, 'email_address' => $customerEmail, 'first_name' => $customerFirstName, @@ -171,11 +189,12 @@ public function execute() 'country' => $country, 'postal_code' => $postcode, ], + 'custom_attributes' => $customAttributes, 'exp' => round(microtime(true) * 1000) ]; $data = $this->jwt->encode($payload, $key, 'HS256'); - if ($customerEmail) { + if ($memberIdentifierValue ?? false) { $this->helper->setCookie($data); $isSetCookies = true; } diff --git a/Cron/RejectRedeemReward.php b/Cron/RejectRedeemReward.php index 9ef0310..e4c16a2 100755 --- a/Cron/RejectRedeemReward.php +++ b/Cron/RejectRedeemReward.php @@ -1,6 +1,6 @@ quoteFactory = $quoteFactory; $this->helper = $helper; $this->timezoneInterface = $timezoneInterface; - $this->zinreloLogger = $zinreloLogger; + $this->trueloyalLogger = $trueloyalLogger; } /** - * Send abandoned cart request to Zinrelo and Reject redeemed point + * Send abandoned cart request to TrueLoyal and Reject redeemed point * * @return void */ @@ -84,8 +84,8 @@ public function execute() if (strtotime($currentTime) >= strtotime($rewardAppliedTime) && $item->getItemsCount()) { /* Send reject reward request to Live API We have to request event customer Quote wise so need to send an API one by one.*/ - $zinreloQuote = $this->helper->getZinreloQuoteByQuoteId($item->getId()); - if ($zinreloQuote->getRedeemRewardDiscount()) { + $trueloyalQuote = $this->helper->getTrueLoyalQuoteByQuoteId($item->getId()); + if ($trueloyalQuote->getRedeemRewardDiscount()) { $this->helper->sendRejectRewardRequest($item); } /*Send Cart abandonment request custom event API*/ @@ -110,12 +110,15 @@ public function execute() $qItem = $this->helper->setFormatedPrice($qItem); $quoteData["items"][] = $qItem; } - $memberId = $item->getCustomer() ? $item->getCustomer()->getEmail() : ""; - $this->sendToZinrelo($memberId, $quoteData, $url, $quoteObj); + $memberId = $this->helper->getMemberIdentifierValueById( + $item->getCustomerId(), + $item->getCustomer() ? $item->getCustomer()->getEmail() : "" + ); + $this->sendToTrueLoyal($memberId, $quoteData, $url, $quoteObj); } } } catch (Exception $e) { - $this->zinreloLogger->addErrorLog($e->getMessage()); + $this->trueloyalLogger->addErrorLog($e->getMessage()); } } } @@ -128,12 +131,12 @@ public function execute() public function getQuoteCollections() { try { - $zinreloQuote = $this->helper->zinreloQuoteFactory->create() + $trueloyalQuote = $this->helper->trueloyalQuoteFactory->create() ->getCollection() ->addFieldToSelect(['quote_id']) ->addFieldToFilter('is_abandoned_cart_sent', ['eq' => '2']); $quoteIds = []; - foreach ($zinreloQuote as $quote) { + foreach ($trueloyalQuote as $quote) { $quoteIds[] = $quote->getQuoteId(); } $quote = $this->quoteFactory->create() @@ -148,7 +151,7 @@ public function getQuoteCollections() $quote->getSelect()->limit(self::COLLECTION_LIMIT); return $quote; } catch (Exception $e) { - $this->zinreloLogger->addErrorLog($e->getMessage()); + $this->trueloyalLogger->addErrorLog($e->getMessage()); } } @@ -168,14 +171,14 @@ public function calculateTimeInterval($quoteTime, $currentTimeZone) } /** - * Send To Zinrelo + * Send To TrueLoyal * * @param mixed $memberId * @param mixed $quoteData * @param mixed $url * @param mixed $object */ - public function sendToZinrelo($memberId, $quoteData, $url, $object) + public function sendToTrueLoyal($memberId, $quoteData, $url, $object) { try { $params = [ @@ -186,11 +189,11 @@ public function sendToZinrelo($memberId, $quoteData, $url, $object) $params = $this->helper->json->serialize($params); /*We have to request event customer Quote wise so need to send an API one by one.*/ $this->helper->request($url, $params, "post"); - $zinreloQuote = $this->helper->getZinreloQuoteByQuoteId($object->getId()); - $zinreloQuote->setIsAbandonedCartSent(1); - $zinreloQuote->save(); + $trueloyalQuote = $this->helper->getTrueLoyalQuoteByQuoteId($object->getId()); + $trueloyalQuote->setIsAbandonedCartSent(1); + $trueloyalQuote->save(); } catch (Exception $e) { - $this->zinreloLogger->addErrorLog($e->getMessage()); + $this->trueloyalLogger->addErrorLog($e->getMessage()); } } } diff --git a/Framework/HTTP/Client/Curl.php b/Framework/HTTP/Client/Curl.php index e8edfef..4627e2c 100755 --- a/Framework/HTTP/Client/Curl.php +++ b/Framework/HTTP/Client/Curl.php @@ -1,6 +1,6 @@ curl = $curl; @@ -282,11 +288,11 @@ public function __construct( $this->cookieManager = $cookieManager; $this->cookieMetadataFactory = $cookieMetadataFactory; $this->sessionManager = $sessionManager; - $this->zinreloEavAttributeFactory = $zinreloEavAttributeFactory; - $this->zinreloQuoteFactory = $zinreloQuoteFactory; - $this->zinreloQuoteItemFactory = $zinreloQuoteItemFactory; - $this->zinreloReviewFactory = $zinreloReviewFactory; - $this->zinreloSalesOrderFactory = $zinreloSalesOrderFactory; + $this->trueloyalEavAttributeFactory = $trueloyalEavAttributeFactory; + $this->trueloyalQuoteFactory = $trueloyalQuoteFactory; + $this->trueloyalQuoteItemFactory = $trueloyalQuoteItemFactory; + $this->trueloyalReviewFactory = $trueloyalReviewFactory; + $this->trueloyalSalesOrderFactory = $trueloyalSalesOrderFactory; $this->quoteRepository = $quoteRepository; $this->eavAttribute = $eavAttribute; parent::__construct($context); @@ -302,6 +308,11 @@ public function getConfigLanguage() return $this->getConfig(self::XML_PATH_LANGUAGES); } + public function getPreferredLanguage(): string + { + return $this->getConfig(self::XML_PATH_PREFERRED_LANGUAGE) ?? ''; + } + /** * Get Config * @@ -332,7 +343,7 @@ public function saveConfig($config_path, $config_value) } /** - * Web Hook Url, which is received from Zinrelo to sent API resquest + * Web Hook Url, which is received from TrueLoyal to sent API resquest * * @return mixed */ @@ -499,8 +510,8 @@ public function isModuleEnabled() if(!$this->isAutoEnrollmentEnabled()) { $customerId = $this->customerSession->create()->getCustomerId(); if ($customerId) { - $zinreloOptedIn = $this->getOptInCustomAttributeValue($customerId); - if (!$zinreloOptedIn) { + $trueloyalOptedIn = $this->getOptInCustomAttributeValue($customerId); + if (!$trueloyalOptedIn) { return false; } } @@ -550,8 +561,8 @@ public function isRewardPointAtPdpEnabled() $isModuleEnable = $this->isModuleEnabled(); $isRewardPointAtPdpEnabled = $this->getConfig(self::XML_PATH_REWARDS_POINTS_AT_PDP) ?? false; $isDashboardHiddenForGuests = $this->isDashboardHiddenForGuests(); - if($isDashboardHiddenForGuests && !$this->getCustomerEmailBySession()) { - return false; + if($isDashboardHiddenForGuests && !$this->getMemberIdentifierValue()) { + return false; } return ($isRewardPointAtPdpEnabled && $isModuleEnable) ?? false; } @@ -576,7 +587,7 @@ public function isPDPAtCartEnabled() $isModuleEnable = $this->isModuleEnabled(); $isRewardPointAtCartEnabled = $this->getConfig(self::XML_PATH_PDP_CART_PAGE) ?? false; $isDashboardHiddenForGuests = $this->isDashboardHiddenForGuests(); - if($isDashboardHiddenForGuests && !$this->getCustomerEmailBySession()) { + if($isDashboardHiddenForGuests && !$this->getMemberIdentifierValue()) { return false; } return ($isRewardPointAtCartEnabled && $isModuleEnable) ?? false; @@ -666,14 +677,14 @@ public function getRewardAppliedRuleLabel($quote): string */ public function getRewardRulesData($quote, $ruleId = "") { - $zinreloQuote = $this->getZinreloQuoteByQuoteId($quote->getId()); - if ($ruleId == "" && $zinreloQuote) { - $ruleId = !$zinreloQuote->isEmpty() ? $zinreloQuote->getRedeemRewardDiscount() : ''; + $trueloyalQuote = $this->getTrueLoyalQuoteByQuoteId($quote->getId()); + if ($ruleId == "" && $trueloyalQuote) { + $ruleId = !$trueloyalQuote->isEmpty() ? $trueloyalQuote->getRedeemRewardDiscount() : ''; } - if (!$zinreloQuote->isEmpty()) { - if ($zinreloQuote->getRewardRulesData()) { - $rewardRules = $this->json->unserialize($zinreloQuote->getRewardRulesData()); + if (!$trueloyalQuote->isEmpty()) { + if ($trueloyalQuote->getRewardRulesData()) { + $rewardRules = $this->json->unserialize($trueloyalQuote->getRewardRulesData()); return $rewardRules[$ruleId] ?? []; } } @@ -687,8 +698,8 @@ public function getRewardRulesData($quote, $ruleId = "") */ public function getRedeemRules() { - $customerEmail = $this->getCustomerEmailBySession(); - $url = $this->getLiveWebHookUrl() . "members/" . $customerEmail . "/rewards"; + $memberId = $this->getMemberIdentifierValue(); + $url = $this->getLiveWebHookUrl() . "members/" . $memberId . "/rewards"; $url = $this->getIdParam($url); $response = $this->request($url, "", "get", "live_api"); $rewardRules = []; @@ -739,6 +750,97 @@ public function getCustomerEmailBySession() return $this->customerSession->create()->getCustomer()->getEmail() ?? ''; } + /** + * Get configured member identifier prefix + * + * @return string + */ + public function getMemberIdentifierPrefix(): string + { + return $this->getConfig(self::XML_PATH_MEMBER_IDENTIFIER_PREFIX) ?? ''; + } + + /** + * Get configured member identifier type ('member_id' or 'member_email') + * + * @return string + */ + public function getMemberIdentifier(): string + { + return $this->getConfig(self::XML_PATH_MEMBER_IDENTIFIER) ?? 'member_email'; + } + + /** + * Get Custom Member Attribute: Store ID + * + * @return string + */ + public function getCustomMemberStoreCode(): string + { + return $this->getConfig(self::XML_PATH_CUSTOM_MEMBER_STORE_CODE) ?? ''; + } + + public function getCustomMemberStoreId(): string + { + return $this->getConfig(self::XML_PATH_CUSTOM_MEMBER_STORE_ID) ?? ''; + } + + /** + * Get Custom Member Attribute: Store Currency + * + * @return string + */ + public function getCustomMemberStoreCurrency(): string + { + return $this->getConfig(self::XML_PATH_CUSTOM_MEMBER_STORE_CURRENCY) ?? ''; + } + + /** + * Get current store currency code + * + * @return string + */ + public function getStoreCurrencyCode(): string + { + return $this->storeManager->getStore()->getCurrentCurrencyCode() ?? ''; + } + + /** + * Get the member identifier value based on the configured type. + * Returns str_pad formatted customer ID for member_id, or customer email for member_email. + * + * @return string + */ + public function getMemberIdentifierValue(): string + { + $prefix = $this->getMemberIdentifierPrefix(); + if ($this->getMemberIdentifier() === 'member_id') { + $value = $this->getFormattedMemberId($prefix); + return $value ?? ''; + } + $value = $this->getCustomerEmailBySession(); + return $value ? $prefix . $value : ''; + } + + /** + * Get Formatted Member ID (ID as string with leading zeros) + * + * @return string + */ + public function getFormattedMemberId($prefix = '') + { + $customerId = $this->customerSession->create()->getCustomerId(); + if (!$customerId) { + return ''; + } + $customerIdStr = (string)$customerId; + if (strlen($prefix) + strlen($customerIdStr) < 3) { + $padLength = max(0, 3 - strlen($prefix)); + return $prefix . str_pad($customerIdStr, $padLength, "0", STR_PAD_LEFT); + } + return $prefix . $customerIdStr; + } + /** * Get Customer Custom Attribute Value * @@ -748,9 +850,9 @@ public function getOptInCustomAttributeValue($customerId) { $customerData = $this->customerRepository->getById($customerId); $opt_in_attribute = $this->getOptInAttributeCode(); - $zinreloOptedIn = $customerData->getCustomAttribute($opt_in_attribute); - if ($zinreloOptedIn) { - return $zinreloOptedIn->getValue(); + $trueloyalOptedIn = $customerData->getCustomAttribute($opt_in_attribute); + if ($trueloyalOptedIn) { + return $trueloyalOptedIn->getValue(); } return null; } @@ -797,7 +899,7 @@ public function getIdParam($url): string } /** - * Request to zinrelo for specific event URL + * Request to trueloyal for specific event URL * * @param mixed $url * @param mixed $params @@ -915,8 +1017,8 @@ public function getDefaultRewardTypes(): array public function getRewardPoints() { try { - $customerEmail = $this->getCustomerEmailBySession(); - $url = $this->getLiveWebHookUrl() . "members/" . $customerEmail; + $memberId = $this->getMemberIdentifierValue(); + $url = $this->getLiveWebHookUrl() . "members/" . $memberId; $url = $this->getIdParam($url); $response = $this->request($url, "", "get", "live_api"); if ($response) { @@ -994,86 +1096,86 @@ public function deleteCookie() ); } - /*Managed to set zinrelo quote, quoteItem, review, sales related data to custom table*/ + /*Managed to set trueloyal quote, quoteItem, review, sales related data to custom table*/ /** - * Get Zinrelo quote specific Data using QuoteId + * Get TrueLoyal quote specific Data using QuoteId * * @param int $quoteId */ - public function getZinreloQuoteByQuoteId($quoteId) + public function getTrueLoyalQuoteByQuoteId($quoteId) { - return $this->zinreloQuoteFactory->create() + return $this->trueloyalQuoteFactory->create() ->getCollection() ->addFieldToFilter('quote_id', $quoteId) ->getFirstItem(); } /** - * Get Zinrelo quote item specific Data using itemId + * Get TrueLoyal quote item specific Data using itemId * * @param int $itemId */ - public function getZinreloQuoteItemByItemId($itemId) + public function getTrueLoyalQuoteItemByItemId($itemId) { - return $this->zinreloQuoteItemFactory->create() + return $this->trueloyalQuoteItemFactory->create() ->getCollection() ->addFieldToFilter('quote_item_id', $itemId) ->getFirstItem(); } /** - * Set zinrelo abandoned cart sent status + * Set trueloyal abandoned cart sent status * * @param int $quoteId * @param int $value */ public function setAbandonedCartSent($quoteId, $value) { - $zinreloQuote = $this->getZinreloQuoteByQuoteId($quoteId); - if (!$zinreloQuote->isEmpty()) { - $zinreloQuote->setIsAbandonedCartSent($value)->save(); + $trueloyalQuote = $this->getTrueLoyalQuoteByQuoteId($quoteId); + if (!$trueloyalQuote->isEmpty()) { + $trueloyalQuote->setIsAbandonedCartSent($value)->save(); } else { - $zinreloQuote->setIsAbandonedCartSent($value); - $zinreloQuote->setQuoteId($quoteId); - $zinreloQuote->save(); + $trueloyalQuote->setIsAbandonedCartSent($value); + $trueloyalQuote->setQuoteId($quoteId); + $trueloyalQuote->save(); } } /** - * Get Zinrelo Order item specific Data using orderID + * Get TrueLoyal Order item specific Data using orderID * * @param int $orderId */ - public function getZinreloOrderByOrderId($orderId) + public function getTrueLoyalOrderByOrderId($orderId) { - return $this->zinreloSalesOrderFactory->create() + return $this->trueloyalSalesOrderFactory->create() ->getCollection() ->addFieldToFilter('order_id', $orderId) ->getFirstItem(); } /** - * Get Zinrelo product review using reviewId + * Get TrueLoyal product review using reviewId * * @param int $reviewId */ - public function getZinreloReviewByReviewId($reviewId) + public function getTrueLoyalReviewByReviewId($reviewId) { - return $this->zinreloReviewFactory->create() + return $this->trueloyalReviewFactory->create() ->getCollection() ->addFieldToFilter('review_id', $reviewId) ->getFirstItem(); } /** - * Get Zinrelo attribute related data using attribute Id + * Get TrueLoyal attribute related data using attribute Id * * @param int $attributeId */ - public function getZinreloAttributeByAttributeId($attributeId) + public function getTrueLoyalAttributeByAttributeId($attributeId) { - return $this->zinreloEavAttributeFactory->create() + return $this->trueloyalEavAttributeFactory->create() ->getCollection() ->addFieldToFilter('attribute_id', $attributeId) ->getFirstItem(); diff --git a/Helper/Data.php b/Helper/Data.php index 3a792d7..4fa0908 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -1,13 +1,13 @@ getZinreloOrderByOrderId($orderId); - $zinreloOrder->setZinreloReward("{}")->setOrderId($orderId); - $zinreloOrder->save(); + $trueloyalOrder = $this->getTrueLoyalOrderByOrderId($orderId); + $trueloyalOrder->setTrueLoyalReward("{}")->setOrderId($orderId); + $trueloyalOrder->save(); } return $order->getIncrementId(); } @@ -37,8 +37,8 @@ public function getRedeemRewardDiscountData($orderId) $order = $this->orderRepository->get($orderId); $quoteID = $order->getQuoteId(); $quote = $this->quoteFactory->create()->load($quoteID); - $zinreloQuote = $this->getZinreloQuoteByQuoteId($quote->getId()); - $redeemReward = $zinreloQuote->getRedeemRewardDiscount(); + $trueloyalQuote = $this->getTrueLoyalQuoteByQuoteId($quote->getId()); + $redeemReward = $trueloyalQuote->getRedeemRewardDiscount(); $rewardData = $this->getRewardRulesData($quote, $redeemReward); $discountAmount = ""; $discountLabel = ""; @@ -63,6 +63,36 @@ public function getRedeemRewardDiscountData($orderId) ]; } + /** + * Get member identifier value from a customer ID and email (for order/customer event context). + * Returns formatted ID when setting is member_id, email otherwise. + * Falls back to email when customer ID is absent (guest). + * + * @param int|null $customerId + * @param string|null $email + * @return string + */ + public function getMemberIdentifierValueById($customerId, $email = null): string + { + $prefix = $this->getMemberIdentifierPrefix() ?? ''; + if ($this->getMemberIdentifier() === 'member_id') { + if ($customerId) { + $customerIdStr = (string)$customerId; + if (strlen($prefix) + strlen($customerIdStr) < 3) { + $padLength = max(0, 3 - strlen($prefix)); + return $prefix . str_pad($customerIdStr, $padLength, "0", STR_PAD_LEFT); + } + return $prefix . $customerIdStr; + } + return $email ? $prefix . $email : ''; + } + if ($email !== null) { + return $email ? $prefix . $email : ''; + } + $resolvedEmail = $customerId ? ($this->getCustomerEmailById($customerId) ?? '') : ''; + return $resolvedEmail ? $prefix . $resolvedEmail : ''; + } + /** * Get Customer Email By Id * @@ -102,7 +132,7 @@ public function getCustomerById($customerId) } /** - * Send Reject reward point API request to Zinrelo when cart gone Abandoned or Redeem Cancel button clicked + * Send Reject reward point API request to TrueLoyal when cart gone Abandoned or Redeem Cancel button clicked * * @param Quote $quote * @return bool @@ -110,24 +140,24 @@ public function getCustomerById($customerId) public function sendRejectRewardRequest($quote) { try { - $zinreloQuote = $this->getZinreloQuoteByQuoteId($quote->getId()); - $redeemReward = $zinreloQuote->getRedeemRewardDiscount(); + $trueloyalQuote = $this->getTrueLoyalQuoteByQuoteId($quote->getId()); + $redeemReward = $trueloyalQuote->getRedeemRewardDiscount(); $rewardData = $this->getRewardRulesData($quote, $redeemReward); if (!empty($rewardData)) { $url = $this->getLiveWebHookUrl() . "transactions/" . $rewardData['id'] . "/reject"; $this->request($url, "", "post", "live_api"); $items = $quote->getAllItems(); foreach ($items as $item) { - $zinreloQuoteItem = $this->getZinreloQuoteItemByItemId($item->getId()); - if ($zinreloQuoteItem->getIsZinreloFreeProduct()) { + $trueloyalQuoteItem = $this->getTrueLoyalQuoteItemByItemId($item->getId()); + if ($trueloyalQuoteItem->getIsTrueLoyalFreeProduct()) { $item->delete(); $item->save(); break; } } - $zinreloQuote->setRedeemRewardDiscount(''); - $zinreloQuote->setRewardRulesData(''); - $zinreloQuote->save(); + $trueloyalQuote->setRedeemRewardDiscount(''); + $trueloyalQuote->setRewardRulesData(''); + $trueloyalQuote->save(); return true; } } catch (Exception $e) { @@ -168,14 +198,14 @@ public function returnResponseData($responseData): array } /** - * Request to Zinrelo for order_create + * Request to TrueLoyal for order_create * * @param string $id * @param string $replacedOrderId * @return bool * @throws NoSuchEntityException */ - public function createZinreloOrder($id, $replacedOrderId) + public function createTrueLoyalOrder($id, $replacedOrderId) { $order = $this->orderRepository->get($id); $couponCode = $this->getCouponCodes($order); @@ -197,9 +227,9 @@ public function createZinreloOrder($id, $replacedOrderId) continue; } $quote = $this->quoteRepository->get($order->getQuoteId()); - $zinreloQuote = $this->getZinreloQuoteByQuoteId($order->getQuoteId()); - if (!empty($zinreloQuote->getRedeemRewardDiscount())) { - $redeemReward = $zinreloQuote->getRedeemRewardDiscount(); + $trueloyalQuote = $this->getTrueLoyalQuoteByQuoteId($order->getQuoteId()); + if (!empty($trueloyalQuote->getRedeemRewardDiscount())) { + $redeemReward = $trueloyalQuote->getRedeemRewardDiscount(); $rewardData = $this->getRewardRulesData($quote, $redeemReward); if ($rewardData) { $discountValue = $rewardData['reward_value']; @@ -288,7 +318,7 @@ public function createZinreloOrder($id, $replacedOrderId) } $orderData['total_qty_ordered'] = (int)$orderData['total_qty_ordered']; $params = [ - "member_id" => $order->getCustomerEmail(), + "member_id" => $this->getMemberIdentifierValueById($order->getCustomerId(), $order->getCustomerEmail()), "activity_id" => "order_create", "data" => $orderData ]; diff --git a/Helper/OrderComplete.php b/Helper/OrderComplete.php index aa51f7b..4d8d700 100755 --- a/Helper/OrderComplete.php +++ b/Helper/OrderComplete.php @@ -1,6 +1,6 @@ helper->getRewardEvents(); $orderId = $order->getEntityId(); - $zinreloOrder = $this->helper->getZinreloOrderByOrderId($orderId); + $trueloyalOrder = $this->helper->getTrueLoyalOrderByOrderId($orderId); if (in_array('order_complete', $event, true) && $order->getState() == 'complete' && - $zinreloOrder->getCompleteRequestSent() == 0 + $trueloyalOrder->getCompleteRequestSent() == 0 ) { $order = $this->orderRepository->get($orderId); $order->getPayment()->setMethodInstance(); @@ -126,7 +126,7 @@ public function getCompletedOrder($order) $orderData['coupon_code'] = $couponCode; $orderData['total_qty_ordered'] = (int)$orderData['total_qty_ordered']; $params = [ - "member_id" => $order->getCustomerEmail(), + "member_id" => $this->helper->getMemberIdentifierValueById($order->getCustomerId(), $order->getCustomerEmail()), "activity_id" => "order_complete", "data" => $orderData ]; @@ -134,9 +134,9 @@ public function getCompletedOrder($order) $params = $this->helper->json->serialize($params); $this->helper->request($url, $params, "post"); try { - /*Set complete request send to Zinrelo*/ - $zinreloOrder->setCompleteRequestSent(1); - $zinreloOrder->save(); + /*Set complete request send to TrueLoyal*/ + $trueloyalOrder->setCompleteRequestSent(1); + $trueloyalOrder->save(); } catch (CouldNotSaveException $e) { $this->helper->addErrorLog($e->getMessage()); } diff --git a/Helper/Reward.php b/Helper/Reward.php index a5a56c7..f6aef7a 100755 --- a/Helper/Reward.php +++ b/Helper/Reward.php @@ -1,6 +1,6 @@ orderRepository->get($orderId); $quoteID = $order->getQuoteId(); $quote = $this->quoteFactory->create()->load($quoteID); - $zinreloQuote = $this->getZinreloQuoteByQuoteId($quote->getId()); - $redeemReward = $zinreloQuote->getRedeemRewardDiscount(); + $trueloyalQuote = $this->getTrueLoyalQuoteByQuoteId($quote->getId()); + $redeemReward = $trueloyalQuote->getRedeemRewardDiscount(); $rewardData = $this->getRewardRulesData($quote, $redeemReward); if (isset($rewardData['rule']) && ($rewardData['rule'] == 'fixed_amount_discount' diff --git a/Logger/Handler.php b/Logger/Handler.php index e3e3813..7934a23 100755 --- a/Logger/Handler.php +++ b/Logger/Handler.php @@ -1,5 +1,5 @@ helper->isModuleEnabled()) { $response[] = [ 'status' => false, - 'message' => __('Zinrelo LoyaltyRewards module is not enabled.') . " " . - __('Enable module from: Stores → Configuration →Zinrelo Loyalty Rewards → Zinrelo Settings.') + 'message' => __('TrueLoyal LoyaltyRewards module is not enabled.') . " " . + __('Enable module from: Stores → Configuration →TrueLoyal Loyalty Rewards → TrueLoyal Settings.') ]; return $response; /*Check header api-key and partner-id with configured auth key*/ @@ -114,10 +114,10 @@ public function createCustomerAttribute() 'adminhtml_customer' ]); $this->attributeResource->save($attribute); - /*Set attribute as Zinrelo*/ + /*Set attribute as TrueLoyal*/ $attributeId = $this->helper->getCustomerAttributeId($customerAttribute['attribute_code']); - $eavAttribute = $this->helper->getZinreloAttributeByAttributeId($attributeId); - $eavAttribute->setAttributeId($attributeId)->setIsZinreloAttribute(1)->save(); + $eavAttribute = $this->helper->getTrueLoyalAttributeByAttributeId($attributeId); + $eavAttribute->setAttributeId($attributeId)->setIsTrueLoyalAttribute(1)->save(); /*End*/ $response[] = [ 'status' => true, diff --git a/Model/Api/CustomerAttributeUpdate.php b/Model/Api/CustomerAttributeUpdate.php index 135b216..3c04e1c 100755 --- a/Model/Api/CustomerAttributeUpdate.php +++ b/Model/Api/CustomerAttributeUpdate.php @@ -1,6 +1,6 @@ helper->isModuleEnabled()) { $response[] = [ 'status' => false, - 'message' => __('Zinrelo LoyaltyRewards module is not enabled.') . " " . - __('Enable module from: Stores → Configuration →Zinrelo Loyalty Rewards → Zinrelo Settings.') + 'message' => __('TrueLoyal LoyaltyRewards module is not enabled.') . " " . + __('Enable module from: Stores → Configuration →TrueLoyal Loyalty Rewards → TrueLoyal Settings.') ]; return $response; /*Check header api-key and partner-id with configured auth key*/ @@ -98,8 +98,8 @@ public function updateCustomerAttributeValue() $attributeValues = $this->eavConfig->getAttribute(Customer::ENTITY, $attribute['attribute_code']); $websiteID = $this->storeManager->getStore()->getWebsiteId(); $customer = $this->customer->create()->setWebsiteId($websiteID)->loadByEmail($attribute['customer_email']); - $eavAttribute = $this->helper->getZinreloAttributeByAttributeId($attributeValues->getAttributeId()); - if ($eavAttribute->getIsZinreloAttribute() && $customer->getData()) { + $eavAttribute = $this->helper->getTrueLoyalAttributeByAttributeId($attributeValues->getAttributeId()); + if ($eavAttribute->getIsTrueLoyalAttribute() && $customer->getData()) { $customerData = $customer->getDataModel(); $customerData->setCustomAttribute($attribute['attribute_code'], $attribute['value']); $customer->updateData($customerData); diff --git a/Model/Carrier/ZinreloShipping.php b/Model/Carrier/TrueLoyalShipping.php similarity index 87% rename from Model/Carrier/ZinreloShipping.php rename to Model/Carrier/TrueLoyalShipping.php index 978aabb..71220c5 100755 --- a/Model/Carrier/ZinreloShipping.php +++ b/Model/Carrier/TrueLoyalShipping.php @@ -1,6 +1,6 @@ $this->getConfigData('name')]; + return ['trueloyalrate' => $this->getConfigData('name')]; } /** - * Zinrelo free shipping + * TrueLoyal free shipping * * @param RateRequest $request * @return bool|DataObject|Result|null @@ -101,9 +101,9 @@ public function collectRates(RateRequest $request) $title = $this->helper->getFreeShippingLabel() ?? $this->getConfigData('title'); $amount = $this->getConfigData('price'); $shippingPrice = $this->getFinalPriceWithHandlingFee($amount); - $method->setCarrier('zinrelorate'); + $method->setCarrier('trueloyalrate'); $method->setCarrierTitle($this->getConfigData('name')); - $method->setMethod('zinrelorate'); + $method->setMethod('trueloyalrate'); $method->setMethodTitle($title); $method->setCost($amount); $method->setPrice($shippingPrice); @@ -111,7 +111,7 @@ public function collectRates(RateRequest $request) return $result; } else { $error = $this->_rateErrorFactory->create(); - $error->setCarrier('zinrelorate'); + $error->setCarrier('trueloyalrate'); $result->append($error); return $result; } diff --git a/Model/ResourceModel/TrueLoyalEavAttribute.php b/Model/ResourceModel/TrueLoyalEavAttribute.php new file mode 100755 index 0000000..0ada8bc --- /dev/null +++ b/Model/ResourceModel/TrueLoyalEavAttribute.php @@ -0,0 +1,23 @@ +_init('trueloyal_eav_attribute', 'id'); + } +} + diff --git a/Model/ResourceModel/TrueLoyalEavAttribute/Collection.php b/Model/ResourceModel/TrueLoyalEavAttribute/Collection.php new file mode 100755 index 0000000..b91a34a --- /dev/null +++ b/Model/ResourceModel/TrueLoyalEavAttribute/Collection.php @@ -0,0 +1,33 @@ +_init( + TrueLoyalEavAttributeModel::class, + TrueLoyalEavAttributeResourceModel::class + ); + } +} + diff --git a/Model/ResourceModel/ZinreloQuote.php b/Model/ResourceModel/TrueLoyalQuote.php similarity index 54% rename from Model/ResourceModel/ZinreloQuote.php rename to Model/ResourceModel/TrueLoyalQuote.php index b852e55..880e6f3 100755 --- a/Model/ResourceModel/ZinreloQuote.php +++ b/Model/ResourceModel/TrueLoyalQuote.php @@ -1,15 +1,15 @@ _init('zinrelo_quote', 'id'); + $this->_init('trueloyal_quote', 'id'); } } diff --git a/Model/ResourceModel/ZinreloReview/Collection.php b/Model/ResourceModel/TrueLoyalQuote/Collection.php similarity index 51% rename from Model/ResourceModel/ZinreloReview/Collection.php rename to Model/ResourceModel/TrueLoyalQuote/Collection.php index 2c4853f..50645cf 100755 --- a/Model/ResourceModel/ZinreloReview/Collection.php +++ b/Model/ResourceModel/TrueLoyalQuote/Collection.php @@ -1,15 +1,15 @@ _init( - ZinreloReviewModel::class, - ZinreloReviewResourceModel::class + TrueLoyalQuoteModel::class, + TrueLoyalQuoteResourceModel::class ); } } diff --git a/Model/ResourceModel/ZinreloEavAttribute.php b/Model/ResourceModel/TrueLoyalQuoteItem.php similarity index 53% rename from Model/ResourceModel/ZinreloEavAttribute.php rename to Model/ResourceModel/TrueLoyalQuoteItem.php index 4e070e3..1751561 100755 --- a/Model/ResourceModel/ZinreloEavAttribute.php +++ b/Model/ResourceModel/TrueLoyalQuoteItem.php @@ -1,15 +1,15 @@ _init('zinrelo_eav_attribute', 'id'); + $this->_init('trueloyal_quote_item', 'id'); } } diff --git a/Model/ResourceModel/TrueLoyalQuoteItem/Collection.php b/Model/ResourceModel/TrueLoyalQuoteItem/Collection.php new file mode 100755 index 0000000..d172847 --- /dev/null +++ b/Model/ResourceModel/TrueLoyalQuoteItem/Collection.php @@ -0,0 +1,33 @@ +_init( + TrueLoyalQuoteItemModel::class, + TrueLoyalQuoteItemResourceModel::class + ); + } +} + diff --git a/Model/ResourceModel/ZinreloQuoteItem.php b/Model/ResourceModel/TrueLoyalReview.php similarity index 54% rename from Model/ResourceModel/ZinreloQuoteItem.php rename to Model/ResourceModel/TrueLoyalReview.php index a0e5c27..0574f09 100755 --- a/Model/ResourceModel/ZinreloQuoteItem.php +++ b/Model/ResourceModel/TrueLoyalReview.php @@ -1,15 +1,15 @@ _init('zinrelo_quote_item', 'id'); + $this->_init('trueloyal_review', 'id'); } } diff --git a/Model/ResourceModel/ZinreloQuoteItem/Collection.php b/Model/ResourceModel/TrueLoyalReview/Collection.php similarity index 50% rename from Model/ResourceModel/ZinreloQuoteItem/Collection.php rename to Model/ResourceModel/TrueLoyalReview/Collection.php index 3faa89a..0653439 100755 --- a/Model/ResourceModel/ZinreloQuoteItem/Collection.php +++ b/Model/ResourceModel/TrueLoyalReview/Collection.php @@ -1,15 +1,15 @@ _init( - ZinreloQuoteItemModel::class, - ZinreloQuoteItemResourceModel::class + TrueLoyalReviewModel::class, + TrueLoyalReviewResourceModel::class ); } } diff --git a/Model/ResourceModel/ZinreloReview.php b/Model/ResourceModel/TrueLoyalSalesOrder.php similarity index 53% rename from Model/ResourceModel/ZinreloReview.php rename to Model/ResourceModel/TrueLoyalSalesOrder.php index 4e3cb36..87ec063 100755 --- a/Model/ResourceModel/ZinreloReview.php +++ b/Model/ResourceModel/TrueLoyalSalesOrder.php @@ -1,15 +1,15 @@ _init('zinrelo_review', 'id'); + $this->_init('trueloyal_sales_order', 'id'); } } diff --git a/Model/ResourceModel/TrueLoyalSalesOrder/Collection.php b/Model/ResourceModel/TrueLoyalSalesOrder/Collection.php new file mode 100755 index 0000000..b0dfb90 --- /dev/null +++ b/Model/ResourceModel/TrueLoyalSalesOrder/Collection.php @@ -0,0 +1,32 @@ +_init( + TrueLoyalSalesOrderModel::class, + TrueLoyalSalesOrderResourceModel::class + ); + } +} + diff --git a/Model/ResourceModel/ZinreloEavAttribute/Collection.php b/Model/ResourceModel/ZinreloEavAttribute/Collection.php deleted file mode 100755 index 1b13001..0000000 --- a/Model/ResourceModel/ZinreloEavAttribute/Collection.php +++ /dev/null @@ -1,33 +0,0 @@ -_init( - ZinreloEavAttributeModel::class, - ZinreloEavAttributeResourceModel::class - ); - } -} - diff --git a/Model/ResourceModel/ZinreloQuote/Collection.php b/Model/ResourceModel/ZinreloQuote/Collection.php deleted file mode 100755 index 3f6d3ed..0000000 --- a/Model/ResourceModel/ZinreloQuote/Collection.php +++ /dev/null @@ -1,33 +0,0 @@ -_init( - ZinreloQuoteModel::class, - ZinreloQuoteResourceModel::class - ); - } -} - diff --git a/Model/ResourceModel/ZinreloSalesOrder.php b/Model/ResourceModel/ZinreloSalesOrder.php deleted file mode 100755 index 32ce56f..0000000 --- a/Model/ResourceModel/ZinreloSalesOrder.php +++ /dev/null @@ -1,23 +0,0 @@ -_init('zinrelo_sales_order', 'id'); - } -} - diff --git a/Model/ResourceModel/ZinreloSalesOrder/Collection.php b/Model/ResourceModel/ZinreloSalesOrder/Collection.php deleted file mode 100755 index ee11303..0000000 --- a/Model/ResourceModel/ZinreloSalesOrder/Collection.php +++ /dev/null @@ -1,32 +0,0 @@ -_init( - ZinreloSalesOrderModel::class, - ZinreloSalesOrderResourceModel::class - ); - } -} - diff --git a/Model/System/Config/EventsSelection.php b/Model/System/Config/EventsSelection.php index 4c9f30c..78ac3d3 100644 --- a/Model/System/Config/EventsSelection.php +++ b/Model/System/Config/EventsSelection.php @@ -1,6 +1,6 @@ self::MEMBER_EMAIL, 'label' => __('Member Email')], + ['value' => self::MEMBER_ID, 'label' => __('Member ID')], + ]; + } +} diff --git a/Model/System/Config/PreferredLanguage.php b/Model/System/Config/PreferredLanguage.php new file mode 100644 index 0000000..41e9539 --- /dev/null +++ b/Model/System/Config/PreferredLanguage.php @@ -0,0 +1,38 @@ + '', 'label' => __(' ')], + ['value' => 'english', 'label' => __('English')], + ['value' => 'arabic', 'label' => __('Arabic')], + ['value' => 'french', 'label' => __('French')], + ['value' => 'german', 'label' => __('German')], + ['value' => 'italian', 'label' => __('Italian')], + ['value' => 'spanish', 'label' => __('Spanish')], + ['value' => 'custom language one', 'label' => __('Custom Language One')], + ['value' => 'custom language two', 'label' => __('Custom Language Two')], + ['value' => 'custom language three', 'label' => __('Custom Language Three')], + ['value' => 'custom language four', 'label' => __('Custom Language Four')], + ['value' => 'custom language five', 'label' => __('Custom Language Five')], + ['value' => 'custom language six', 'label' => __('Custom Language Six')], + ['value' => 'custom language seven', 'label' => __('Custom Language Seven')], + ['value' => 'custom language eight', 'label' => __('Custom Language Eight')], + ['value' => 'custom language nine', 'label' => __('Custom Language Nine')], + ['value' => 'custom language ten', 'label' => __('Custom Language Ten')], + ['value' => 'custom language eleven', 'label' => __('Custom Language Eleven')], + ['value' => 'custom language twelve', 'label' => __('Custom Language Twelve')], + ['value' => 'custom language thirteen', 'label' => __('Custom Language Thirteen')], + ['value' => 'custom language fourteen', 'label' => __('Custom Language Fourteen')], + ]; + } +} diff --git a/Model/Total/CreditMemo/LoyaltyRewardsDiscount.php b/Model/Total/CreditMemo/LoyaltyRewardsDiscount.php index 21fd993..1ffd746 100755 --- a/Model/Total/CreditMemo/LoyaltyRewardsDiscount.php +++ b/Model/Total/CreditMemo/LoyaltyRewardsDiscount.php @@ -1,10 +1,10 @@ addTotalAmount('zinrelo_discount', $totalAmount); - $total->addBaseTotalAmount('zinrelo_discount', $totalAmount); + $total->addTotalAmount('trueloyal_discount', $totalAmount); + $total->addBaseTotalAmount('trueloyal_discount', $totalAmount); $quote->setCustomDiscount($totalAmount); return $this; } @@ -93,7 +93,7 @@ public function fetch(Quote $quote, Total $total) $totalAmount = -($rewardData['points_to_be_redeemed'] / $rewardData['conversion_rate']); } return [ - 'code' => 'zinrelo_discount', + 'code' => 'trueloyal_discount', 'title' => __($this->helper->getRewardAppliedRuleLabel($quote)), 'value' => $totalAmount ]; diff --git a/Model/TrueLoyalEavAttribute.php b/Model/TrueLoyalEavAttribute.php new file mode 100755 index 0000000..ed72f7a --- /dev/null +++ b/Model/TrueLoyalEavAttribute.php @@ -0,0 +1,24 @@ +_init(TrueLoyalEavAttributeResourceModel::class); + } +} + diff --git a/Model/TrueLoyalQuote.php b/Model/TrueLoyalQuote.php new file mode 100755 index 0000000..4f91b2b --- /dev/null +++ b/Model/TrueLoyalQuote.php @@ -0,0 +1,24 @@ +_init(TrueLoyalQuoteResourceModel::class); + } +} + diff --git a/Model/TrueLoyalQuoteItem.php b/Model/TrueLoyalQuoteItem.php new file mode 100755 index 0000000..2adcfc9 --- /dev/null +++ b/Model/TrueLoyalQuoteItem.php @@ -0,0 +1,24 @@ +_init(TrueLoyalQuoteItemResourceModel::class); + } +} + diff --git a/Model/TrueLoyalReview.php b/Model/TrueLoyalReview.php new file mode 100755 index 0000000..9ed05b9 --- /dev/null +++ b/Model/TrueLoyalReview.php @@ -0,0 +1,24 @@ +_init(TrueLoyalReviewResourceModel::class); + } +} + diff --git a/Model/TrueLoyalSalesOrder.php b/Model/TrueLoyalSalesOrder.php new file mode 100755 index 0000000..34983c0 --- /dev/null +++ b/Model/TrueLoyalSalesOrder.php @@ -0,0 +1,24 @@ +_init(TrueLoyalSalesOrderResourceModel::class); + } +} + diff --git a/Model/ZinreloEavAttribute.php b/Model/ZinreloEavAttribute.php deleted file mode 100755 index bb55a94..0000000 --- a/Model/ZinreloEavAttribute.php +++ /dev/null @@ -1,24 +0,0 @@ -_init(ZinreloEavAttributeResourceModel::class); - } -} - diff --git a/Model/ZinreloQuote.php b/Model/ZinreloQuote.php deleted file mode 100755 index 2051e9a..0000000 --- a/Model/ZinreloQuote.php +++ /dev/null @@ -1,24 +0,0 @@ -_init(ZinreloQuoteResourceModel::class); - } -} - diff --git a/Model/ZinreloQuoteItem.php b/Model/ZinreloQuoteItem.php deleted file mode 100755 index f1e4c8f..0000000 --- a/Model/ZinreloQuoteItem.php +++ /dev/null @@ -1,24 +0,0 @@ -_init(ZinreloQuoteItemResourceModel::class); - } -} - diff --git a/Model/ZinreloReview.php b/Model/ZinreloReview.php deleted file mode 100755 index 722936f..0000000 --- a/Model/ZinreloReview.php +++ /dev/null @@ -1,24 +0,0 @@ -_init(ZinreloReviewResourceModel::class); - } -} - diff --git a/Model/ZinreloSalesOrder.php b/Model/ZinreloSalesOrder.php deleted file mode 100755 index f49461d..0000000 --- a/Model/ZinreloSalesOrder.php +++ /dev/null @@ -1,24 +0,0 @@ -_init(ZinreloSalesOrderResourceModel::class); - } -} - diff --git a/Observer/AddFreeProduct.php b/Observer/AddFreeProduct.php index 414e1b5..4912cba 100755 --- a/Observer/AddFreeProduct.php +++ b/Observer/AddFreeProduct.php @@ -1,12 +1,12 @@ getEvent()->getOrder(); $replacedOrderId = $this->helper->getReplacedOrderID($order->getEntityId(), false); - return $this->helper->createZinreloOrder($order->getId(), $replacedOrderId); + return $this->helper->createTrueLoyalOrder($order->getId(), $replacedOrderId); } } } diff --git a/Observer/ConfigSaveObserver.php b/Observer/ConfigSaveObserver.php index ee1a2d9..da164c3 100755 --- a/Observer/ConfigSaveObserver.php +++ b/Observer/ConfigSaveObserver.php @@ -1,11 +1,11 @@ helper = $helper; $this->logger = $logger; diff --git a/Observer/CreateOrderAfter.php b/Observer/CreateOrderAfter.php index 66b91fe..c6ac2c7 100755 --- a/Observer/CreateOrderAfter.php +++ b/Observer/CreateOrderAfter.php @@ -1,6 +1,6 @@ helper->getRewardEvents(); $orderId = $observer->getEvent()->getOrder()->getId(); $order = $this->orderRepository->get($orderId); - $zinreloOrder = $this->helper->getZinreloOrderByOrderId($orderId); + $trueloyalOrder = $this->helper->getTrueLoyalOrderByOrderId($orderId); $replacedOrderId = $order->getIncrementId(); - if (!$zinreloOrder->getZinreloReward()) { + if (!$trueloyalOrder->getTrueLoyalReward()) { if ($order->getQuoteId() !== null) { $quote = $this->quoteRepository->get($order->getQuoteId()); - $zinreloQuote = $this->helper->getZinreloQuoteByQuoteId($order->getQuoteId()); + $trueloyalQuote = $this->helper->getTrueLoyalQuoteByQuoteId($order->getQuoteId()); } - if ($order->getQuoteId() !== null && $zinreloQuote->getRedeemRewardDiscount()) { - $redeemReward = $zinreloQuote->getRedeemRewardDiscount(); + if ($order->getQuoteId() !== null && $trueloyalQuote->getRedeemRewardDiscount()) { + $redeemReward = $trueloyalQuote->getRedeemRewardDiscount(); $rewardData = $this->helper->getRewardRulesData($quote, $redeemReward); $url = $this->helper->getLiveWebHookUrl() . "transactions/" . $rewardData['id'] . "/approve"; $this->helper->request($url, "", "post", "live_api"); - $zinreloOrder->setZinreloReward($this->serializer->serialize($rewardData))->setOrderId($orderId); + $trueloyalOrder->setTrueLoyalReward($this->serializer->serialize($rewardData))->setOrderId($orderId); } else { - $zinreloOrder->setZinreloReward("{}")->setOrderId($orderId); + $trueloyalOrder->setTrueLoyalReward("{}")->setOrderId($orderId); } try { - $zinreloOrder->save(); + $trueloyalOrder->save(); } catch (CouldNotSaveException $e) { $this->helper->addErrorLog($e->getMessage()); } } - $this->helper->createZinreloOrder($orderId, $replacedOrderId); + $this->helper->createTrueLoyalOrder($orderId, $replacedOrderId); } } diff --git a/Observer/Customer/CustomerLogoutObserver.php b/Observer/Customer/CustomerLogoutObserver.php index bb88071..3801b22 100755 --- a/Observer/Customer/CustomerLogoutObserver.php +++ b/Observer/Customer/CustomerLogoutObserver.php @@ -1,9 +1,9 @@ helper->getRewardEvents(); - /*Check the customer_delete event is enabled, if enabled then will send customer_delete event to Zinrelo*/ + /*Check the customer_delete event is enabled, if enabled then will send customer_delete event to TrueLoyal*/ if (in_array('customer_delete', $event)) { $customerId = $observer->getEvent()->getCustomer()->getEntityId(); $customer = $this->customerRepository->getById($customerId); $customerData = $customer->__toArray(); $params = [ - "member_id" => $customer->getEmail(), + "member_id" => $this->helper->getMemberIdentifierValueById($customerId, $customer->getEmail()), "activity_id" => "customer_delete", "data" => $customerData ]; diff --git a/Observer/CustomerSaveAfter.php b/Observer/CustomerSaveAfter.php index fe74232..ba8e136 100755 --- a/Observer/CustomerSaveAfter.php +++ b/Observer/CustomerSaveAfter.php @@ -1,5 +1,5 @@ $customer->getEmail(), + "member_id" => $this->helper->getMemberIdentifierValueById($customerId, $customer->getEmail()), "activity_id" => $activity_id, "data" => $customerData ]; diff --git a/Observer/OrderCancel.php b/Observer/OrderCancel.php index 6d41f3d..38a6651 100755 --- a/Observer/OrderCancel.php +++ b/Observer/OrderCancel.php @@ -1,11 +1,11 @@ $order->getCustomerEmail(), + "member_id" => $this->helper->getMemberIdentifierValueById($order->getCustomerId(), $order->getCustomerEmail()), "activity_id" => "order_cancel", "data" => $orderData ]; diff --git a/Observer/OrderComplete.php b/Observer/OrderComplete.php index 82e024b..f8bbc67 100644 --- a/Observer/OrderComplete.php +++ b/Observer/OrderComplete.php @@ -1,13 +1,13 @@ $order->getCustomerEmail(), + "member_id" => $this->helper->getMemberIdentifierValueById($order->getCustomerId(), $order->getCustomerEmail()), "activity_id" => "order_complete", "data" => $orderData ]; $url = $this->helper->getWebHookUrl(); $params = $this->helper->json->serialize($params); $this->helper->request($url, $params, "post"); - /*Set complete request send to Zinrelo*/ + /*Set complete request send to TrueLoyal*/ $orderModel = $this->orderFactory->create()->load($orderId); $orderModel->setCompleteRequestSent(1); try { diff --git a/Observer/OrderFullInvoicePaid.php b/Observer/OrderFullInvoicePaid.php index 46ab417..7ecedba 100755 --- a/Observer/OrderFullInvoicePaid.php +++ b/Observer/OrderFullInvoicePaid.php @@ -1,6 +1,6 @@ $order->getCustomerEmail(), + "member_id" => $this->helper->getMemberIdentifierValueById($order->getCustomerId(), $order->getCustomerEmail()), "activity_id" => "order_paid", "data" => $invoicesItems ]; diff --git a/Observer/OrderRefund.php b/Observer/OrderRefund.php index e3853c7..446f757 100755 --- a/Observer/OrderRefund.php +++ b/Observer/OrderRefund.php @@ -1,13 +1,13 @@ productMetadata->getVersion(); $event = $this->helper->getRewardEvents(); - /*Check the order_refund event is enabled, if enabled then will send order_refund event to Zinrelo*/ + /*Check the order_refund event is enabled, if enabled then will send order_refund event to TrueLoyal*/ if (in_array('order_refund', $event)) { try { /*This event should call only for Magento version 2.3.0*/ @@ -169,7 +169,7 @@ public function managePartialRefundItems($itemData, $refundData) } /** - * Send request to zinrelo when refund generated + * Send request to trueloyal when refund generated * * @param string $customerEmail * @param string $activityId @@ -179,7 +179,7 @@ public function managePartialRefundItems($itemData, $refundData) public function sendRequest($customerEmail, $activityId, $refundData) { $params = [ - "member_id" => $customerEmail, + "member_id" => $this->helper->getMemberIdentifierValueById(null, $customerEmail), "activity_id" => $activityId, "data" => $refundData ]; diff --git a/Observer/OrderShipped.php b/Observer/OrderShipped.php index a26c323..5fe4063 100755 --- a/Observer/OrderShipped.php +++ b/Observer/OrderShipped.php @@ -1,14 +1,14 @@ getEvent()->getShipment(); $order = $shipment->getOrder(); $this->orderCompleteHelper->getCompletedOrder($order); - /*Check the order_shipped event is enabled, if enabled then will send order_shipped event to Zinrelo*/ + /*Check the order_shipped event is enabled, if enabled then will send order_shipped event to TrueLoyal*/ if (in_array('order_shipped', $event)) { if (!$order->canShip()) { try { @@ -127,7 +127,7 @@ public function execute(Observer $observer) $shipmentItems['order_grand_total'] = (float)$order->getGrandTotal(); $shipmentItems['order_base_grand_total'] = (float)$order->getBaseGrandTotal(); $params = [ - "member_id" => $order->getCustomerEmail(), + "member_id" => $this->helper->getMemberIdentifierValueById($order->getCustomerId(), $order->getCustomerEmail()), "activity_id" => "order_shipped", "data" => $shipmentItems ]; diff --git a/Observer/OrderUpdate.php b/Observer/OrderUpdate.php index fa7d0bf..0c15428 100755 --- a/Observer/OrderUpdate.php +++ b/Observer/OrderUpdate.php @@ -1,6 +1,6 @@ request->getParam('history')['comment'])) { $id = $this->request->getParam('order_id') ?? $this->restRequest->getParam('id'); $event = $this->helper->getRewardEvents(); - /*Check the order_update event is enabled, if enabled then will send order_update event to Zinrelo*/ + /*Check the order_update event is enabled, if enabled then will send order_update event to TrueLoyal*/ if (in_array('order_update', $event)) { $order = $this->orderRepository->get($id); $order->getPayment()->setMethodInstance(); @@ -118,7 +118,7 @@ public function execute(Observer $observer) } $orderData['total_qty_ordered'] = (int) $orderData['total_qty_ordered']; $params = [ - "member_id" => $order->getCustomerEmail(), + "member_id" => $this->helper->getMemberIdentifierValueById($order->getCustomerId(), $order->getCustomerEmail()), "activity_id" => "order_update", "data" => $orderData ]; diff --git a/Observer/ProductReviewSaveAfter.php b/Observer/ProductReviewSaveAfter.php index 7c83c18..7f884f8 100755 --- a/Observer/ProductReviewSaveAfter.php +++ b/Observer/ProductReviewSaveAfter.php @@ -1,5 +1,5 @@ reviewFactory->create()->load($reviewId); $reviewData = $review->toArray(); - $zinreloReview = $this->helper->getZinreloReviewByReviewId($reviewId); + $trueloyalReview = $this->helper->getTrueLoyalReviewByReviewId($reviewId); if ($statusId == Review::STATUS_APPROVED && in_array('review_approved', $event, true)) { $this->sendRequest($reviewData, $productId, $customerId, "review_approved"); } elseif ($statusId == Review::STATUS_PENDING && in_array('review_submitted', $event, true) && - !$zinreloReview->getSubmittedToZinrelo() + !$trueloyalReview->getSubmittedToTrueLoyal() ) { $this->sendRequest($reviewData, $productId, $customerId, "review_submitted"); try { - $zinreloReview->setSubmittedToZinrelo(1)->setReviewId($reviewId)->save(); + $trueloyalReview->setSubmittedToTrueLoyal(1)->setReviewId($reviewId)->save(); } catch (CouldNotSaveException $e) { $this->helper->addErrorLog($e->getMessage()); } @@ -71,7 +71,7 @@ public function execute(Observer $observer) } /** - * Send review created - approved event to Zinrelo + * Send review created - approved event to TrueLoyal * * @param array $reviewData * @param int $productId @@ -89,7 +89,7 @@ public function sendRequest($reviewData, $productId, $customerId, $activityId): $reviewData['product_image_url'] = $productInfo['product_image_url']; $reviewData['category_name'] = $this->helper->getCategoryName($productId); $params = [ - "member_id" => $this->helper->getCustomerEmailById($customerId), + "member_id" => $this->helper->getMemberIdentifierValueById($customerId), "activity_id" => $activityId, "data" => $reviewData ]; diff --git a/Observer/RemoveZinreloDiscount.php b/Observer/RemoveTrueLoyalDiscount.php similarity index 66% rename from Observer/RemoveZinreloDiscount.php rename to Observer/RemoveTrueLoyalDiscount.php index d8769a1..104bab8 100755 --- a/Observer/RemoveZinreloDiscount.php +++ b/Observer/RemoveTrueLoyalDiscount.php @@ -1,15 +1,15 @@ checkoutSession->getQuote(); - $zinreloQuote = $this->helper->getZinreloQuoteByQuoteId($quote->getId()); - if ($zinreloQuote->getIsAbandonedCartSent() || $zinreloQuote->getIsAbandonedCartSent() === null) { + $trueloyalQuote = $this->helper->getTrueLoyalQuoteByQuoteId($quote->getId()); + if ($trueloyalQuote->getIsAbandonedCartSent() || $trueloyalQuote->getIsAbandonedCartSent() === null) { $this->helper->setAbandonedCartSent($quote->getId(), 2); } $cart = $observer->getEvent()->getCart(); if ($cart->getItemsCount() > 1) { return true; - } elseif ($cart->getItemsCount() === 1 && $zinreloQuote->getRedeemRewardDiscount()) { + } elseif ($cart->getItemsCount() === 1 && $trueloyalQuote->getRedeemRewardDiscount()) { foreach ($quote->getAllItems() as $item) { - $zinreloQuoteItem = $this->helper->getZinreloQuoteItemByItemId($item->getId()); - if ($zinreloQuoteItem->getIsZinreloFreeProduct()) { + $trueloyalQuoteItem = $this->helper->getTrueLoyalQuoteItemByItemId($item->getId()); + if ($trueloyalQuoteItem->getIsTrueLoyalFreeProduct()) { $this->helper->sendRejectRewardRequest($quote); $quote->delete(); return true; } } - } elseif ($cart->getItemsCount() === 0 && $zinreloQuote->getRedeemRewardDiscount()) { + } elseif ($cart->getItemsCount() === 0 && $trueloyalQuote->getRedeemRewardDiscount()) { $this->helper->sendRejectRewardRequest($quote); return true; } diff --git a/Plugin/Cart/DisableQty.php b/Plugin/Cart/DisableQty.php index 39c013d..b82a7d4 100755 --- a/Plugin/Cart/DisableQty.php +++ b/Plugin/Cart/DisableQty.php @@ -1,10 +1,10 @@ checkoutSession = $checkoutSession; - $this->zinreloHelper = $zinreloHelper; + $this->trueloyalHelper = $trueloyalHelper; } /** @@ -44,13 +44,13 @@ public function afterGetItemRenderer(AbstractCart $subject, $result) $quote = $this->checkoutSession->getQuote(); $items = $quote->getAllItems(); foreach ($items as $item) { - $zinreloQuoteItem = $this->zinreloHelper->getZinreloQuoteItemByItemId($item->getId()); - if ($zinreloQuoteItem->getIsZinreloFreeProduct()) { + $trueloyalQuoteItem = $this->trueloyalHelper->getTrueLoyalQuoteItemByItemId($item->getId()); + if ($trueloyalQuoteItem->getIsTrueLoyalFreeProduct()) { $isFreeProduct = true; } } if ($isFreeProduct) { - $result->setTemplate('Zinrelo_LoyaltyRewards::cart/item/default.phtml'); + $result->setTemplate('TrueLoyal_LoyaltyRewards::cart/item/default.phtml'); } return $result; } diff --git a/Plugin/Checkout/CustomerData/AroundPluginDefaultItem.php b/Plugin/Checkout/CustomerData/AroundPluginDefaultItem.php index 7bdc97d..5e4c669 100755 --- a/Plugin/Checkout/CustomerData/AroundPluginDefaultItem.php +++ b/Plugin/Checkout/CustomerData/AroundPluginDefaultItem.php @@ -1,10 +1,10 @@ helperData->getFreeProduct(); if ($productId) { - $zinreloQuoteItem = $this->helperData->getZinreloQuoteItemByItemId($item->getId()); - if ($zinreloQuoteItem->getIsZinreloFreeProduct() == 1) { + $trueloyalQuoteItem = $this->helperData->getTrueLoyalQuoteItemByItemId($item->getId()); + if ($trueloyalQuoteItem->getIsTrueLoyalFreeProduct() == 1) { return 0; } } diff --git a/Plugin/Checkout/CustomerData/DefaultItem.php b/Plugin/Checkout/CustomerData/DefaultItem.php index ddcfc13..672ca5c 100644 --- a/Plugin/Checkout/CustomerData/DefaultItem.php +++ b/Plugin/Checkout/CustomerData/DefaultItem.php @@ -1,13 +1,13 @@ helper->getFreeProduct(); if ($productId) { - if ($item->getIsZinreloFreeProduct() == 1) { + if ($item->getIsTrueLoyalFreeProduct() == 1) { return 0; } } diff --git a/Setup/Patch/Data/RewardPoint.php b/Setup/Patch/Data/RewardPoint.php index c0ef2b5..74a63b8 100755 --- a/Setup/Patch/Data/RewardPoint.php +++ b/Setup/Patch/Data/RewardPoint.php @@ -1,6 +1,6 @@ attributeResource->save($attribute); - /*Set attribute as Zinrelo*/ + /*Set attribute as TrueLoyal*/ $attributeId = $this->helper->getCustomerAttributeId($attributeCode); - $eavAttribute = $this->helper->getZinreloAttributeByAttributeId($attributeId); - $eavAttribute->setAttributeId($attributeId)->setIsZinreloAttribute(1)->save(); + $eavAttribute = $this->helper->getTrueLoyalAttributeByAttributeId($attributeId); + $eavAttribute->setAttributeId($attributeId)->setIsTrueLoyalAttribute(1)->save(); } $this->moduleDataSetup->getConnection()->endSetup(); } diff --git a/Setup/Patch/Schema/DefaultTabelUpdate.php b/Setup/Patch/Schema/DefaultTabelUpdate.php index b9ca42b..38591ed 100644 --- a/Setup/Patch/Schema/DefaultTabelUpdate.php +++ b/Setup/Patch/Schema/DefaultTabelUpdate.php @@ -1,6 +1,6 @@ Table::TYPE_SMALLINT, ['unsigned' => true, 'nullable' => false, 'identity' => false, 'default' => "0"], - 'comment' => 'Is Zinrelo Free Product', + 'comment' => 'Is TrueLoyal Free Product', ]; - $connection->addColumn($quoteItemTable, 'is_zinrelo_free_product', $quoteItemColumn); + $connection->addColumn($quoteItemTable, 'is_trueloyal_free_product', $quoteItemColumn); /*customer_eav_attribute*/ $customerEavAttributeTable = $installer->getTable('customer_eav_attribute'); $customerEavAttributeColumn = [ 'type' => Table::TYPE_SMALLINT, ['unsigned' => true, 'nullable' => false, 'identity' => false, 'default' => "0"], - 'comment' => 'Is Zinrelo Attribute', + 'comment' => 'Is TrueLoyal Attribute', ]; - $connection->addColumn($customerEavAttributeTable, 'is_zinrelo_attribute', $customerEavAttributeColumn); + $connection->addColumn($customerEavAttributeTable, 'is_trueloyal_attribute', $customerEavAttributeColumn); /*eav_attribute*/ $eavAttributeTable = $installer->getTable('eav_attribute'); $eavAttributeColumn = [ 'type' => Table::TYPE_SMALLINT, ['unsigned' => true, 'nullable' => false, 'identity' => false, 'default' => "0"], - 'comment' => 'Is Zinrelo Attribute', + 'comment' => 'Is TrueLoyal Attribute', ]; - $connection->addColumn($eavAttributeTable, 'is_zinrelo_attribute', $eavAttributeColumn); + $connection->addColumn($eavAttributeTable, 'is_trueloyal_attribute', $eavAttributeColumn); /*sales_order*/ $salesOrderTable = $installer->getTable('sales_order'); $salesOrderColumns = [ - 'zinrelo_reward' => [ + 'trueloyal_reward' => [ 'type' => Table::TYPE_TEXT, 'nullable' => true, 'comment' => 'Add applied reward rule data', @@ -104,7 +104,7 @@ public function apply() 'complete_request_sent' => [ 'type' => Table::TYPE_SMALLINT, ['unsigned' => true, 'nullable' => false, 'identity' => false, 'default' => "0"], - 'comment' => 'Is order complete request sent to Zinrelo', + 'comment' => 'Is order complete request sent to TrueLoyal', ] ]; foreach ($salesOrderColumns as $name => $definition) { @@ -116,9 +116,9 @@ public function apply() $reviewColumn = [ 'type' => Table::TYPE_SMALLINT, ['unsigned' => true, 'nullable' => false, 'identity' => false, 'default' => "0"], - 'comment' => 'Is product review submitted Zinrelo', + 'comment' => 'Is product review submitted TrueLoyal', ]; - $connection->addColumn($reviewTable, 'submitted_to_zinrelo', $reviewColumn); + $connection->addColumn($reviewTable, 'submitted_to_trueloyal', $reviewColumn); $installer->endSetup(); } diff --git a/ViewModel/ProductView.php b/ViewModel/ProductView.php index c440673..4a613a0 100755 --- a/ViewModel/ProductView.php +++ b/ViewModel/ProductView.php @@ -1,8 +1,8 @@ - + diff --git a/etc/adminhtml/di.xml b/etc/adminhtml/di.xml index 154fb8c..5d38552 100755 --- a/etc/adminhtml/di.xml +++ b/etc/adminhtml/di.xml @@ -1,5 +1,5 @@ - + diff --git a/etc/adminhtml/events.xml b/etc/adminhtml/events.xml index b5a17a8..b8a64a3 100755 --- a/etc/adminhtml/events.xml +++ b/etc/adminhtml/events.xml @@ -2,6 +2,6 @@ - + diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 5ca4244..79cca5e 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -1,13 +1,13 @@ - - + + -
- - zinrelo_loyaltyRewards - Zinrelo_LoyaltyRewards::config +
+ + trueloyal_loyaltyRewards + TrueLoyal_LoyaltyRewards::config @@ -31,7 +31,7 @@ Partner id refer to URL. + To get Partner id refer to URL. ]]> @@ -43,7 +43,7 @@ API Key refer to URL. + To get API Key refer to URL. ]]> @@ -55,7 +55,7 @@ API Key Identifier refer to URL. + To get API Key Identifier refer to URL. ]]> @@ -79,7 +79,7 @@ @@ -151,8 +151,8 @@ - Zinrelo\LoyaltyRewards\Model\System\Config\EventsSelection - Only selected events will be sent to Zinrelo + TrueLoyal\LoyaltyRewards\Model\System\Config\EventsSelection + Only selected events will be sent to TrueLoyal 1 @@ -175,6 +175,49 @@ Value Pass Like : {"fr": "french", "es": "spanish", "hi": "custom language one"} + + + + + + Make sure the Rewards and Activities are translated into this language.
+ This field is optional. If not selected, the preferred language will be the default one in TrueLoyal. + ]]> +
+ TrueLoyal\LoyaltyRewards\Model\System\Config\PreferredLanguage +
+ + + + This field is optional. + + + + + Choose whether to use Member ID or Member Email when sending requests to TrueLoyal. + TrueLoyal\LoyaltyRewards\Model\System\Config\MemberIdentifier + + + + + + + Enter names of TrueLoyal Member Custom Attributes corresponding to Magento data fields below.
+ Note: These custom attributes must be created in TrueLoyal before typing them here. + ]]> +
+ + + + + + + + + +
diff --git a/etc/config.xml b/etc/config.xml index 4952fe4..a2e0e18 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -2,30 +2,30 @@ - + - https://api.zinrelo.com/v2/loyalty/ - https://api.zinrelo.com/v2/loyalty/integrations + https://api.trueloyal.com/v2/loyalty/ + https://api.trueloyal.com/v2/loyalty/integrations 30 Earn {{EARN_POINTS}} points by ordering this product. Earn {{EARN_POINTS}} points by ordering this product. You have {{AVAILABLE_POINTS}} points. Select your reward to redeem. Reward - + - + 1 - Zinrelo\LoyaltyRewards\Model\Carrier\ZinreloShipping + TrueLoyal\LoyaltyRewards\Model\Carrier\TrueLoyalShipping Free Shipping 00.00 Free Shipping - + - + 1 - + diff --git a/etc/crontab.xml b/etc/crontab.xml index 10dc0b4..b7fe3a3 100755 --- a/etc/crontab.xml +++ b/etc/crontab.xml @@ -1,7 +1,7 @@ - + * * * * * diff --git a/etc/csp_whitelist.xml b/etc/csp_whitelist.xml index 3dfa28b..1581cec 100755 --- a/etc/csp_whitelist.xml +++ b/etc/csp_whitelist.xml @@ -4,9 +4,9 @@ - https://app.zinrelo.com - app.zinrelo.com - https://cdn.zinrelo.com/js/all.js + https://app.trueloyal.com + app.trueloyal.com + https://cdn.trueloyal.com/js/all.js diff --git a/etc/db_schema.xml b/etc/db_schema.xml index ee93c71..92e72aa 100755 --- a/etc/db_schema.xml +++ b/etc/db_schema.xml @@ -1,7 +1,7 @@ - +
@@ -9,61 +9,61 @@ -
- +
- + -
- +
- - + + -
- +
- + -
- +
- + diff --git a/etc/db_schema_whitelist.json b/etc/db_schema_whitelist.json index 3725be2..994cdba 100755 --- a/etc/db_schema_whitelist.json +++ b/etc/db_schema_whitelist.json @@ -1,5 +1,5 @@ { - "zinrelo_quote": { + "trueloyal_quote": { "column": { "id": true, "redeem_reward_discount": true, @@ -8,52 +8,52 @@ "quote_id": true }, "constraint": { - "ZINRELO_QUOTE_QUOTE_ID_QUOTE_ENTITY_ID": true, + "TRUELOYAL_QUOTE_QUOTE_ID_QUOTE_ENTITY_ID": true, "PRIMARY": true } }, - "zinrelo_quote_item": { + "trueloyal_quote_item": { "column": { "id": true, - "is_zinrelo_free_product": true, + "is_trueloyal_free_product": true, "quote_item_id": true }, "constraint": { - "ZINRELO_QUOTE_ITEM_QUOTE_ITEM_ID_QUOTE_ITEM_ITEM_ID": true, + "TRUELOYAL_QUOTE_ITEM_QUOTE_ITEM_ID_QUOTE_ITEM_ITEM_ID": true, "PRIMARY": true } }, - "zinrelo_sales_order": { + "trueloyal_sales_order": { "column": { "id": true, - "zinrelo_reward": true, + "trueloyal_reward": true, "complete_request_sent": true, "order_id": true }, "constraint": { - "ZINRELO_SALES_ORDER_ORDER_ID_SALES_ORDER_ENTITY_ID": true, + "TRUELOYAL_SALES_ORDER_ORDER_ID_SALES_ORDER_ENTITY_ID": true, "PRIMARY": true } }, - "zinrelo_review": { + "trueloyal_review": { "column": { "id": true, - "submitted_to_zinrelo": true, + "submitted_to_trueloyal": true, "review_id": true }, "constraint": { - "ZINRELO_REVIEW_REVIEW_ID_REVIEW_REVIEW_ID": true, + "TRUELOYAL_REVIEW_REVIEW_ID_REVIEW_REVIEW_ID": true, "PRIMARY": true } }, - "zinrelo_eav_attribute": { + "trueloyal_eav_attribute": { "column": { "id": true, - "is_zinrelo_attribute": true, + "is_trueloyal_attribute": true, "attribute_id": true }, "constraint": { - "ZINRELO_EAV_ATTRIBUTE_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID": true, + "TRUELOYAL_EAV_ATTRIBUTE_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID": true, "PRIMARY": true } } diff --git a/etc/di.xml b/etc/di.xml index d37fed1..d163c69 100755 --- a/etc/di.xml +++ b/etc/di.xml @@ -1,34 +1,34 @@ - + - + - + - + - + - + - - + + Magento\Framework\Filesystem\Driver\File - + - zinreloLog + trueloyalLog - Zinrelo\LoyaltyRewards\Logger\Handler + TrueLoyal\LoyaltyRewards\Logger\Handler diff --git a/etc/events.xml b/etc/events.xml index 9edea2d..bd809ab 100755 --- a/etc/events.xml +++ b/etc/events.xml @@ -3,64 +3,64 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + - + - + - + - + - - - + + + diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml index d235f3c..6fd9e09 100755 --- a/etc/frontend/routes.xml +++ b/etc/frontend/routes.xml @@ -3,7 +3,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd"> - + diff --git a/etc/module.xml b/etc/module.xml index f8e4383..1f2b12a 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - + diff --git a/etc/sales.xml b/etc/sales.xml index 0c15515..1a05686 100755 --- a/etc/sales.xml +++ b/etc/sales.xml @@ -1,19 +1,19 @@
- +
- +
- +
diff --git a/etc/webapi.xml b/etc/webapi.xml index ae0db27..27c2275 100755 --- a/etc/webapi.xml +++ b/etc/webapi.xml @@ -1,14 +1,14 @@ - + - + diff --git a/etc/webapi_rest/events.xml b/etc/webapi_rest/events.xml index 2eb209e..0c00b21 100755 --- a/etc/webapi_rest/events.xml +++ b/etc/webapi_rest/events.xml @@ -1,6 +1,6 @@ - + diff --git a/i18n/en_US.csv b/i18n/en_US.csv index d0e5b2f..1ee2d70 100755 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -12,8 +12,8 @@ "Attribute value updated successfully.","Attribute value updated successfully." "Attribute value can not be updated.","Attribute value can not be updated." "An invalid request data passed. Kindly check auth header data and try again.","An invalid request data passed. Kindly check auth header data and try again." -"Zinrelo LoyaltyRewards module is not enabled.","Zinrelo LoyaltyRewards module is not enabled." -"Enable module from: Stores → Configuration →Zinrelo Loyalty Rewards → Zinrelo Settings.","Enable module from: Stores → Configuration →Zinrelo Loyalty Rewards → Zinrelo Settings." +"TrueLoyal LoyaltyRewards module is not enabled.","TrueLoyal LoyaltyRewards module is not enabled." +"Enable module from: Stores → Configuration →TrueLoyal Loyalty Rewards → TrueLoyal Settings.","Enable module from: Stores → Configuration →TrueLoyal Loyalty Rewards → TrueLoyal Settings." "Enable the loyalty rewards module","Enable the loyalty rewards module" "Enable reward points text on product pages","Enable reward points text on product pages" "Reward points text on product pages","Reward points text on product pages" diff --git a/registration.php b/registration.php index 23b52f0..3800b39 100755 --- a/registration.php +++ b/registration.php @@ -1,6 +1,6 @@ - + diff --git a/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml b/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml index 89129bf..1b77df7 100755 --- a/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml +++ b/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml @@ -2,7 +2,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> - + diff --git a/view/adminhtml/layout/sales_order_creditmemo_view.xml b/view/adminhtml/layout/sales_order_creditmemo_view.xml index 654a731..cf43640 100755 --- a/view/adminhtml/layout/sales_order_creditmemo_view.xml +++ b/view/adminhtml/layout/sales_order_creditmemo_view.xml @@ -2,7 +2,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> - + diff --git a/view/adminhtml/layout/sales_order_invoice_new.xml b/view/adminhtml/layout/sales_order_invoice_new.xml index 8ece635..09cd3cd 100755 --- a/view/adminhtml/layout/sales_order_invoice_new.xml +++ b/view/adminhtml/layout/sales_order_invoice_new.xml @@ -3,7 +3,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> - + diff --git a/view/adminhtml/layout/sales_order_invoice_updateqty.xml b/view/adminhtml/layout/sales_order_invoice_updateqty.xml index b45ca4e..ff412ff 100755 --- a/view/adminhtml/layout/sales_order_invoice_updateqty.xml +++ b/view/adminhtml/layout/sales_order_invoice_updateqty.xml @@ -2,7 +2,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> - + diff --git a/view/adminhtml/layout/sales_order_invoice_view.xml b/view/adminhtml/layout/sales_order_invoice_view.xml index 14d2a2d..28d37a4 100755 --- a/view/adminhtml/layout/sales_order_invoice_view.xml +++ b/view/adminhtml/layout/sales_order_invoice_view.xml @@ -2,7 +2,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> - + diff --git a/view/adminhtml/layout/sales_order_view.xml b/view/adminhtml/layout/sales_order_view.xml index ebdbdb0..4f278e0 100755 --- a/view/adminhtml/layout/sales_order_view.xml +++ b/view/adminhtml/layout/sales_order_view.xml @@ -3,7 +3,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> - + diff --git a/view/frontend/layout/catalog_product_view.xml b/view/frontend/layout/catalog_product_view.xml index 2abeb00..447b20b 100755 --- a/view/frontend/layout/catalog_product_view.xml +++ b/view/frontend/layout/catalog_product_view.xml @@ -3,10 +3,10 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> - + - Zinrelo\LoyaltyRewards\ViewModel\ProductView + TrueLoyal\LoyaltyRewards\ViewModel\ProductView diff --git a/view/frontend/layout/checkout_cart_index.xml b/view/frontend/layout/checkout_cart_index.xml index 37a0380..276f466 100755 --- a/view/frontend/layout/checkout_cart_index.xml +++ b/view/frontend/layout/checkout_cart_index.xml @@ -2,23 +2,23 @@ - + - Zinrelo\LoyaltyRewards\ViewModel\ProductView + TrueLoyal\LoyaltyRewards\ViewModel\ProductView - @@ -27,8 +27,8 @@ - - Zinrelo_LoyaltyRewards/js/view/checkout/summary/zinrelo-discount + + TrueLoyal_LoyaltyRewards/js/view/checkout/summary/trueloyal-discount 20 diff --git a/view/frontend/layout/checkout_cart_item_renderers.xml b/view/frontend/layout/checkout_cart_item_renderers.xml index 8aee734..3358b9a 100755 --- a/view/frontend/layout/checkout_cart_item_renderers.xml +++ b/view/frontend/layout/checkout_cart_item_renderers.xml @@ -4,18 +4,18 @@ - Zinrelo_LoyaltyRewards::cart/item/renderer/actions/remove.phtml + TrueLoyal_LoyaltyRewards::cart/item/renderer/actions/remove.phtml - Zinrelo_LoyaltyRewards::cart/item/renderer/actions/edit.phtml + TrueLoyal_LoyaltyRewards::cart/item/renderer/actions/edit.phtml - Zinrelo_LoyaltyRewards::cart/item/renderer/actions/move_to_wishlist.phtml + TrueLoyal_LoyaltyRewards::cart/item/renderer/actions/move_to_wishlist.phtml diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml index 9937db8..bd805cf 100755 --- a/view/frontend/layout/checkout_index_index.xml +++ b/view/frontend/layout/checkout_index_index.xml @@ -13,8 +13,8 @@ - - Zinrelo_LoyaltyRewards/js/view/checkout/summary/zinrelo-discount + + TrueLoyal_LoyaltyRewards/js/view/checkout/summary/trueloyal-discount 20 diff --git a/view/frontend/layout/default.xml b/view/frontend/layout/default.xml index 02a6989..4b5c856 100755 --- a/view/frontend/layout/default.xml +++ b/view/frontend/layout/default.xml @@ -2,7 +2,7 @@ - + diff --git a/view/frontend/layout/sales_order_creditmemo.xml b/view/frontend/layout/sales_order_creditmemo.xml index 9918759..304844c 100755 --- a/view/frontend/layout/sales_order_creditmemo.xml +++ b/view/frontend/layout/sales_order_creditmemo.xml @@ -3,7 +3,7 @@ - + diff --git a/view/frontend/layout/sales_order_invoice.xml b/view/frontend/layout/sales_order_invoice.xml index 02f6fd4..43bc31a 100755 --- a/view/frontend/layout/sales_order_invoice.xml +++ b/view/frontend/layout/sales_order_invoice.xml @@ -3,7 +3,7 @@ - + diff --git a/view/frontend/layout/sales_order_print.xml b/view/frontend/layout/sales_order_print.xml index 21fab65..5e86af9 100755 --- a/view/frontend/layout/sales_order_print.xml +++ b/view/frontend/layout/sales_order_print.xml @@ -3,7 +3,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> - + diff --git a/view/frontend/layout/sales_order_printcreditmemo.xml b/view/frontend/layout/sales_order_printcreditmemo.xml index 3a64547..7c30af8 100755 --- a/view/frontend/layout/sales_order_printcreditmemo.xml +++ b/view/frontend/layout/sales_order_printcreditmemo.xml @@ -3,7 +3,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> - + diff --git a/view/frontend/layout/sales_order_printinvoice.xml b/view/frontend/layout/sales_order_printinvoice.xml index 48f36ad..2dab54b 100755 --- a/view/frontend/layout/sales_order_printinvoice.xml +++ b/view/frontend/layout/sales_order_printinvoice.xml @@ -3,7 +3,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> - + diff --git a/view/frontend/layout/sales_order_view.xml b/view/frontend/layout/sales_order_view.xml index e9e5b89..2499950 100755 --- a/view/frontend/layout/sales_order_view.xml +++ b/view/frontend/layout/sales_order_view.xml @@ -3,7 +3,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> - + diff --git a/view/frontend/requirejs-config.js b/view/frontend/requirejs-config.js index d457ec6..cf90d40 100755 --- a/view/frontend/requirejs-config.js +++ b/view/frontend/requirejs-config.js @@ -1,15 +1,15 @@ var config = { map: { "*": { - 'Magento_Checkout/template/minicart/item/default.html': 'Zinrelo_LoyaltyRewards/template/minicart/item/default.html', - priceBox:'Zinrelo_LoyaltyRewards/js/price-box-zinrelo', - cartPoints: 'Zinrelo_LoyaltyRewards/js/cart-points' + 'Magento_Checkout/template/minicart/item/default.html': 'TrueLoyal_LoyaltyRewards/template/minicart/item/default.html', + priceBox:'TrueLoyal_LoyaltyRewards/js/price-box-trueloyal', + cartPoints: 'TrueLoyal_LoyaltyRewards/js/cart-points' } }, config: { mixins: { 'Magento_Checkout/js/model/checkout-data-resolver': { - 'Zinrelo_LoyaltyRewards/js/model/checkout-data-resolver': true + 'TrueLoyal_LoyaltyRewards/js/model/checkout-data-resolver': true } } } diff --git a/view/frontend/templates/cart/RewardList.phtml b/view/frontend/templates/cart/RewardList.phtml index b207aa3..ff13d4f 100755 --- a/view/frontend/templates/cart/RewardList.phtml +++ b/view/frontend/templates/cart/RewardList.phtml @@ -1,15 +1,15 @@ helper->getQuote(); -$zinreloQuote = $this->helper->getZinreloQuoteByQuoteId($quote->getId()); -$redeemReward = $zinreloQuote->getRedeemRewardDiscount(); +$trueloyalQuote = $this->helper->getTrueLoyalQuoteByQuoteId($quote->getId()); +$redeemReward = $trueloyalQuote->getRedeemRewardDiscount(); $rewardData = $block->helper->getRewardRulesData($quote, $redeemReward); -$customerEmail = $block->getCustomerEmail(); +$memberIdentifierValue = $block->helper->getMemberIdentifierValue(); $points = $block->getRewardPoints(); $redeemUrl = $block->getFormAction(); $redeemRules = $block->getRedeemRules(); $isEnabled = $block->helper->isRewardDropDownEnable(); -if (($isEnabled && !empty($customerEmail) && $points != "error" && !empty($redeemRules)) || - ($isEnabled && $zinreloQuote->getRewardRulesData() != "") +if (($isEnabled && !empty($memberIdentifierValue) && $points != "error" && !empty($redeemRules)) || + ($isEnabled && $trueloyalQuote->getRewardRulesData() != "") ) { $points = ($points == "error") ? 0 : $points; $message = $block->helper->getRewardLabelAtCartPage(); @@ -80,8 +80,8 @@ if (($isEnabled && !empty($customerEmail) && $points != "error" && !empty($redee 'mage/cookies' ], function ($, shippingrateservice) { - if ($.mage.cookies.get('zinrelo_shipping_selected')) { - $.mage.cookies.clear('zinrelo_shipping_selected'); + if ($.mage.cookies.get('trueloyal_shipping_selected')) { + $.mage.cookies.clear('trueloyal_shipping_selected'); } diff --git a/view/frontend/templates/cart/item/default.phtml b/view/frontend/templates/cart/item/default.phtml index 9dcf634..26ac9fe 100755 --- a/view/frontend/templates/cart/item/default.phtml +++ b/view/frontend/templates/cart/item/default.phtml @@ -10,10 +10,10 @@ use Magento\Msrp\Helper\Data; /** @var $block Renderer */ -$zinreloHelper = $this->helper(Zinrelo\LoyaltyRewards\Helper\Data ::class); +$trueloyalHelper = $this->helper(TrueLoyal\LoyaltyRewards\Helper\Data ::class); $_item = $block->getItem(); -$zinreloQuoteItem = $zinreloHelper->getZinreloQuoteItemByItemId($_item->getId()); +$trueloyalQuoteItem = $trueloyalHelper->getTrueLoyalQuoteItemByItemId($_item->getId()); $product = $_item->getProduct(); $isVisibleProduct = $product->isVisibleInSiteVisibility(); /** @var Data $helper */ @@ -106,7 +106,7 @@ $canApplyMsrp = $helper->isShowBeforeOrderConfirm($product) && $helper->isMinima
+ + + + diff --git a/view/frontend/web/template/checkout/summary/zinrelo-discount.html b/view/frontend/web/template/checkout/summary/zinrelo-discount.html deleted file mode 100755 index 451724b..0000000 --- a/view/frontend/web/template/checkout/summary/zinrelo-discount.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - -
+ +
- -