Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 43 additions & 8 deletions Block/Advert/AbstractAdvert.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
use \Magento\Framework\Currency;

/**
* @category Zip
* @package ZipPayment
* @author Zip Plugin Team <integration@zip.co>
* @copyright 2020 Zip Co Limited
* @link https://zip.co
*/
Expand All @@ -31,8 +28,6 @@ abstract class AbstractAdvert extends \Magento\Framework\View\Element\Template
protected $_registry;

/**
* Checkout session
*
* @var \Magento\Checkout\Model\Session
*/
protected $_checkoutSession;
Expand Down Expand Up @@ -74,6 +69,17 @@ abstract class AbstractAdvert extends \Magento\Framework\View\Element\Template
]
];

/**
* AbstractAdvert constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Zip\ZipPayment\Model\Config $config
* @param \Magento\Framework\Registry $registry
* @param \Zip\ZipPayment\Helper\Logger $logger
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param PriceCurrencyInterface $priceCurrency
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Zip\ZipPayment\Model\Config $config,
Expand All @@ -92,13 +98,23 @@ public function __construct(
$this->_priceCurrency = $priceCurrency;
}

/**
* Returns the final price of the current product
*
* @return float
*/
public function getProductPrice()
{
$product = $this->_registry->registry('current_product');
$price = $product->getPriceInfo()->getPrice('final_price')->getValue();
return $price;
}

/**
* Returns the quote grand total
*
* @return float|int
*/
public function getCartTotal()
{
$totals = $this->_checkoutSession->getQuote()->getTotals();
Expand All @@ -109,13 +125,24 @@ public function getCartTotal()
return $totalAmount;
}

/**
* Formats the price without the currency symbol
*
* @param float|int $price
* @return string
*/
public function getCurrencyFormat($price)
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$currency = $objectManager->get(\Magento\Directory\Model\Currency::class);
return $currency->format($price, ['display' => Currency::NO_SYMBOL], false);
}

/**
* Returns the current currency symbol
*
* @return string
*/
public function getCurrencySymbol()
{
return $this->_priceCurrency->getCurrencySymbol();
Expand All @@ -124,7 +151,9 @@ public function getCurrencySymbol()
/**
* Check if widget has been enabled
*
* @return bool
* @param string $widget
* @param string $page
* @return mixed
*/
protected function _configShow($widget, $page)
{
Expand All @@ -138,6 +167,8 @@ protected function _configShow($widget, $page)
/**
* Check if widget html selector has value
*
* @param string $widget
* @param string $page
* @return bool
*/
protected function _isSelectorExist($widget, $page)
Expand All @@ -149,7 +180,9 @@ protected function _isSelectorExist($widget, $page)
/**
* Returns the config path
*
* @return bool
* @param string $widget
* @param string $page
* @return string|null
*/
protected function _getConfigPath($widget, $page)
{
Expand All @@ -161,7 +194,9 @@ protected function _getConfigPath($widget, $page)
}

/**
* get element selectors for current widgets
* Get element selectors for current widgets
*
* @return array
*/
public function getElementSelectors()
{
Expand Down
3 changes: 1 addition & 2 deletions Block/Advert/Banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Magento\Catalog\Block as CatalogBlock;

/**
* @author Zip Plugin Team <integration@zip.co>
* @copyright 2020 Zip Co Limited
* @link https://zip.co
*/
Expand All @@ -14,7 +13,7 @@ class Banner extends AbstractAdvert implements CatalogBlock\ShortcutInterface
/**
* @const string
*/
const ADVERT_TYPE = "banner";
public const ADVERT_TYPE = "banner";

/**
* Get shortcut alias
Expand Down
37 changes: 33 additions & 4 deletions Block/Advert/RootEl.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Magento\Catalog\Block as CatalogBlock;

/**
* @author Zip Plugin Team <integration@zip.co>
* @copyright 2020 Zip Co Limited
* @link https://zip.co
*/
Expand All @@ -15,13 +14,25 @@ class RootEl extends AbstractAdvert implements CatalogBlock\ShortcutInterface
/**
* Get country path
*/
const COUNTRY_CODE_PATH = 'general/country/default';
public const COUNTRY_CODE_PATH = 'general/country/default';

/**
* @var \Zip\ZipPayment\ViewModel\WidgetConfig
*/
protected $widgetConfigViewModel;

/**
* RootEl constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Zip\ZipPayment\Model\Config $config
* @param \Magento\Framework\Registry $registry
* @param \Zip\ZipPayment\Helper\Logger $logger
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
* @param \Zip\ZipPayment\ViewModel\WidgetConfig $widgetConfigViewModel
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Zip\ZipPayment\Model\Config $config,
Expand Down Expand Up @@ -67,31 +78,49 @@ public function getEnvironment()
}

/**
* get region
* Get region
*
* @return string
*/
public function getRegion()
{
return $this->_config->getRegion();
}

/**
* Get language code
*
* @return string
*/
public function getLanguageCode()
{
return $this->_config->getLanguageCode();
}

/**
* Get minimum order total
*
* @return float
*/
public function getOrderTotalMinimum()
{
return $this->_config->getOrderTotalMinimum();
}

/**
* Get maximum order total
*
* @return float
*/
public function getOrderTotalMaximum()
{
return $this->_config->getOrderTotalMaximum();
}

/**
* display product widget in line
* Display product widget in line
*
* @return string
*/
public function isDisplayInlineWidget()
{
Expand Down
3 changes: 1 addition & 2 deletions Block/Advert/Tagline.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Magento\Catalog\Block as CatalogBlock;

/**
* @author Zip Plugin Team <integration@zip.co>
* @copyright 2020 Zip Co Limited
* @link https://zip.co
*/
Expand All @@ -14,7 +13,7 @@ class Tagline extends AbstractAdvert implements CatalogBlock\ShortcutInterface
/**
* @const string
*/
const WIDGET_TYPE = "tagline";
public const WIDGET_TYPE = "tagline";

/**
* Get shortcut alias
Expand Down
19 changes: 18 additions & 1 deletion Block/Advert/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Widget extends AbstractAdvert implements CatalogBlock\ShortcutInterface
/**
* @const string
*/
const ADVERT_TYPE = "widget";
public const ADVERT_TYPE = "widget";

/**
* @var NotAllowedProductsProvider
Expand All @@ -22,6 +22,18 @@ class Widget extends AbstractAdvert implements CatalogBlock\ShortcutInterface
*/
private $checkoutSession;

/**
* Widget constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Zip\ZipPayment\Model\Config $config
* @param \Magento\Framework\Registry $registry
* @param \Zip\ZipPayment\Helper\Logger $logger
* @param CheckoutSession $checkoutSession
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
* @param NotAllowedProductsProvider $notAllowedProductsProvider
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Zip\ZipPayment\Model\Config $config,
Expand All @@ -37,6 +49,11 @@ public function __construct(
$this->checkoutSession = $checkoutSession;
}

/**
* Returns the formatted cart total or product price for the current page
*
* @return string
*/
public function getPrice()
{
$price = 0;
Expand Down
17 changes: 13 additions & 4 deletions Block/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Magento\Framework\View\Element\Template;

/**
* @author Zip Plugin Team <integration@zip.co>
* @copyright 2020 Zip Co Limited
* @link https://zip.co
*/
Expand All @@ -14,18 +13,28 @@ class Error extends Template
/**
* @const string
*/
const ERROR_BODY = 'payment/zippayment/zip_messages/error_body';
public const ERROR_BODY = 'payment/zippayment/zip_messages/error_body';
/**
* @const string
*/
const ERROR_HEADER = 'payment/zippayment/zip_messages/error_header';
public const ERROR_HEADER = 'payment/zippayment/zip_messages/error_header';

/**
* @var Magento\Framework\Message\ManagerInterface
* @var \Magento\Framework\Message\ManagerInterface
*/
protected $_messageManager;

/**
* @var \Zip\ZipPayment\Model\Config
*/
protected $_config;

/**
* @param Template\Context $context
* @param \Magento\Framework\Message\ManagerInterface $messageManager
* @param \Zip\ZipPayment\Model\Config $config
* @param array $data
*/
public function __construct(
Template\Context $context,
\Magento\Framework\Message\ManagerInterface $messageManager,
Expand Down
1 change: 0 additions & 1 deletion Block/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Magento\Payment\Block\ConfigurableInfo;

/**
* @author Zip Plugin Team <integration@zip.co>
* @copyright 2020 Zip Co Limited
* @link https://zip.co
*/
Expand Down
18 changes: 15 additions & 3 deletions Block/Referred.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Magento\Framework\View\Element\Template;

/**
* @author Zip Plugin Team <integration@zip.co>
* @copyright 2020 Zip Co Limited
* @link https://zip.co
*/
Expand All @@ -14,15 +13,28 @@ class Referred extends Template
/**
* @const string
*/
const REFERRED_HEADER = 'payment/zippayment/zip_messages/referred_header';
public const REFERRED_HEADER = 'payment/zippayment/zip_messages/referred_header';
/**
* @const string
*/
const REFERRED_BODY = 'payment/zippayment/zip_messages/referred_body';
public const REFERRED_BODY = 'payment/zippayment/zip_messages/referred_body';

/**
* @var \Magento\Framework\Message\ManagerInterface
*/
protected $_messageManager;

/**
* @var \Zip\ZipPayment\Model\Config
*/
protected $_config;

/**
* @param Template\Context $context
* @param \Magento\Framework\Message\ManagerInterface $messageManager
* @param \Zip\ZipPayment\Model\Config $config
* @param array $data
*/
public function __construct(
Template\Context $context,
\Magento\Framework\Message\ManagerInterface $messageManager,
Expand Down
1 change: 0 additions & 1 deletion Block/System/Config/Fieldset/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public function __construct(
parent::__construct($context, $authSession, $jsHelper, $data);
}


/**
* Add custom css class
*
Expand Down
Loading
Loading