-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1244 from BearGroup/release/5.18.0
Release/5.18.0
- Loading branch information
Showing
22 changed files
with
486 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
<?php | ||
|
||
namespace Amazon\Pay\Block\Promo; | ||
|
||
use Amazon\Pay\Model\AmazonConfig; | ||
use Magento\Catalog\Model\Product; | ||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Magento\Framework\Registry; | ||
use Magento\Framework\View\Element\Template; | ||
|
||
class PromoMessaging extends \Magento\Framework\View\Element\Template | ||
{ | ||
|
||
/** | ||
* These product types are not supported for promo messaging | ||
*/ | ||
protected const EXCLUDED_PRODUCT_TYPES = ['giftcard', 'grouped', 'virtual']; | ||
|
||
/** | ||
* @var AmazonConfig | ||
*/ | ||
protected $amazonConfig; | ||
|
||
/** | ||
* @var Registry | ||
*/ | ||
protected $registry; | ||
|
||
/** | ||
* @param AmazonConfig $amazonConfig | ||
* @param Template\Context $context | ||
* @param Registry $registry | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
AmazonConfig $amazonConfig, | ||
Template\Context $context, | ||
Registry $registry, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
$this->amazonConfig = $amazonConfig; | ||
$this->registry = $registry; | ||
} | ||
|
||
/** | ||
* Checks if promo messaging is enabled | ||
* | ||
* @return int | ||
*/ | ||
public function isPromoMessageEnabled(): int | ||
{ | ||
return $this->_scopeConfig->getValue('payment/amazon_payment_v2/promo_message_enabled'); | ||
} | ||
|
||
/** | ||
* AP Merchant Id getter | ||
* | ||
* @return string|null | ||
*/ | ||
public function getMerchantId(): ?string | ||
{ | ||
return $this->amazonConfig->getMerchantId(); | ||
} | ||
|
||
/** | ||
* AP Currency Code getter | ||
* | ||
* @return string | ||
*/ | ||
public function getCurrencyCode(): string | ||
{ | ||
return $this->amazonConfig->getCurrencyCode(); | ||
} | ||
|
||
/** | ||
* AP Language Code getter | ||
* | ||
* @return string | ||
*/ | ||
public function getLanguageCode(): string | ||
{ | ||
return $this->amazonConfig->getLanguage(); | ||
} | ||
|
||
/** | ||
* Determines current environment based on if sandbox is enabled or not | ||
* | ||
* @return string | ||
*/ | ||
public function getEnvironment(): string | ||
{ | ||
return $this->amazonConfig->isSandboxEnabled() ? 'sandbox' : 'live'; | ||
} | ||
|
||
/** | ||
* Get product from registry | ||
* | ||
* @return Product | ||
*/ | ||
private function getProduct(): Product | ||
{ | ||
return $this->registry->registry('product'); | ||
} | ||
|
||
/** | ||
* Grabs current product's price for promo vars | ||
* | ||
* @return float|null | ||
*/ | ||
public function getProductPrice(): ?float | ||
{ | ||
$product = $this->getProduct(); | ||
return $product ? $product->getPrice() : null; | ||
} | ||
|
||
/** | ||
* Checks if product is of a type that does not contain static price values | ||
* | ||
* @return bool | ||
*/ | ||
public function checkIsEligibleProduct(): bool | ||
{ | ||
$product = $this->getProduct(); | ||
return !in_array($product->getTypeId(), self::EXCLUDED_PRODUCT_TYPES, true); | ||
} | ||
|
||
/** | ||
* AP Payment Product Type | ||
* | ||
* @return string|null | ||
*/ | ||
public function getPaymentProductType(): ?string | ||
{ | ||
return $this->_scopeConfig->getValue('payment/amazon_payment_v2/promo_message_product_type'); | ||
} | ||
|
||
/** | ||
* AP Promo Font Color getter | ||
* | ||
* @return string|null | ||
*/ | ||
public function getPromoFontColor(): ?string | ||
{ | ||
return $this->_scopeConfig->getValue('payment/amazon_payment_v2/promo_message_color'); | ||
} | ||
|
||
/** | ||
* AP Promo Font Color getter | ||
* | ||
* @return string|null | ||
*/ | ||
public function getPromoFontSize(): ?string | ||
{ | ||
return $this->_scopeConfig->getValue('payment/amazon_payment_v2/promo_message_font_size'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Amazon\Pay\Model\Config\Source; | ||
|
||
class PromoFontSize implements \Magento\Framework\Data\OptionSourceInterface | ||
{ | ||
|
||
/** | ||
* Font values available for promo message banner | ||
* | ||
* @return array[] | ||
*/ | ||
public function toOptionArray(): array | ||
{ | ||
return [ | ||
[ | ||
'label' => __('14px'), | ||
'value' => '14', | ||
], | ||
[ | ||
'label' => __('16px'), | ||
'value' => '16', | ||
], | ||
[ | ||
'label' => __('18px'), | ||
'value' => '18', | ||
], | ||
[ | ||
'label' => __('20px'), | ||
'value' => '20', | ||
] | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Amazon\Pay\Model\Config\Source; | ||
|
||
class PromoPaymentType implements \Magento\Framework\Data\OptionSourceInterface | ||
{ | ||
|
||
/** | ||
* Payment "product type" checkout values available for promo message banner | ||
* | ||
* @return array[] | ||
*/ | ||
public function toOptionArray(): array | ||
{ | ||
return [ | ||
[ | ||
'label' => __('Pay And Ship'), | ||
'value' => 'PayAndShip', | ||
], | ||
[ | ||
'label' => __('Pay Only'), | ||
'value' => 'PayOnly', | ||
] | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.