diff --git a/Block/Adminhtml/Form/Field/Code.php b/Block/Adminhtml/Form/Field/Code.php index c857d12..c4ff0b2 100644 --- a/Block/Adminhtml/Form/Field/Code.php +++ b/Block/Adminhtml/Form/Field/Code.php @@ -1,14 +1,20 @@ addColumn( @@ -28,20 +34,27 @@ protected function _prepareToRender() $this->_addButtonLabel = __('Add Code'); } + /** + * Get Salesrule renderer + * + * @return \Magento\Framework\View\Element\BlockInterface + * @throws \Magento\Framework\Exception\LocalizedException + */ protected function _getSalesruleRenderer() { if (!$this->_salesruleRenderer) { $this->_salesruleRenderer = $this->getLayout()->createBlock( - '\Rejoiner\Acr\Block\Adminhtml\Form\Field\Salesrule', + \Rejoiner\Acr\Block\Adminhtml\Form\Field\Salesrule::class, 'promo_salesrule', ['data' => ['is_render_to_js_template' => true]] ); - } + } + return $this->_salesruleRenderer; } /** - * @param \Magento\Framework\DataObject $row + * @inheritDoc */ protected function _prepareArrayRow(\Magento\Framework\DataObject $row) { @@ -52,7 +65,5 @@ protected function _prepareArrayRow(\Magento\Framework\DataObject $row) $options[$key] = 'selected="selected"'; } $row->setData('option_extra_attrs', $options); - - return; } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/Form/Field/Custom.php b/Block/Adminhtml/Form/Field/Custom.php index 7db6444..0f052f6 100644 --- a/Block/Adminhtml/Form/Field/Custom.php +++ b/Block/Adminhtml/Form/Field/Custom.php @@ -1,6 +1,6 @@ _addAfter = false; $this->_addButtonLabel = __('Add Rule'); } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/Form/Field/Google.php b/Block/Adminhtml/Form/Field/Google.php index ecd6e36..d608ad3 100644 --- a/Block/Adminhtml/Form/Field/Google.php +++ b/Block/Adminhtml/Form/Field/Google.php @@ -1,6 +1,6 @@ setData('option_extra_attrs', $options); - - return; } /** + * Get Source Renderer + * * @return \Rejoiner\Acr\Block\Adminhtml\Form\Field\Source + * @throws \Magento\Framework\Exception\LocalizedException */ protected function getSourceRenderer() { if (!$this->sourceRenderer) { $this->sourceRenderer = $this->getLayout()->createBlock( - '\Rejoiner\Acr\Block\Adminhtml\Form\Field\Source', + \Rejoiner\Acr\Block\Adminhtml\Form\Field\Source::class, 'google_anal', ['data' => ['is_render_to_js_template' => true]] ); @@ -64,4 +69,4 @@ protected function getSourceRenderer() return $this->sourceRenderer; } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/Form/Field/Salesrule.php b/Block/Adminhtml/Form/Field/Salesrule.php index 7191495..a42b78f 100644 --- a/Block/Adminhtml/Form/Field/Salesrule.php +++ b/Block/Adminhtml/Form/Field/Salesrule.php @@ -1,6 +1,6 @@ setName($value); } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/Form/Field/Source.php b/Block/Adminhtml/Form/Field/Source.php index 07e9007..ef3214d 100644 --- a/Block/Adminhtml/Form/Field/Source.php +++ b/Block/Adminhtml/Form/Field/Source.php @@ -1,6 +1,6 @@ setName($value); } -} \ No newline at end of file +} diff --git a/Block/Base.php b/Block/Base.php index c3eab1f..ba0972e 100644 --- a/Block/Base.php +++ b/Block/Base.php @@ -1,6 +1,6 @@ rejoinerHelper; } - /** * Get cache key informative items * * @return array + * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function getCacheKeyInfo() { @@ -56,5 +59,4 @@ public function getCacheKeyInfo() 'page_type' => $this->rejoinerHelper->getCurrentPageName() ]; } - -} \ No newline at end of file +} diff --git a/Block/Newsletter.php b/Block/Newsletter.php index 5048187..46a23d3 100644 --- a/Block/Newsletter.php +++ b/Block/Newsletter.php @@ -1,6 +1,6 @@ label) { $label = $this->rejoinerHelper->getRejoinerSubscribeCheckboxLabel(); - $this->label = $label ? $label : __(self::DEFAULT_LABEL); + $this->label = $label ?: __(self::DEFAULT_LABEL); } return $this->label; } /** + * IsLabelChanged flag + * * @return bool */ public function isLabelChanged() @@ -82,6 +88,8 @@ public function isLabelChanged() } /** + * GetCssClass + * * @return string */ public function getCssClass() @@ -94,6 +102,8 @@ public function getCssClass() } /** + * GetStyles + * * @return string */ public function getStyles() @@ -106,6 +116,8 @@ public function getStyles() } /** + * GetCheckboxSelectors + * * @return string */ public function getCheckboxSelectors() @@ -114,6 +126,8 @@ public function getCheckboxSelectors() } /** + * HideInCustomerAccount flag + * * @return bool */ public function hideInCustomerAccount() @@ -122,6 +136,8 @@ public function hideInCustomerAccount() } /** + * ShowOnLoginCheckout flag + * * @return bool */ public function showOnLoginCheckout() @@ -130,6 +146,8 @@ public function showOnLoginCheckout() } /** + * ShowOnGuestCheckout flag + * * @return bool */ public function showOnGuestCheckout() @@ -138,6 +156,8 @@ public function showOnGuestCheckout() } /** + * ShouldBeCheckedByDefault flag + * * @return bool */ public function shouldBeCheckedByDefault() @@ -146,16 +166,18 @@ public function shouldBeCheckedByDefault() } /** + * Get config array + * * @return array */ public function getConfig() { return [ - 'label' => $this->getLabel() ? $this->getLabel() : self::DEFAULT_LABEL, + 'label' => $this->getLabel() ?: self::DEFAULT_LABEL, 'show_on_guest_checkout' => (int) $this->showOnGuestCheckout(), 'show_on_login_checkout' => (int) $this->showOnLoginCheckout(), 'checked_by_default' => (int) $this->shouldBeCheckedByDefault(), 'subscribe_guest_checkout' => (int) ($this->showOnGuestCheckout() && $this->shouldBeCheckedByDefault()) ]; } -} \ No newline at end of file +} diff --git a/Block/Product.php b/Block/Product.php index 7f8b7d4..a546724 100644 --- a/Block/Product.php +++ b/Block/Product.php @@ -1,6 +1,6 @@ rejoinerHelper->getImageWidth(); $imageHeight = $this->rejoinerHelper->getImageHeight(); - $imageUrl = $this->imageHelper->init($this->product, 'category_page_grid')->resize($imageWidth, $imageHeight)->getUrl(); + $imageUrl = $this->imageHelper + ->init($this->product, 'category_page_grid') + ->resize($imageWidth, $imageHeight) + ->getUrl(); /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categoriesCollection */ $categoriesCollection = $this->categoryCollectionFactory->create(); @@ -73,7 +79,7 @@ public function getCurrentProductInfo() $categories[] = $category->getName(); } - $productData = [ + return [ 'name' => $this->product->getName(), 'image_url' => $imageUrl, 'price' => (string) $this->rejoinerHelper->convertPriceToCents($this->product->getPrice()), @@ -81,20 +87,16 @@ public function getCurrentProductInfo() 'product_url' => (string) $this->product->getProductUrl(), 'category' => $categories ]; - - return $productData; } /** * Get cache key informative items * * @return array + * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function getCacheKeyInfo() { - - $s =34; - return [ 'BLOCK_TPL', $this->_storeManager->getStore()->getCode(), @@ -104,4 +106,4 @@ public function getCacheKeyInfo() 'product' => $this->product->getId() ]; } -} \ No newline at end of file +} diff --git a/Controller/Addbysku/Index.php b/Controller/Addbysku/Index.php index c0225de..4c8aa78 100644 --- a/Controller/Addbysku/Index.php +++ b/Controller/Addbysku/Index.php @@ -1,6 +1,6 @@ getRequest()->getParams(); @@ -89,9 +94,11 @@ public function execute() $stockItemResource->loadByProductId($stockItem, $productId, $websiteId); $qty = $stockItem->getQty(); try { - if (!$cart->getQuote()->hasProductId($productId) && is_numeric($product['qty']) && $qty > $product['qty']) { + if (!$cart->getQuote()->hasProductId($productId) + && is_numeric($product['qty']) && $qty > $product['qty']) { $cart->addProduct($productBySKU, (int) $product['qty']); - $successMessage .= __('%1 was added to your shopping cart.'.'
', $this->escaper->escapeHtml($productBySKU->getName())); + $successMessage .= __('%1 was added to your shopping cart.' . + '
', $this->escaper->escapeHtml($productBySKU->getName())); } unset($params[$key]); } catch (\Exception $e) { @@ -105,7 +112,7 @@ public function execute() try { $cart->getQuote()->save(); $cart->save(); - } catch (\Exception $e) { + } catch (\Exception $e) { $this->rejoinerHelper->log($e->getMessage()); } @@ -118,4 +125,4 @@ public function execute() $url = $this->_url->getUrl('checkout/cart/', ['updateCart' => true]); $this->getResponse()->setRedirect($url); } -} \ No newline at end of file +} diff --git a/Controller/Addtocart/Index.php b/Controller/Addtocart/Index.php index 3f9bde1..1e29d2a 100755 --- a/Controller/Addtocart/Index.php +++ b/Controller/Addtocart/Index.php @@ -1,6 +1,6 @@ getResponse()->setRedirect($url); return $this->_response; } -} \ No newline at end of file +} diff --git a/Cron/TrackOrderSuccessConversion.php b/Cron/TrackOrderSuccessConversion.php index a71d4ec..b93903f 100644 --- a/Cron/TrackOrderSuccessConversion.php +++ b/Cron/TrackOrderSuccessConversion.php @@ -1,6 +1,6 @@ getOrder(); if ($order->getId()) { - $total = $displayPriceWithTax? $order->getGrandTotal() : $order->getSubtotal(); + $total = $displayPriceWithTax ? $order->getGrandTotal() : $order->getSubtotal(); $result = [ 'cart_value' => $this->rejoinerHelper->convertPriceToCents($total), - 'cart_item_count' => intval($order->getTotalQtyOrdered()), + 'cart_item_count' => (int) $order->getTotalQtyOrdered(), 'customer_order_number' => $order->getIncrementId(), - 'return_url' => $this->_urlBuilder->getUrl('sales/order/view/', ['order_id' => $order->getIncrementId()]) + 'return_url' => $this->_urlBuilder->getUrl( + 'sales/order/view/', + ['order_id' => $order->getIncrementId()] + ) ]; $promo = $order->getCouponCode(); @@ -95,10 +107,13 @@ public function getCartData() $result['promo'] = $promo; } } + return $result; } /** + * Get cart items + * * @return array */ public function getCartItems() @@ -107,6 +122,8 @@ public function getCartItems() } /** + * Get order + * * @return Order */ private function getOrder() @@ -119,4 +136,4 @@ private function getOrder() return $this->order; } -} \ No newline at end of file +} diff --git a/Helper/Customer.php b/Helper/Customer.php index bfd8ca8..78dc739 100644 --- a/Helper/Customer.php +++ b/Helper/Customer.php @@ -1,4 +1,9 @@ $this->getCustomerAge(), 'gender' => $this->getGender(), 'en' => substr($this->localeResolver->getLocale(), 0, 2), 'name' => $this->getCurrentCustomer()->getFirstname(), ]; - - return $customerData; } /** * @return int + * @throws \Exception */ protected function getCustomerAge() { $age = 0; /** @var \Magento\Customer\Model\Customer $customer */ $customer = $this->getCurrentCustomer(); + if ($dob = $customer->getDob()) { $birthdayDate = new \DateTime($dob); $now = new \DateTime(); $interval = $now->diff($birthdayDate); $age = $interval->y; } + return $age; } /** * @return string + * @throws \Magento\Framework\Exception\LocalizedException */ protected function getGender() { @@ -81,11 +88,11 @@ protected function getGender() ->getSource() ->getOptionText($this->getCurrentCustomer()->getData('gender')); - return $genderText? $genderText : ''; + return $genderText ?: ''; } /** - * @return string + * @return array */ public function getCustomerEmail() { @@ -99,4 +106,4 @@ public function getCurrentCustomer() { return $this->currentCustomer; } -} \ No newline at end of file +} diff --git a/Helper/Data.php b/Helper/Data.php index ea5d32e..a7c9754 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -1,11 +1,11 @@ scopeConfig->getValue('checkout/rejoiner_acr/google_attributes', ScopeInterface::SCOPE_STORE)) { + if ($googleAnalitics = $this->scopeConfig->getValue( + 'checkout/rejoiner_acr/google_attributes', + ScopeInterface::SCOPE_STORE + )) { foreach (unserialize($googleAnalitics) as $attr) { if ($attr['attr_name'] && $attr['value']) { $result[$attr['attr_name']] = $attr['value']; @@ -234,7 +242,10 @@ public function returnGoogleAttributes() public function returnCustomAttributes() { $result = []; - if ($customAttr = $this->scopeConfig->getValue('checkout/rejoiner_acr/custom_attributes', ScopeInterface::SCOPE_STORE)) { + if ($customAttr = $this->scopeConfig->getValue( + 'checkout/rejoiner_acr/custom_attributes', + ScopeInterface::SCOPE_STORE + )) { foreach (unserialize($customAttr) as $attr) { if ($attr['attr_name'] && $attr['value']) { $result[$attr['attr_name']] = $attr['value']; @@ -251,7 +262,10 @@ public function returnCustomAttributes() public function getExtraCodes() { $result = []; - if ($extraCodes = $this->scopeConfig->getValue('checkout/rejoiner_acr/extra_codes', ScopeInterface::SCOPE_STORE)) { + if ($extraCodes = $this->scopeConfig->getValue( + 'checkout/rejoiner_acr/extra_codes', + ScopeInterface::SCOPE_STORE + )) { foreach (unserialize($extraCodes) as $extraCode) { if ($extraCode['promo_param'] && $extraCode['promo_salesrule']) { $result[$extraCode['promo_param']] = $extraCode['promo_salesrule']; @@ -263,12 +277,17 @@ public function getExtraCodes() } /** + * @param $rule_id + * @param string $param * @return string + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function generateCouponCode($rule_id, $param = 'promo') { $quote = $this->checkoutSession->getQuote(); $quotePromo = $quote->getPromo(); + $couponCode = ''; if ($quotePromo) { $codes = unserialize($quotePromo); @@ -316,7 +335,7 @@ public function getDomain() { $domain = trim($this->scopeConfig->getValue(self::XML_PATH_REJOINER_DOMAIN, ScopeInterface::SCOPE_STORE)); - return ($domain[0] == '.') ? $domain : '.' . $domain; + return ($domain[0] === '.') ? $domain : '.' . $domain; } /** @@ -335,7 +354,7 @@ public function getRejoinerVersion() $siteId = $this->getRejoinerSiteId(); $siteIdLength = strlen($siteId); - if ($siteIdLength == self::REJOINER2_SITE_ID_LENGTH) { + if ($siteIdLength === self::REJOINER2_SITE_ID_LENGTH) { return self::REJOINER_VERSION_2; } @@ -368,7 +387,10 @@ public function getTrackNumberEnabled() */ public function getTrackPriceWithTax() { - return (int) $this->scopeConfig->getValue(self::XML_PATH_REJOINER_TRACK_PRICE_WITH_TAX, ScopeInterface::SCOPE_STORE); + return (int) $this->scopeConfig->getValue( + self::XML_PATH_REJOINER_TRACK_PRICE_WITH_TAX, + ScopeInterface::SCOPE_STORE + ); } /** @@ -543,12 +565,13 @@ protected function isDebugEnabled() return (bool) $this->scopeConfig->getValue(self::XML_PATH_REJOINER_DEBUG_ENABLED, ScopeInterface::SCOPE_STORE); } - /** * If shopping cart information should be sent to Rejoiner service on current page + * * @return int */ - public function getShoppingCartDataOnThisPage() { + public function getShoppingCartDataOnThisPage() + { return (int) in_array( $this->getCurrentPageName(), [ @@ -594,20 +617,25 @@ public function sendInfoToRejoiner(\Magento\Sales\Model\Order $orderModel) if ($passNewCustomers && $listId) { $email = $orderModel->getCustomerEmail(); $customerName = $orderModel->getBillingAddress()->getFirstname(); - $this->addToList($listId, $email, $customerName); + $customerLastName = $orderModel->getBillingAddress()->getLastname(); + $this->addToList($listId, $email, $customerName, $customerLastName); } } catch (\Exception $e) { } } /** + * Subscribe customer + * * @param string $email - * @param string $customerName + * @param string|null $customerName + * @param string|null $customerLastName * @return $this + * @throws \Exception */ - public function subscribe($email, $customerName = null) + public function subscribe($email, $customerName = null, $customerLastName = null) { - $this->addToList($this->getRejoinerMarketingListID(), $email, $customerName); + $this->addToList($this->getRejoinerMarketingListID(), $email, $customerName, $customerLastName); return $this; } @@ -615,6 +643,7 @@ public function subscribe($email, $customerName = null) /** * @param string $email * @return $this + * @throws \Exception */ public function unSubscribe($email) { @@ -642,12 +671,16 @@ private function convert($email) } /** - * @param $listId - * @param $email - * @param string $customerName + * Add customer to the list + * + * @param string $listId + * @param string $email + * @param string|null $customerName + * @param string|null $customerLastName * @return $this + * @throws \Exception */ - private function addToList($listId, $email, $customerName = null) + private function addToList($listId, $email, $customerName = null, $customerLastName = null) { if (!$listId) { return $this; @@ -662,6 +695,10 @@ private function addToList($listId, $email, $customerName = null) $data['first_name'] = $customerName; } + if ($customerLastName) { + $data['last_name'] = $customerLastName; + } + $apiAddToListPath = $this->getRejoinerApiAddToListPath($listId); $client = $this->prepareClient($apiAddToListPath, $data); $this->sendRequest($client); @@ -691,7 +728,7 @@ private function prepareClient($path, array $data) $requestPath = sprintf($path, $siteId); $authorization = sprintf('Rejoiner %s', $apiKey); - if ($rejoinerVersion == self::REJOINER_VERSION_1) { + if ($rejoinerVersion === self::REJOINER_VERSION_1) { $apiSecret = utf8_encode($this->scopeConfig->getValue(self::XML_PATH_REJOINER_API_SECRET)); if (!$apiSecret) { @@ -731,6 +768,7 @@ private function sendRequest(\Magento\Framework\HTTP\ZendClient $client) switch ($responseCode) { case '200': + case '201': $this->log($responseCode . ': Everything is alright.'); break; case '400': @@ -758,7 +796,6 @@ private function sendRequest(\Magento\Framework\HTTP\ZendClient $client) return $responseCode; } - /** * @param \Magento\Catalog\Model\Product $product * @param $categoriesArray diff --git a/Helper/ItemsData.php b/Helper/ItemsData.php index 21359af..56f7eae 100644 --- a/Helper/ItemsData.php +++ b/Helper/ItemsData.php @@ -1,4 +1,9 @@ getProduct(); - if ($product->getTypeId() == Configurable::TYPE_CODE) { + if ($product->getTypeId() === Configurable::TYPE_CODE) { $childProduct = $this->getChildProduct($item, $order); if ($this->useParentThumbnail() - || !($childProduct->getThumbnail() && $childProduct->getThumbnail() != 'no_selection') + || !($childProduct->getThumbnail() && $childProduct->getThumbnail() !== 'no_selection') ) { return $product; } @@ -136,23 +147,33 @@ private function getProductForThumbnail($item, $order = null) } /** + * Get child product + * * @param QuoteItem|OrderItem $item * @param null|Order $order * @return Product */ private function getChildProduct($item, $order = null) { - // it is faster to iterate over ordered items then to do some magic or load simple products accidentally on our own + /** + * it is faster to iterate over ordered items then to do some magic + * or load simple products accidentally on our own + */ if ($order) { $parentItemId = $item->getId(); + /** @var OrderItem $orderItem */ foreach ($order->getAllItems() as $orderItem) { - if ($orderItem->getParentItemId() == $parentItemId) { + if ($orderItem->getParentItemId() === $parentItemId) { $product = $orderItem->getProduct(); break; } } - // actually, this should not ever happen because configurable products is always present in cart with its' simple child + + /** + * actually, this should not ever happen because configurable products + * is always present in cart with its' simple child + */ if (!isset($product)) { $product = $item->getProduct(); } @@ -167,11 +188,13 @@ private function getChildProduct($item, $order = null) } /** + * UseParentThumbnail flag + * * @return bool */ private function useParentThumbnail() { $thumbnailSource = $this->scopeConfig->getValue(ConfigurableRenderer::CONFIG_THUMBNAIL_SOURCE); - return $thumbnailSource == ThumbnailSource::OPTION_USE_PARENT_IMAGE; + return $thumbnailSource === ThumbnailSource::OPTION_USE_PARENT_IMAGE; } } diff --git a/Helper/Serializer.php b/Helper/Serializer.php index da1f501..58bb493 100644 --- a/Helper/Serializer.php +++ b/Helper/Serializer.php @@ -1,6 +1,6 @@ getQuote(); if ($quote->getAllVisibleItems()) { - $total = $displayPriceWithTax? $quote->getGrandTotal() : $quote->getSubtotal(); + $total = $displayPriceWithTax ? $quote->getGrandTotal() : $quote->getSubtotal(); $result = [ - 'total_items_count' => (string) intval($quote->getItemsQty()), + 'total_items_count' => (string) (int) $quote->getItemsQty(), 'cart_value' => (string) $this->rejoinerHelper->convertPriceToCents($total), 'return_url' => (string) $this->rejoinerHelper->getRestoreUrl() ]; + if ($this->rejoinerHelper->getIsEnabledCouponCodeGeneration()) { $ruleId = $this->rejoinerHelper->getCouponCodeRuleId(); + if ($ruleId) { $result['promo'] = $this->rejoinerHelper->generateCouponCode($ruleId); } $extraCodes = $this->rejoinerHelper->getExtraCodes(); + if ($extraCodes) { foreach ($extraCodes as $param => $rule_id) { if ($param && $rule_id) { @@ -110,9 +117,11 @@ public function getCartData() /** * @return \Magento\Quote\Model\Quote + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException */ protected function getQuote() { return $this->checkoutSession->getQuote(); } -} \ No newline at end of file +} diff --git a/Logger/Handler.php b/Logger/Handler.php index 0842883..dee0dc3 100644 --- a/Logger/Handler.php +++ b/Logger/Handler.php @@ -1,6 +1,6 @@ _init(\Rejoiner\Acr\Model\ResourceModel\Acr::class); } -} \ No newline at end of file +} diff --git a/Model/ResourceModel/Acr.php b/Model/ResourceModel/Acr.php index d1a507a..fd2e7a5 100644 --- a/Model/ResourceModel/Acr.php +++ b/Model/ResourceModel/Acr.php @@ -1,6 +1,6 @@ _init('rejoiner_acr_success_orders', 'entity_id'); } -} \ No newline at end of file +} diff --git a/Model/ResourceModel/Acr/Collection.php b/Model/ResourceModel/Acr/Collection.php index 9c0be28..a8a3a71 100644 --- a/Model/ResourceModel/Acr/Collection.php +++ b/Model/ResourceModel/Acr/Collection.php @@ -1,6 +1,6 @@ _init(\Rejoiner\Acr\Model\Acr::class, \Rejoiner\Acr\Model\ResourceModel\Acr::class); } -} \ No newline at end of file +} diff --git a/Model/System/Config/Backend/Attributes.php b/Model/System/Config/Backend/Attributes.php index f4a44f5..7f7d9df 100644 --- a/Model/System/Config/Backend/Attributes.php +++ b/Model/System/Config/Backend/Attributes.php @@ -1,6 +1,6 @@ getValue(); $value = is_array($value) ? $value : []; foreach ($value as $key => $data) { - if (!$data ) { + if (!$data) { unset($value[$key]); } } $this->setValue(serialize($value)); + return $this; } @@ -34,11 +35,14 @@ public function beforeSave() */ protected function _afterLoad() { - $value = $this->getValue(); - $value = unserialize($value); + if ($value = $this->getValue()) { + $value = unserialize($value, ['allowed_classes' => false]); + } + if (is_array($value)) { $this->setValue($value); } + return $this; } -} \ No newline at end of file +} diff --git a/Model/System/Config/Source/Salesrule.php b/Model/System/Config/Source/Salesrule.php index ca37449..d97c338 100644 --- a/Model/System/Config/Source/Salesrule.php +++ b/Model/System/Config/Source/Salesrule.php @@ -1,6 +1,6 @@ getEvent()->getData('order_ids'); /** @var \Magento\Sales\Model\Order $order */ $order = $this->orderFactory->create()->load($lastOrderId[0]); + if (!$order->getId()) { return $this; } + if ($this->rejoinerHelper->getShouldBeProcessedByCron()) { /** @var \Rejoiner\Acr\Model\Acr $acrModel */ $acrModel = $this->acrFactory->create(); - $acrModel->setOrderId($order->getId())->setCreatedAt(date('Y-m-d H:i:s', $this->timezone->scopeTimeStamp())); + $acrModel->setOrderId($order->getId())->setCreatedAt( + date('Y-m-d H:i:s', $this->timezone->scopeTimeStamp()) + ); $acrModel->save(); } else { $this->rejoinerHelper->sendInfoToRejoiner($order); @@ -61,4 +67,4 @@ public function execute(\Magento\Framework\Event\Observer $observer) return $this; } -} \ No newline at end of file +} diff --git a/Observer/ControllerActionPredispatch.php b/Observer/ControllerActionPredispatch.php index dc9ec63..927cd5d 100644 --- a/Observer/ControllerActionPredispatch.php +++ b/Observer/ControllerActionPredispatch.php @@ -1,6 +1,6 @@ getData('request'); - if ($request->getModuleName() == 'checkout' - && $request->getControllerName() == 'cart' - && $request->getActionName() == 'index' + + if ($request->getModuleName() === 'checkout' + && $request->getControllerName() === 'cart' + && $request->getActionName() === 'index' && $request->getParam('updateCart') ) { $cookiesManager = $this->_cookieManager; @@ -47,9 +52,13 @@ public function execute(\Magento\Framework\Event\Observer $observer) $sectionDataIds = json_decode($encodedCookie); if ($sectionDataIds && isset($sectionDataIds->cart)) { $sectionDataIds->cart += 1000; - $cookiesManager->setPublicCookie('section_data_ids', json_encode($sectionDataIds), $publicCookieMetadata); + $cookiesManager->setPublicCookie( + 'section_data_ids', + json_encode($sectionDataIds), + $publicCookieMetadata + ); } } } } -} \ No newline at end of file +} diff --git a/Observer/CustomerLoginObserver.php b/Observer/CustomerLoginObserver.php index 870a3b4..b10e14f 100644 --- a/Observer/CustomerLoginObserver.php +++ b/Observer/CustomerLoginObserver.php @@ -1,6 +1,6 @@ customerSession->isLoggedIn() && $this->rejoinerHelper->getRejoinerSubscribeLoginCheckout() && $this->isSubscribe()) { + if ($this->customerSession->isLoggedIn() + && $this->rejoinerHelper->getRejoinerSubscribeLoginCheckout() + && $this->isSubscribe()) { /** @var \Magento\Customer\Model\Customer $customer */ $customer = $observer->getData('customer'); /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ @@ -60,20 +61,23 @@ public function execute(\Magento\Framework\Event\Observer $observer) } /** + * IsSubscribe flag + * * @return bool */ protected function isSubscribe() { - $subscribe = false; if ($this->request->getParam('is_subscribed', false)) { $subscribe = true; } else { try { $credentials = $this->jsonHelper->jsonDecode($this->request->getContent()); $subscribe = isset($credentials['rejoiner_subscription']) && $credentials['rejoiner_subscription']; - } catch (\Exception $e) {} + } catch (\Exception $e) { + $subscribe = false; + } } return $subscribe; } -} \ No newline at end of file +} diff --git a/Observer/OrderSaveAfter.php b/Observer/OrderSaveAfter.php index 052e148..7463ace 100644 --- a/Observer/OrderSaveAfter.php +++ b/Observer/OrderSaveAfter.php @@ -1,6 +1,6 @@ getData('order'); + /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ $subscriber = $this->subscriberFactory->create(); $subscriber->subscribe($order->getCustomerEmail()); - } catch (\Exception $e) {} + } catch (\Exception $e) { + } + $this->session->unsRejoinerSubscribe(); } } -} \ No newline at end of file +} diff --git a/Observer/SalesQuoteRemoveItem.php b/Observer/SalesQuoteRemoveItem.php index f5a95c2..5e12953 100644 --- a/Observer/SalesQuoteRemoveItem.php +++ b/Observer/SalesQuoteRemoveItem.php @@ -1,6 +1,6 @@ _sessionManager->setData(\Rejoiner\Acr\Helper\Data::REMOVED_CART_ITEM_SKU_VARIABLE, $removedItem); } } -} \ No newline at end of file +} diff --git a/Plugin/Checkout/Model/ShippingInformationManagementPlugin.php b/Plugin/Checkout/Model/ShippingInformationManagementPlugin.php index b4bd33a..4f07ad3 100644 --- a/Plugin/Checkout/Model/ShippingInformationManagementPlugin.php +++ b/Plugin/Checkout/Model/ShippingInformationManagementPlugin.php @@ -1,6 +1,6 @@ getStatus() == Subscriber::STATUS_SUBSCRIBED) { $customerName = ''; + $customerLastName = ''; + if ($customerId = $subscriber->getCustomerId()) { /** @var \Magento\Customer\Model\Customer $customer */ $customer = $this->customerRegistry->retrieve($customerId); - $customerName = $customer->getData('firstname') ? $customer->getData('firstname') : ''; + $customerName = $customer->getData('firstname') ?: ''; + $customerLastName = $customer->getData('lastname') ?: ''; } - $this->rejoinerHelper->subscribe($subscriber->getEmail(), $customerName); + $this->rejoinerHelper->subscribe($subscriber->getEmail(), $customerName, $customerLastName); $subscriber->setData('added_to_rejoiner', RejoinerHelper::STATUS_SUBSCRIBED); } } catch (\Exception $e) { @@ -54,6 +59,8 @@ public function beforeSave(Subscriber $subscriber) } /** + * IsStatusChanged flag + * * @param Subscriber $subscriber * @return bool */ diff --git a/Plugin/Sales/Block/Adminhtml/Create/TotalsPlugin.php b/Plugin/Sales/Block/Adminhtml/Create/TotalsPlugin.php index 0a7e858..49c51eb 100644 --- a/Plugin/Sales/Block/Adminhtml/Create/TotalsPlugin.php +++ b/Plugin/Sales/Block/Adminhtml/Create/TotalsPlugin.php @@ -1,6 +1,6 @@ getChildHtml('rejoiner_subscribe') . $html; } -} \ No newline at end of file +} diff --git a/Plugin/Sales/Model/AdminOrder/CreatePlugin.php b/Plugin/Sales/Model/AdminOrder/CreatePlugin.php index d8debfd..dd27f61 100644 --- a/Plugin/Sales/Model/AdminOrder/CreatePlugin.php +++ b/Plugin/Sales/Model/AdminOrder/CreatePlugin.php @@ -1,6 +1,6 @@ subscriberFactory->create(); $subscriber->subscribe($email); - } catch (\Exception $e) {} + } catch (\Exception $e) { + } } return $order; } -} \ No newline at end of file +} diff --git a/Setup/InstallSchema.php b/Setup/InstallSchema.php index c231b29..2370127 100644 --- a/Setup/InstallSchema.php +++ b/Setup/InstallSchema.php @@ -1,6 +1,6 @@ 'Promo' ] ); - $installer->endSetup(); + $installer->endSetup(); } } diff --git a/Setup/UpgradeSchema.php b/Setup/UpgradeSchema.php index 9da989d..880860b 100644 --- a/Setup/UpgradeSchema.php +++ b/Setup/UpgradeSchema.php @@ -1,6 +1,6 @@ =100.0.0", - "magento/module-catalog": ">=100.0.0", - "magento/module-customer": ">=100.0.0", - "magento/module-newsletter": ">=100.0.0" - }, - "type": "magento2-module", - "version": "2.5.7", - "license": [ - "OSL-3.0", - "AFL-3.0" - ], - "autoload": { - "files": [ "registration.php" ], - "psr-4": { - "Rejoiner\\Acr\\": "" + "name": "rejoiner/module-acr", + "description": "Rejoiner extension for Magento 2", + "require": { + "magento/module-checkout": ">=100.0.0", + "magento/module-catalog": ">=100.0.0", + "magento/module-customer": ">=100.0.0", + "magento/module-newsletter": ">=100.0.0", + "ext-json": "*" + }, + "type": "magento2-module", + "version": "2.5.8", + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "autoload": { + "files": [ "registration.php" ], + "psr-4": { + "Rejoiner\\Acr\\": "" + } } - } } diff --git a/etc/adminhtml/di.xml b/etc/adminhtml/di.xml index 0af25f0..e30cb95 100644 --- a/etc/adminhtml/di.xml +++ b/etc/adminhtml/di.xml @@ -1,10 +1,9 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> + @@ -13,4 +12,4 @@ - \ No newline at end of file + diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 8ebcc7f..8ab0c45 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -1,10 +1,9 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> +
@@ -288,4 +287,4 @@
-
\ No newline at end of file + diff --git a/etc/config.xml b/etc/config.xml index 6caa884..9e8bcec 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -1,10 +1,9 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> + @@ -20,4 +19,4 @@ - \ No newline at end of file + diff --git a/etc/crontab.xml b/etc/crontab.xml index e1e1452..5530f66 100644 --- a/etc/crontab.xml +++ b/etc/crontab.xml @@ -1,14 +1,13 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> + */10 * * * * - \ No newline at end of file + diff --git a/etc/di.xml b/etc/di.xml index 7612737..d8e7487 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -1,10 +1,9 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> + @@ -40,4 +39,4 @@ - \ No newline at end of file + diff --git a/etc/events.xml b/etc/events.xml index ce79e4a..f86e60b 100644 --- a/etc/events.xml +++ b/etc/events.xml @@ -1,10 +1,9 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> + diff --git a/etc/extension_attributes.xml b/etc/extension_attributes.xml index b930472..a1ceaaf 100644 --- a/etc/extension_attributes.xml +++ b/etc/extension_attributes.xml @@ -1,8 +1,12 @@ + - \ No newline at end of file + diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index 4379b6e..259d4d2 100644 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -1,10 +1,8 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> @@ -22,4 +20,4 @@ - \ No newline at end of file + diff --git a/etc/frontend/events.xml b/etc/frontend/events.xml index de07237..ef1602c 100644 --- a/etc/frontend/events.xml +++ b/etc/frontend/events.xml @@ -1,10 +1,8 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml index db73bc9..07b6483 100755 --- a/etc/frontend/routes.xml +++ b/etc/frontend/routes.xml @@ -1,10 +1,8 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> diff --git a/etc/frontend/sections.xml b/etc/frontend/sections.xml index 2b3b4c3..e36571a 100644 --- a/etc/frontend/sections.xml +++ b/etc/frontend/sections.xml @@ -1,4 +1,9 @@ + +
diff --git a/etc/module.xml b/etc/module.xml index 1270cfb..c900287 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,14 +1,12 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> - \ No newline at end of file + diff --git a/registration.php b/registration.php index 85e9466..d38c80f 100755 --- a/registration.php +++ b/registration.php @@ -1,8 +1,12 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> diff --git a/view/adminhtml/layout/sales_order_create_index.xml b/view/adminhtml/layout/sales_order_create_index.xml index 018535c..42de7ae 100644 --- a/view/adminhtml/layout/sales_order_create_index.xml +++ b/view/adminhtml/layout/sales_order_create_index.xml @@ -1,10 +1,8 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> diff --git a/view/adminhtml/layout/sales_order_create_load_block_data.xml b/view/adminhtml/layout/sales_order_create_load_block_data.xml index 018535c..42de7ae 100644 --- a/view/adminhtml/layout/sales_order_create_load_block_data.xml +++ b/view/adminhtml/layout/sales_order_create_load_block_data.xml @@ -1,10 +1,8 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> diff --git a/view/adminhtml/layout/sales_order_create_load_block_totals.xml b/view/adminhtml/layout/sales_order_create_load_block_totals.xml index 018535c..42de7ae 100644 --- a/view/adminhtml/layout/sales_order_create_load_block_totals.xml +++ b/view/adminhtml/layout/sales_order_create_load_block_totals.xml @@ -1,10 +1,8 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> diff --git a/view/adminhtml/templates/order/create/subscribe.phtml b/view/adminhtml/templates/order/create/subscribe.phtml index e9a4df3..72454f8 100644 --- a/view/adminhtml/templates/order/create/subscribe.phtml +++ b/view/adminhtml/templates/order/create/subscribe.phtml @@ -2,5 +2,5 @@
- -
\ No newline at end of file + + diff --git a/view/frontend/layout/catalog_product_view.xml b/view/frontend/layout/catalog_product_view.xml index a754d04..4e165e7 100644 --- a/view/frontend/layout/catalog_product_view.xml +++ b/view/frontend/layout/catalog_product_view.xml @@ -1,10 +1,8 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml index 7f4efda..3941d8c 100755 --- a/view/frontend/layout/checkout_index_index.xml +++ b/view/frontend/layout/checkout_index_index.xml @@ -1,10 +1,8 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> diff --git a/view/frontend/layout/checkout_onepage_success.xml b/view/frontend/layout/checkout_onepage_success.xml index 8d4a572..a89eb27 100644 --- a/view/frontend/layout/checkout_onepage_success.xml +++ b/view/frontend/layout/checkout_onepage_success.xml @@ -1,10 +1,8 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> diff --git a/view/frontend/layout/conversion.xml b/view/frontend/layout/conversion.xml index 6be3f87..614c125 100644 --- a/view/frontend/layout/conversion.xml +++ b/view/frontend/layout/conversion.xml @@ -1,10 +1,8 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> @@ -16,4 +14,4 @@ /> - \ No newline at end of file + diff --git a/view/frontend/layout/customer_account_login.xml b/view/frontend/layout/customer_account_login.xml index 8df4fdd..4a3d9b5 100644 --- a/view/frontend/layout/customer_account_login.xml +++ b/view/frontend/layout/customer_account_login.xml @@ -1,10 +1,8 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> diff --git a/view/frontend/layout/default.xml b/view/frontend/layout/default.xml index ad7ffc8..610c055 100644 --- a/view/frontend/layout/default.xml +++ b/view/frontend/layout/default.xml @@ -1,10 +1,8 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> diff --git a/view/frontend/layout/multishipping_checkout_addresses.xml b/view/frontend/layout/multishipping_checkout_addresses.xml index f585049..b282dcc 100644 --- a/view/frontend/layout/multishipping_checkout_addresses.xml +++ b/view/frontend/layout/multishipping_checkout_addresses.xml @@ -1,10 +1,8 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> - \ No newline at end of file + diff --git a/view/frontend/layout/multishipping_checkout_success.xml b/view/frontend/layout/multishipping_checkout_success.xml index ca8f3eb..a89eb27 100644 --- a/view/frontend/layout/multishipping_checkout_success.xml +++ b/view/frontend/layout/multishipping_checkout_success.xml @@ -1,10 +1,8 @@ + ~ Copyright © 2022 Rejoiner. All rights reserved. + ~ See COPYING.txt for license details. + --> diff --git a/view/frontend/requirejs-config.js b/view/frontend/requirejs-config.js index a431532..eecab3f 100644 --- a/view/frontend/requirejs-config.js +++ b/view/frontend/requirejs-config.js @@ -1,5 +1,5 @@ -/** - * Copyright © 2017 Rejoiner. All rights reserved. +/* + * Copyright © 2022 Rejoiner. All rights reserved. * See COPYING.txt for license details. */ var config = { @@ -15,4 +15,4 @@ var config = { } } } -}; \ No newline at end of file +}; diff --git a/view/frontend/templates/rejoiner_acr/base.phtml b/view/frontend/templates/rejoiner_acr/base.phtml index aaba72e..f37b0bd 100644 --- a/view/frontend/templates/rejoiner_acr/base.phtml +++ b/view/frontend/templates/rejoiner_acr/base.phtml @@ -1,5 +1,10 @@ - getRejoinerHelper(); // Need to render blocks one by one to implode them into the single JSON $childBlockNames = $block->getChildNames(); @@ -10,11 +15,11 @@ foreach ($childBlockNames as $childBlockName) { } } ?> -getRejoinerSiteId() && $rejoinerHelper->getDomain()) : ?> +getRejoinerSiteId() && $rejoinerHelper->getDomain()): ?> escapeHtml($rejoinerHelper->getDomain()); $siteId = $block->escapeHtml($rejoinerHelper->getRejoinerSiteId()); - $rejoinerScriptUri = $block->escapeHtml($rejoinerHelper->getRejoinerScriptUri());; + $rejoinerScriptUri = $block->escapeHtml($rejoinerHelper->getRejoinerScriptUri()); ?>