How to add custom text block in onpage check-out The 2019 Stack Overflow Developer Survey Results Are InMagento 2 Add text in checkout page via XMLHow to check if in checkout if custom module installed?How to add a custom and dynamic block during onepage checkout?How to move Magento Coupon Block from the Cart page to the one page checkoutHow can you add a content block to magento onepage checkout?Add custom field in onepage check out,order,invoice,salesHow to add text block in magento 2 custom moduleHow to add custom content to block layout render by jslayoutHow add div after image block in Magento 2?Magento 2 : Change Comment of Onepage Checkout Email AddressMagento2 - Add Custom fields block after shipping method
Pokemon Turn Based battle (Python)
How much of the clove should I use when using big garlic heads?
How to type this arrow in math mode?
Slides for 30 min~1 hr Skype tenure track application interview
"as much details as you can remember"
The phrase "to the numbers born"?
Does adding complexity mean a more secure cipher?
How to support a colleague who finds meetings extremely tiring?
Why isn't the circumferential light around the M87 black hole's event horizon symmetric?
How come people say “Would of”?
Inverse Relationship Between Precision and Recall
If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?
What is the most efficient way to store a numeric range?
Are spiders unable to hurt humans, especially very small spiders?
Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?
If a sorcerer casts the Banishment spell on a PC while in Avernus, does the PC return to their home plane?
How to charge AirPods to keep battery healthy?
How can I add encounters in the Lost Mine of Phandelver campaign without giving PCs too much XP?
What is the motivation for a law requiring 2 parties to consent for recording a conversation
Why doesn't shell automatically fix "useless use of cat"?
Get name of standard action overriden in Visualforce contorller
Will it cause any balance problems to have PCs level up and gain the benefits of a long rest mid-fight?
What is this sharp, curved notch on my knife for?
For what reasons would an animal species NOT cross a *horizontal* land bridge?
How to add custom text block in onpage check-out
The 2019 Stack Overflow Developer Survey Results Are InMagento 2 Add text in checkout page via XMLHow to check if in checkout if custom module installed?How to add a custom and dynamic block during onepage checkout?How to move Magento Coupon Block from the Cart page to the one page checkoutHow can you add a content block to magento onepage checkout?Add custom field in onepage check out,order,invoice,salesHow to add text block in magento 2 custom moduleHow to add custom content to block layout render by jslayoutHow add div after image block in Magento 2?Magento 2 : Change Comment of Onepage Checkout Email AddressMagento2 - Add Custom fields block after shipping method
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to add custom text block in onepage checkout in #payment page. That block will use to remind the "discount code" to customer, it's like popup text.
Please check the sample image.

magento2 onepage-checkout
add a comment |
I want to add custom text block in onepage checkout in #payment page. That block will use to remind the "discount code" to customer, it's like popup text.
Please check the sample image.

magento2 onepage-checkout
explain position via screenshot and what do you mean by popup text ?
– Hassan Ali Shahzad
yesterday
See this : magento.stackexchange.com/questions/208702/…
– KernelPanic
yesterday
yes @ Hassan....
– mohana
yesterday
Hi @kernel, I like to display like popup text
– mohana
yesterday
Please check my updated question.
– mohana
yesterday
add a comment |
I want to add custom text block in onepage checkout in #payment page. That block will use to remind the "discount code" to customer, it's like popup text.
Please check the sample image.

magento2 onepage-checkout
I want to add custom text block in onepage checkout in #payment page. That block will use to remind the "discount code" to customer, it's like popup text.
Please check the sample image.

magento2 onepage-checkout
magento2 onepage-checkout
edited yesterday
mohana
asked yesterday
mohanamohana
10210
10210
explain position via screenshot and what do you mean by popup text ?
– Hassan Ali Shahzad
yesterday
See this : magento.stackexchange.com/questions/208702/…
– KernelPanic
yesterday
yes @ Hassan....
– mohana
yesterday
Hi @kernel, I like to display like popup text
– mohana
yesterday
Please check my updated question.
– mohana
yesterday
add a comment |
explain position via screenshot and what do you mean by popup text ?
– Hassan Ali Shahzad
yesterday
See this : magento.stackexchange.com/questions/208702/…
– KernelPanic
yesterday
yes @ Hassan....
– mohana
yesterday
Hi @kernel, I like to display like popup text
– mohana
yesterday
Please check my updated question.
– mohana
yesterday
explain position via screenshot and what do you mean by popup text ?
– Hassan Ali Shahzad
yesterday
explain position via screenshot and what do you mean by popup text ?
– Hassan Ali Shahzad
yesterday
See this : magento.stackexchange.com/questions/208702/…
– KernelPanic
yesterday
See this : magento.stackexchange.com/questions/208702/…
– KernelPanic
yesterday
yes @ Hassan....
– mohana
yesterday
yes @ Hassan....
– mohana
yesterday
Hi @kernel, I like to display like popup text
– mohana
yesterday
Hi @kernel, I like to display like popup text
– mohana
yesterday
Please check my updated question.
– mohana
yesterday
Please check my updated question.
– mohana
yesterday
add a comment |
1 Answer
1
active
oldest
votes
Try following way to use magento default popup modal:
app/code/SR/MagentoCommunity/view/frontend/layout/checkout_index_index.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.root">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="checkout" xsi:type="array">
<item name="children" xsi:type="array">
<item name="steps" xsi:type="array">
<item name="children" xsi:type="array">
<item name="billing-step" xsi:type="array">
<item name="children" xsi:type="array">
<item name="payment" xsi:type="array">
<item name="children" xsi:type="array">
<item name="beforeMethods" xsi:type="array">
<item name="children" xsi:type="array">
<item name="custom_block" xsi:type="array">
<item name="component" xsi:type="string">SR_MagentoCommunity/js/view/custom-block</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
app/code/SR/MagentoCommunity/view/frontend/web/js/view/custom-block.js
define([
'jquery',
'ko',
'uiComponent',
'Magento_Ui/js/modal/modal',
'Magento_Checkout/js/view/payment',
'mage/translate'
], function ($, ko, Component, modal, payment, $t)
'use strict';
return Component.extend(
defaults:
template: 'SR_MagentoCommunity/custom-block'
,
options:
popupModalContent: '#sr-discount-popup'
,
shouldShowMessage: ko.observable(false),
initialize: function ()
this._super();
var self = this;
var subscription = payment.prototype.isVisible.subscribe(function(value)
if (value)
var popupModalContent = self.options.popupModalContent;
var modalOption =
type: 'popup',
responsive: true,
title: 'Test Title',
buttons: [],
closed: function ()
self.shouldShowMessage(false);
;
self.shouldShowMessage(true);
$(popupModalContent).modal(modalOption);
$(popupModalContent).trigger('openModal');
subscription.dispose();
);
return this;
,
getMessage: function ()
return $t("Don't forget to use discount code");
);
);
app/code/SR/MagentoCommunity/view/frontend/web/template/custom-block.html
<div id="sr-discount-popup" data-bind="visible:shouldShowMessage">
<span data-bind="text: getMessage()"></span>
</div>
Thank you. @ Sohel
– mohana
yesterday
Please let me know, how to add image instead of text.
– mohana
yesterday
1
Pass image from php checkout config and added that image in html
– Sohel Rana
yesterday
Yeah got it thank you
– mohana
yesterday
@mohana do you manage that?
– Sohel Rana
yesterday
|
show 1 more comment
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269457%2fhow-to-add-custom-text-block-in-onpage-check-out%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try following way to use magento default popup modal:
app/code/SR/MagentoCommunity/view/frontend/layout/checkout_index_index.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.root">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="checkout" xsi:type="array">
<item name="children" xsi:type="array">
<item name="steps" xsi:type="array">
<item name="children" xsi:type="array">
<item name="billing-step" xsi:type="array">
<item name="children" xsi:type="array">
<item name="payment" xsi:type="array">
<item name="children" xsi:type="array">
<item name="beforeMethods" xsi:type="array">
<item name="children" xsi:type="array">
<item name="custom_block" xsi:type="array">
<item name="component" xsi:type="string">SR_MagentoCommunity/js/view/custom-block</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
app/code/SR/MagentoCommunity/view/frontend/web/js/view/custom-block.js
define([
'jquery',
'ko',
'uiComponent',
'Magento_Ui/js/modal/modal',
'Magento_Checkout/js/view/payment',
'mage/translate'
], function ($, ko, Component, modal, payment, $t)
'use strict';
return Component.extend(
defaults:
template: 'SR_MagentoCommunity/custom-block'
,
options:
popupModalContent: '#sr-discount-popup'
,
shouldShowMessage: ko.observable(false),
initialize: function ()
this._super();
var self = this;
var subscription = payment.prototype.isVisible.subscribe(function(value)
if (value)
var popupModalContent = self.options.popupModalContent;
var modalOption =
type: 'popup',
responsive: true,
title: 'Test Title',
buttons: [],
closed: function ()
self.shouldShowMessage(false);
;
self.shouldShowMessage(true);
$(popupModalContent).modal(modalOption);
$(popupModalContent).trigger('openModal');
subscription.dispose();
);
return this;
,
getMessage: function ()
return $t("Don't forget to use discount code");
);
);
app/code/SR/MagentoCommunity/view/frontend/web/template/custom-block.html
<div id="sr-discount-popup" data-bind="visible:shouldShowMessage">
<span data-bind="text: getMessage()"></span>
</div>
Thank you. @ Sohel
– mohana
yesterday
Please let me know, how to add image instead of text.
– mohana
yesterday
1
Pass image from php checkout config and added that image in html
– Sohel Rana
yesterday
Yeah got it thank you
– mohana
yesterday
@mohana do you manage that?
– Sohel Rana
yesterday
|
show 1 more comment
Try following way to use magento default popup modal:
app/code/SR/MagentoCommunity/view/frontend/layout/checkout_index_index.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.root">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="checkout" xsi:type="array">
<item name="children" xsi:type="array">
<item name="steps" xsi:type="array">
<item name="children" xsi:type="array">
<item name="billing-step" xsi:type="array">
<item name="children" xsi:type="array">
<item name="payment" xsi:type="array">
<item name="children" xsi:type="array">
<item name="beforeMethods" xsi:type="array">
<item name="children" xsi:type="array">
<item name="custom_block" xsi:type="array">
<item name="component" xsi:type="string">SR_MagentoCommunity/js/view/custom-block</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
app/code/SR/MagentoCommunity/view/frontend/web/js/view/custom-block.js
define([
'jquery',
'ko',
'uiComponent',
'Magento_Ui/js/modal/modal',
'Magento_Checkout/js/view/payment',
'mage/translate'
], function ($, ko, Component, modal, payment, $t)
'use strict';
return Component.extend(
defaults:
template: 'SR_MagentoCommunity/custom-block'
,
options:
popupModalContent: '#sr-discount-popup'
,
shouldShowMessage: ko.observable(false),
initialize: function ()
this._super();
var self = this;
var subscription = payment.prototype.isVisible.subscribe(function(value)
if (value)
var popupModalContent = self.options.popupModalContent;
var modalOption =
type: 'popup',
responsive: true,
title: 'Test Title',
buttons: [],
closed: function ()
self.shouldShowMessage(false);
;
self.shouldShowMessage(true);
$(popupModalContent).modal(modalOption);
$(popupModalContent).trigger('openModal');
subscription.dispose();
);
return this;
,
getMessage: function ()
return $t("Don't forget to use discount code");
);
);
app/code/SR/MagentoCommunity/view/frontend/web/template/custom-block.html
<div id="sr-discount-popup" data-bind="visible:shouldShowMessage">
<span data-bind="text: getMessage()"></span>
</div>
Thank you. @ Sohel
– mohana
yesterday
Please let me know, how to add image instead of text.
– mohana
yesterday
1
Pass image from php checkout config and added that image in html
– Sohel Rana
yesterday
Yeah got it thank you
– mohana
yesterday
@mohana do you manage that?
– Sohel Rana
yesterday
|
show 1 more comment
Try following way to use magento default popup modal:
app/code/SR/MagentoCommunity/view/frontend/layout/checkout_index_index.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.root">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="checkout" xsi:type="array">
<item name="children" xsi:type="array">
<item name="steps" xsi:type="array">
<item name="children" xsi:type="array">
<item name="billing-step" xsi:type="array">
<item name="children" xsi:type="array">
<item name="payment" xsi:type="array">
<item name="children" xsi:type="array">
<item name="beforeMethods" xsi:type="array">
<item name="children" xsi:type="array">
<item name="custom_block" xsi:type="array">
<item name="component" xsi:type="string">SR_MagentoCommunity/js/view/custom-block</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
app/code/SR/MagentoCommunity/view/frontend/web/js/view/custom-block.js
define([
'jquery',
'ko',
'uiComponent',
'Magento_Ui/js/modal/modal',
'Magento_Checkout/js/view/payment',
'mage/translate'
], function ($, ko, Component, modal, payment, $t)
'use strict';
return Component.extend(
defaults:
template: 'SR_MagentoCommunity/custom-block'
,
options:
popupModalContent: '#sr-discount-popup'
,
shouldShowMessage: ko.observable(false),
initialize: function ()
this._super();
var self = this;
var subscription = payment.prototype.isVisible.subscribe(function(value)
if (value)
var popupModalContent = self.options.popupModalContent;
var modalOption =
type: 'popup',
responsive: true,
title: 'Test Title',
buttons: [],
closed: function ()
self.shouldShowMessage(false);
;
self.shouldShowMessage(true);
$(popupModalContent).modal(modalOption);
$(popupModalContent).trigger('openModal');
subscription.dispose();
);
return this;
,
getMessage: function ()
return $t("Don't forget to use discount code");
);
);
app/code/SR/MagentoCommunity/view/frontend/web/template/custom-block.html
<div id="sr-discount-popup" data-bind="visible:shouldShowMessage">
<span data-bind="text: getMessage()"></span>
</div>
Try following way to use magento default popup modal:
app/code/SR/MagentoCommunity/view/frontend/layout/checkout_index_index.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.root">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="checkout" xsi:type="array">
<item name="children" xsi:type="array">
<item name="steps" xsi:type="array">
<item name="children" xsi:type="array">
<item name="billing-step" xsi:type="array">
<item name="children" xsi:type="array">
<item name="payment" xsi:type="array">
<item name="children" xsi:type="array">
<item name="beforeMethods" xsi:type="array">
<item name="children" xsi:type="array">
<item name="custom_block" xsi:type="array">
<item name="component" xsi:type="string">SR_MagentoCommunity/js/view/custom-block</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
app/code/SR/MagentoCommunity/view/frontend/web/js/view/custom-block.js
define([
'jquery',
'ko',
'uiComponent',
'Magento_Ui/js/modal/modal',
'Magento_Checkout/js/view/payment',
'mage/translate'
], function ($, ko, Component, modal, payment, $t)
'use strict';
return Component.extend(
defaults:
template: 'SR_MagentoCommunity/custom-block'
,
options:
popupModalContent: '#sr-discount-popup'
,
shouldShowMessage: ko.observable(false),
initialize: function ()
this._super();
var self = this;
var subscription = payment.prototype.isVisible.subscribe(function(value)
if (value)
var popupModalContent = self.options.popupModalContent;
var modalOption =
type: 'popup',
responsive: true,
title: 'Test Title',
buttons: [],
closed: function ()
self.shouldShowMessage(false);
;
self.shouldShowMessage(true);
$(popupModalContent).modal(modalOption);
$(popupModalContent).trigger('openModal');
subscription.dispose();
);
return this;
,
getMessage: function ()
return $t("Don't forget to use discount code");
);
);
app/code/SR/MagentoCommunity/view/frontend/web/template/custom-block.html
<div id="sr-discount-popup" data-bind="visible:shouldShowMessage">
<span data-bind="text: getMessage()"></span>
</div>
answered yesterday
Sohel RanaSohel Rana
23.2k34461
23.2k34461
Thank you. @ Sohel
– mohana
yesterday
Please let me know, how to add image instead of text.
– mohana
yesterday
1
Pass image from php checkout config and added that image in html
– Sohel Rana
yesterday
Yeah got it thank you
– mohana
yesterday
@mohana do you manage that?
– Sohel Rana
yesterday
|
show 1 more comment
Thank you. @ Sohel
– mohana
yesterday
Please let me know, how to add image instead of text.
– mohana
yesterday
1
Pass image from php checkout config and added that image in html
– Sohel Rana
yesterday
Yeah got it thank you
– mohana
yesterday
@mohana do you manage that?
– Sohel Rana
yesterday
Thank you. @ Sohel
– mohana
yesterday
Thank you. @ Sohel
– mohana
yesterday
Please let me know, how to add image instead of text.
– mohana
yesterday
Please let me know, how to add image instead of text.
– mohana
yesterday
1
1
Pass image from php checkout config and added that image in html
– Sohel Rana
yesterday
Pass image from php checkout config and added that image in html
– Sohel Rana
yesterday
Yeah got it thank you
– mohana
yesterday
Yeah got it thank you
– mohana
yesterday
@mohana do you manage that?
– Sohel Rana
yesterday
@mohana do you manage that?
– Sohel Rana
yesterday
|
show 1 more comment
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269457%2fhow-to-add-custom-text-block-in-onpage-check-out%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
explain position via screenshot and what do you mean by popup text ?
– Hassan Ali Shahzad
yesterday
See this : magento.stackexchange.com/questions/208702/…
– KernelPanic
yesterday
yes @ Hassan....
– mohana
yesterday
Hi @kernel, I like to display like popup text
– mohana
yesterday
Please check my updated question.
– mohana
yesterday