Commit c2916a0c by halweg

feat : coupon push 添加后台配置

parent b50c515f
......@@ -2,7 +2,11 @@
namespace Joshine\CouponPusher\Block;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\View\Element\Template;
use Magento\Newsletter\Model\Subscriber;
use Magento\Store\Model\ScopeInterface;
class CouponSubscribeAlert extends \Magento\Framework\View\Element\Template
{
......@@ -10,23 +14,70 @@ class CouponSubscribeAlert extends \Magento\Framework\View\Element\Template
protected $coupon;
protected $_objectManager;
protected $saleRule;
protected $_rule;
public function __construct(
Template\Context $context,
array $data = [],
\Magento\SalesRule\Model\Coupon $coupon,
\Magento\SalesRule\Model\Rule $saleRule
\Magento\SalesRule\Model\Rule $saleRule,
\Magento\Framework\ObjectManagerInterface $objectManager
)
{
parent::__construct($context, $data);
$this->coupon = $coupon;
$this->saleRule = $saleRule;
$this->_objectManager = $objectManager;
}
public function getCoupon()
{
$ruleId = $this->coupon->loadByCode('N20F')->getRuleId();
return $this->saleRule->load($ruleId);
if (empty($this->_rule)) {
$code = $this->_objectManager->get(ScopeConfigInterface::class)
->getValue(
'joshine_coupon_pusher/general/newsletter_coupon_code',
ScopeInterface::SCOPE_STORE
);
$ruleId = $this->coupon->loadByCode($code)->getRuleId();
$rule = $this->saleRule->load($ruleId);
$this->_rule = $rule;
}
return $this->_rule;
}
public function getCouponTitle()
{
return $this->_objectManager->get(ScopeConfigInterface::class)
->getValue(
'joshine_coupon_pusher/general/newsletter_coupon_title',
ScopeInterface::SCOPE_STORE
);
}
public function getInformationTitle()
{
return $this->_objectManager->get(ScopeConfigInterface::class)
->getValue(
'joshine_coupon_pusher/general/newsletter_information_title',
ScopeInterface::SCOPE_STORE
);
}
public function getInformationText()
{
return $this->_objectManager->get(ScopeConfigInterface::class)
->getValue(
'joshine_coupon_pusher/general/newsletter_information_text',
ScopeInterface::SCOPE_STORE
);
}
public function getCouponDescription()
{
return $this->getCoupon()->getData('description');
}
}
\ No newline at end of file
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="admin">
<route id="joshine_coupon_pusher" frontName="joshine_coupon_pusher">
<module name="joshine_coupon_pusher"/>
</route>
</router>
</config>
\ No newline at end of file
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="joshine_coupon_pusher" translate="label" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<class>separator-top</class>
<label>CouponPusher</label>
<tab>joshine</tab>
<resource>Joshine_CouponPusher::opt_config</resource>
<group id="general" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label>General Configuration</label>
<field id="enabled" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Module Enable</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="newsletter_coupon_code" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Newsletter Coupon Code</label>
<comment>Coupon will display on the frontend.</comment>
</field>
<field id="newsletter_coupon_title" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Newsletter Coupon Title</label>
<comment>Coupon will display on the frontend.</comment>
</field>
<field id="newsletter_information_title" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Newsletter Information Title</label>
<comment>Coupon will display on the frontend.</comment>
</field>
<field id="newsletter_information_text" translate="label" type="textarea" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Newsletter Information Text</label>
<comment>Coupon will display on the frontend.</comment>
</field>
</group>
</section>
</system>
</config>
\ No newline at end of file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<opt>
<general>
<enabled>0</enabled>
<newsletter_coupon_title>??% OF</newsletter_coupon_title>
<newsletter_information_title>Submit email address to get your exclusive offer.</newsletter_information_title>
<newsletter_information_text>*You agree to receive autodialed marketing messages on this
number. Consent not required to purchase goods. Message and data rates may apply. Message
frequency may vary. Text STOP to opt out and HELP for help.</newsletter_information_text>
</general>
</opt>
</default>
</config>
\ No newline at end of file
......@@ -6,6 +6,6 @@
<css src="Joshine_CouponPusher::css/_coupon_alert.css"/>
</head>
<referenceContainer name="footer-container">
<block class="Joshine\CouponPusher\Block\JsInit" name="coupon.pusher.js"/>
<block class="Joshine\CouponPusher\Block\JsInit" name="coupon.pusher.js" ifconfig="joshine_coupon_pusher/general/enabled"/>
</referenceContainer>
</page>
\ No newline at end of file
......@@ -18,7 +18,7 @@
position: relative;
}
@media (max-width: 670px) {
@media (max-width: 991px) {
#coupon-subscribe-alert.joshine-model-warp .j-modal .j-modal-dialog {
width: 85vw;
}
......@@ -48,11 +48,11 @@
<img src="<?= $block->getViewFileUrl('Joshine_CouponPusher::images/coupon_background.png'); ?>" alt="" class="">
<div class="coupon-text">
<!--todo:: show config coupon-->
<p class="coupon-discount-amount">20% OFF</p>
<p class="coupon-discount-rule">testtest</p>
<p class="coupon-discount-amount"><?= $block->getCouponTitle() ?></p>
<p class="coupon-discount-rule"><?= $block->getCouponDescription() ?></p>
</div>
<div class="coupon-alt-input-title">
<?= __('Sign up for text messages to get your exclusive offer.') ?>
<?= __('Subscribe to get your exclusive offer.') ?>
</div>
<div class="coupon-alt-input">
<div class="coupon-alt-input-left">
......@@ -61,14 +61,11 @@
<div class="coupon-alert-submit-button" id="coupon-subscribe-email"><?= __('Submit') ?></div>
</div>
<div class="coupon-input-errorMsg"></div>
<div class="split-line joshine-hidden-sm joshine-hidden-xs"><span class="split-text"><?= __('OR') ?></span></div>
<div class="coupon-alt-bottom-title joshine-hidden-sm joshine-hidden-xs"><span><?= __('Submit email address to get your exclusive offer.') ?></span>
<div class="split-line joshine-hidden-sm joshine-hidden-xs"><span class="split-text"><?= __('Additional Information') ?></span></div>
<div class="coupon-alt-bottom-title joshine-hidden-sm joshine-hidden-xs"><span><?= $block->getInformationTitle() ?></span>
</div>
<div class="coupon-alt-bottom-text joshine-hidden-sm joshine-hidden-xs">
<?= __('*You agree to receive autodialed marketing messages on this
number. Consent not required to purchase goods. Message and data rates may apply. Message
frequency may vary. Text STOP to opt out and HELP for help.') ?>
<a href="#" class="" target="_blank"><?= __('Privacy policy') ?> </a>
<?= $block->getInformationText() ?>
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment