Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
joshine
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
joshine
Commits
c2916a0c
Commit
c2916a0c
authored
Mar 31, 2023
by
halweg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat : coupon push 添加后台配置
parent
b50c515f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
128 additions
and
14 deletions
+128
-14
app/code/Joshine/CouponPusher/Block/CouponSubscribeAlert.php
+55
-3
app/code/Joshine/CouponPusher/etc/adminhtml/routes.xml
+9
-0
app/code/Joshine/CouponPusher/etc/adminhtml/system.xml
+39
-0
app/code/Joshine/CouponPusher/etc/config.xml
+16
-0
app/code/Joshine/CouponPusher/view/frontend/layout/default.xml
+2
-1
app/code/Joshine/CouponPusher/view/frontend/templates/coupon-subscribe-alert.phtml
+7
-10
No files found.
app/code/Joshine/CouponPusher/Block/CouponSubscribeAlert.php
View file @
c2916a0c
...
...
@@ -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
app/code/Joshine/CouponPusher/etc/adminhtml/routes.xml
0 → 100644
View file @
c2916a0c
<?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
app/code/Joshine/CouponPusher/etc/adminhtml/system.xml
0 → 100644
View file @
c2916a0c
<?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
app/code/Joshine/CouponPusher/etc/config.xml
0 → 100644
View file @
c2916a0c
<?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
app/code/Joshine/CouponPusher/view/frontend/layout/default.xml
View file @
c2916a0c
...
...
@@ -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
app/code/Joshine/CouponPusher/view/frontend/templates/coupon-subscribe-alert.phtml
View file @
c2916a0c
...
...
@@ -18,7 +18,7 @@
position
:
relative
;
}
@media
(
max-width
:
670
px
)
{
@media
(
max-width
:
991
px
)
{
#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"
>
<?=
__
(
'S
ign up for text messages
to get your exclusive offer.'
)
?>
<?=
__
(
'S
ubscribe
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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment