diff --git a/Block/AbstractPixel.php b/Block/AbstractPixel.php
index 1c275ce..f420d1c 100644
--- a/Block/AbstractPixel.php
+++ b/Block/AbstractPixel.php
@@ -83,7 +83,9 @@ protected function _toHtml(): string
fbq("' . $this->getTrackMethod() . '", '
. $this->json->serialize($eventName) . ', '
. $this->json->serialize($parameters) . ', '
- . '{ "eventID": "' . $eventName . '" + "." + Math.floor(Math.random() * 1000000) + "." + Date.now(), "event_source_url": window.location.href, "referrer_url": document.referrer }'
+ . '{ "eventID": "' . $eventName
+ . '" + "." + Math.floor(Math.random() * 1000000) + "."'
+ . ' + Date.now(), "event_source_url": window.location.href, "referrer_url": document.referrer }'
. ');
';
@@ -95,6 +97,8 @@ protected function _toHtml(): string
}
/**
+ * Get track method
+ *
* @return string
*/
protected function getTrackMethod(): string
diff --git a/Block/Adminhtml/System/Config/Form/InfoConversionApi.php b/Block/Adminhtml/System/Config/Form/InfoConversionApi.php
index b058bae..2922869 100644
--- a/Block/Adminhtml/System/Config/Form/InfoConversionApi.php
+++ b/Block/Adminhtml/System/Config/Form/InfoConversionApi.php
@@ -12,6 +12,8 @@ class InfoConversionApi extends InfoPlan
{
/**
+ * Get min plan name
+ *
* @return string
*/
protected function getMinPlan(): string
@@ -20,6 +22,8 @@ protected function getMinPlan(): string
}
/**
+ * Get section id
+ *
* @return string
*/
protected function getSectionId(): string
@@ -28,6 +32,8 @@ protected function getSectionId(): string
}
/**
+ * Get section text
+ *
* @return string
*/
protected function getText(): string
diff --git a/Block/Adminhtml/System/Config/Form/InfoPlan.php b/Block/Adminhtml/System/Config/Form/InfoPlan.php
index fa74aab..7533502 100644
--- a/Block/Adminhtml/System/Config/Form/InfoPlan.php
+++ b/Block/Adminhtml/System/Config/Form/InfoPlan.php
@@ -11,23 +11,29 @@
abstract class InfoPlan extends \Magefan\Community\Block\Adminhtml\System\Config\Form\Info
{
/**
+ * Get min plan name
+ *
* @return string
*/
abstract protected function getMinPlan(): string;
/**
+ * Get section id
+ *
* @return string
*/
abstract protected function getSectionId(): string;
/**
+ * Get section text
+ *
* @return string
*/
abstract protected function getText(): string;
-
/**
* Return info block html
+ *
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
@@ -39,7 +45,11 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele
$html = '';
$html .= '
';
$script = '
@@ -66,7 +76,9 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele
text: "Upgrade Plan Now",
class: "action primary accept",
click: function () {
- window.open("https://magefan.com/magento-2-google-tag-manager/pricing?utm_source=gtm_config&utm_medium=link&utm_campaign=regular");
+ var url = "https://magefan.com/magento-2-google-tag-manager/pricing?"
+ + "utm_source=gtm_config&utm_medium=link&utm_campaign=regular";
+ window.open(url);
}
}]
});
diff --git a/Block/Adminhtml/System/Config/Form/ProtectCustomerData.php b/Block/Adminhtml/System/Config/Form/ProtectCustomerData.php
index 93ccf42..8ae9425 100644
--- a/Block/Adminhtml/System/Config/Form/ProtectCustomerData.php
+++ b/Block/Adminhtml/System/Config/Form/ProtectCustomerData.php
@@ -23,7 +23,7 @@ public function render(AbstractElement $element): string
{
$url = $this->getUrl('*/*/*/section/web');
$comment = 'When enabled, data won\'t be sent to Facebook, until the customer provides consent.'; /*
- Note, that this option will work only when Cookie Restriction Mode at
+ Note, that this option will work only when Cookie Restriction Mode at
Stores > Configuration > General > Web > Default Cookie Settings
is enabled.'; */
diff --git a/Block/Pixel/Purchase.php b/Block/Pixel/Purchase.php
index f6a9f72..9783f9c 100644
--- a/Block/Pixel/Purchase.php
+++ b/Block/Pixel/Purchase.php
@@ -76,6 +76,8 @@ protected function getEventName(): string
}
/**
+ * Get current order
+ *
* @return \Magento\Sales\Model\Order
*/
protected function getOrder()
diff --git a/Block/Pixel/PurchaseGetOrderFromRequest.php b/Block/Pixel/PurchaseGetOrderFromRequest.php
index a682888..69301cd 100644
--- a/Block/Pixel/PurchaseGetOrderFromRequest.php
+++ b/Block/Pixel/PurchaseGetOrderFromRequest.php
@@ -11,6 +11,8 @@
class PurchaseGetOrderFromRequest extends Purchase
{
/**
+ * Get order
+ *
* @return \Magento\Sales\Model\Order|null
*/
protected function getOrder()
@@ -24,6 +26,8 @@ protected function getOrder()
}
/**
+ * Get order factory
+ *
* @return mixed
*/
protected function getOrderFactory()
@@ -33,6 +37,8 @@ protected function getOrderFactory()
}
/**
+ * Get order id
+ *
* @return string
*/
protected function getOrderId()
@@ -45,4 +51,4 @@ protected function getOrderId()
return 0;
}
-}
\ No newline at end of file
+}
diff --git a/Block/Pixel/ViewProductContent.php b/Block/Pixel/ViewProductContent.php
index 26a822f..620cbfa 100644
--- a/Block/Pixel/ViewProductContent.php
+++ b/Block/Pixel/ViewProductContent.php
@@ -95,6 +95,7 @@ private function getCurrentProduct(): Product
if ($productId = $this->_request->getParam('mfpreselect')) {
try {
$product = $this->productRepository->getById($productId);
+ // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedCatch
} catch (NoSuchEntityException $e) {
}
diff --git a/Model/AbstractPixel.php b/Model/AbstractPixel.php
index 4e8a04e..9948b85 100644
--- a/Model/AbstractPixel.php
+++ b/Model/AbstractPixel.php
@@ -51,6 +51,8 @@ class AbstractPixel
* @param Config $config
* @param StoreManagerInterface $storeManager
* @param CategoryRepositoryInterface $categoryRepository
+ * @param RequestInterface|null $request
+ * @param Registry|null $registry
*/
public function __construct(
Config $config,
diff --git a/Model/Config.php b/Model/Config.php
index a8aadf5..7c8148d 100644
--- a/Model/Config.php
+++ b/Model/Config.php
@@ -85,12 +85,12 @@ public function getProductAttribute(?string $storeId = null): string
return trim((string)$this->getConfig(self::XML_PATH_ATTRIBUTES_PRODUCT, $storeId));
}
- /*
- * Retrieve Magento product categories
- *
- * @param string|null $storeId
- * @return string
- */
+ /**
+ * Retrieve Magento category attribute
+ *
+ * @param string|null $storeId
+ * @return string
+ */
public function getCategoriesAttribute(?string $storeId = null): string
{
return trim((string)$this->getConfig(self::XML_PATH_ATTRIBUTES_CATEGORIES, $storeId));
diff --git a/Model/Pixel/Cart/Content.php b/Model/Pixel/Cart/Content.php
index fbdc0ba..d4419f9 100644
--- a/Model/Pixel/Cart/Content.php
+++ b/Model/Pixel/Cart/Content.php
@@ -40,10 +40,12 @@ public function get(Item $quoteItem): array
}
/**
- * @param $quoteItem
+ * Get product from quote item
+ *
+ * @param Item $quoteItem
* @return \Magento\Catalog\Api\Data\ProductInterface
*/
- protected function getItemProduct($quoteItem)
+ protected function getItemProduct(Item $quoteItem)
{
$product = $quoteItem->getProduct();
if ('configurable' === $product->getTypeId()) {
@@ -54,6 +56,7 @@ protected function getItemProduct($quoteItem)
try {
$product = $this->getProductRepository()->getById($option->getProductId());
break;
+ // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedCatch
} catch (NoSuchEntityException $e) {
}
@@ -65,6 +68,8 @@ protected function getItemProduct($quoteItem)
}
/**
+ * Get product repository instance
+ *
* @return ProductRepositoryInterface
*/
protected function getProductRepository(): ProductRepositoryInterface
diff --git a/Model/Pixel/Order/Content.php b/Model/Pixel/Order/Content.php
index 356454b..9bc35ac 100644
--- a/Model/Pixel/Order/Content.php
+++ b/Model/Pixel/Order/Content.php
@@ -27,10 +27,12 @@ public function get(OrderItemInterface $orderItem): array
}
/**
- * @param $orderItem
+ * Get product from order item
+ *
+ * @param OrderItemInterface $orderItem
* @return \Magento\Catalog\Api\Data\ProductInterface
*/
- protected function getItemProduct($orderItem)
+ protected function getItemProduct(OrderItemInterface $orderItem)
{
$product = $orderItem->getProduct();
if ('configurable' === $product->getTypeId()) {
diff --git a/Model/Pixel/Purchase.php b/Model/Pixel/Purchase.php
index bcbd143..7fdc340 100644
--- a/Model/Pixel/Purchase.php
+++ b/Model/Pixel/Purchase.php
@@ -77,10 +77,12 @@ public function get(Order $order): array
}
/**
- * @param $entity
+ * Set mf_children_item for each item
+ *
+ * @param Order $entity
* @return void
*/
- protected function setMfChildrenItem($entity)
+ protected function setMfChildrenItem(Order $entity)
{
// Use getItem, not getAllItems, to prevent some errors with the custom plugins
foreach ($entity->getItems() as $childrenItem) {
diff --git a/view/adminhtml/templates/system/config/event/list.phtml b/view/adminhtml/templates/system/config/event/list.phtml
index 575f792..2abf5b6 100644
--- a/view/adminhtml/templates/system/config/event/list.phtml
+++ b/view/adminhtml/templates/system/config/event/list.phtml
@@ -41,9 +41,14 @@ $eventsExtra = [
isPlusEnabled()) { ?>style="color: #eb5202">
- = $escaper->escapeHtml(__(!$block->isPlusEnabled() ? 'Available in FB Pixel Plus Only' : 'FB Pixel Plus')) ?>
+ = $escaper->escapeHtml(__(!$block->isPlusEnabled()
+ ? 'Available in FB Pixel Plus Only'
+ : 'FB Pixel Plus')) ?>
isPlusEnabled()) { ?>
- (Read more):
+ (
+ Read more
+ ):
@@ -60,7 +65,10 @@ $eventsExtra = [
__(!$block->isExtraEnabled() ? 'Available in FB Pixel Extra Only' : 'FB Pixel Extra')
) ?>
isExtraEnabled()) { ?>
- (Read more):
+ (
+ Read more
+ ):
diff --git a/view/frontend/templates/pixel.phtml b/view/frontend/templates/pixel.phtml
index 68a748c..732904b 100644
--- a/view/frontend/templates/pixel.phtml
+++ b/view/frontend/templates/pixel.phtml
@@ -27,17 +27,23 @@ $script = '';
n.queue=[];
f.mfFbq = 1;
- let customerData = localStorage.getItem('mage-cache-storage') ? JSON.parse(localStorage.getItem('mage-cache-storage')).customer : false;
- let advancedMatching = (customerData && customerData.mf_fb_pixel_customer_data) ? customerData.mf_fb_pixel_customer_data : {};
+ let customerData = localStorage.getItem('mage-cache-storage')
+ ? JSON.parse(localStorage.getItem('mage-cache-storage')).customer
+ : false;
+ let advancedMatching = (customerData && customerData.mf_fb_pixel_customer_data)
+ ? customerData.mf_fb_pixel_customer_data : {};
fbq('init', '{$escaper->escapeHtml($block->getFbPixelId())}', advancedMatching);
- fbq('track', 'PageView', {}, {'eventID': 'PageView' + '.' + Math.floor(Math.random() * 1000000) + '.' + Date.now(), 'currency': '" . $block->getCurrentCurrencyCode() . "','event_source_url': window.location.href, 'referrer_url': document.referrer});
+ fbq('track', 'PageView', {},
+ {'eventID': 'PageView' + '.' + Math.floor(Math.random() * 1000000) + '.' + Date.now(),
+ 'currency': '" . $block->getCurrentCurrencyCode() . "',
+ 'event_source_url': window.location.href, 'referrer_url': document.referrer});
var triedToLoadPixel = false;
";
- if ($block->isSpeedOptimizationEnabled() && $block->getRequest()->getModuleName() !== 'checkout') {
- $script .= "
+if ($block->isSpeedOptimizationEnabled() && $block->getRequest()->getModuleName() !== 'checkout') {
+ $script .= "
var actionDetected = false;
document.addEventListener('scroll', initMfFbPixel);
document.addEventListener('mousemove', initMfFbPixel);
@@ -55,11 +61,11 @@ $script = '';
}
};
";
- } else {
- $script .= "
+} else {
+ $script .= "
var actionDetected = true;
";
- }
+}
$script .= "
function mfLoadFbPixel() {
@@ -75,13 +81,13 @@ $script = '';
";
- if ($block->isProtectCustomerDataEnabled()) {
- echo $block->getLayout()->createBlock(\Magefan\Community\Block\JsScript::class)
- ->setMethod('isCustomerConsentProvided')
- ->setScriptAttributes(['data-rocketjavascript' => 'false'])
- ->toHtml();
+if ($block->isProtectCustomerDataEnabled()) {
+ echo $block->getLayout()->createBlock(\Magefan\Community\Block\JsScript::class)
+ ->setMethod('isCustomerConsentProvided')
+ ->setScriptAttributes(['data-rocketjavascript' => 'false'])
+ ->toHtml();
- $script .= "
+ $script .= "
document.addEventListener('DOMContentLoaded', function () {
if (MagefanJs.isCustomerConsentProvided()) {
mfLoadFbPixel();
@@ -94,11 +100,11 @@ $script = '';
}
});
";
- } else {
- $script .= "
+} else {
+ $script .= "
mfLoadFbPixel();
";
- }
+}
$script .= "
}(window);