How to add custom text block in onpage check-out





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







2















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.



enter image description here










share|improve this question

























  • explain position via screenshot and what do you mean by popup text ?

    – Hassan Ali Shahzad
    2 days ago











  • See this : magento.stackexchange.com/questions/208702/…

    – KernelPanic
    2 days ago











  • yes @ Hassan....

    – mohana
    2 days ago











  • Hi @kernel, I like to display like popup text

    – mohana
    2 days ago











  • Please check my updated question.

    – mohana
    2 days ago


















2















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.



enter image description here










share|improve this question

























  • explain position via screenshot and what do you mean by popup text ?

    – Hassan Ali Shahzad
    2 days ago











  • See this : magento.stackexchange.com/questions/208702/…

    – KernelPanic
    2 days ago











  • yes @ Hassan....

    – mohana
    2 days ago











  • Hi @kernel, I like to display like popup text

    – mohana
    2 days ago











  • Please check my updated question.

    – mohana
    2 days ago














2












2








2








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.



enter image description here










share|improve this question
















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.



enter image description here







magento2 onepage-checkout






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago







mohana

















asked 2 days ago









mohanamohana

4713




4713













  • explain position via screenshot and what do you mean by popup text ?

    – Hassan Ali Shahzad
    2 days ago











  • See this : magento.stackexchange.com/questions/208702/…

    – KernelPanic
    2 days ago











  • yes @ Hassan....

    – mohana
    2 days ago











  • Hi @kernel, I like to display like popup text

    – mohana
    2 days ago











  • Please check my updated question.

    – mohana
    2 days ago



















  • explain position via screenshot and what do you mean by popup text ?

    – Hassan Ali Shahzad
    2 days ago











  • See this : magento.stackexchange.com/questions/208702/…

    – KernelPanic
    2 days ago











  • yes @ Hassan....

    – mohana
    2 days ago











  • Hi @kernel, I like to display like popup text

    – mohana
    2 days ago











  • Please check my updated question.

    – mohana
    2 days ago

















explain position via screenshot and what do you mean by popup text ?

– Hassan Ali Shahzad
2 days ago





explain position via screenshot and what do you mean by popup text ?

– Hassan Ali Shahzad
2 days ago













See this : magento.stackexchange.com/questions/208702/…

– KernelPanic
2 days ago





See this : magento.stackexchange.com/questions/208702/…

– KernelPanic
2 days ago













yes @ Hassan....

– mohana
2 days ago





yes @ Hassan....

– mohana
2 days ago













Hi @kernel, I like to display like popup text

– mohana
2 days ago





Hi @kernel, I like to display like popup text

– mohana
2 days ago













Please check my updated question.

– mohana
2 days ago





Please check my updated question.

– mohana
2 days ago










1 Answer
1






active

oldest

votes


















3














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>





share|improve this answer
























  • Thank you. @ Sohel

    – mohana
    2 days ago











  • Please let me know, how to add image instead of text.

    – mohana
    2 days ago






  • 1





    Pass image from php checkout config and added that image in html

    – Sohel Rana
    2 days ago











  • Yeah got it thank you

    – mohana
    2 days ago











  • @mohana do you manage that?

    – Sohel Rana
    2 days ago












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
});


}
});














draft saved

draft discarded


















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









3














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>





share|improve this answer
























  • Thank you. @ Sohel

    – mohana
    2 days ago











  • Please let me know, how to add image instead of text.

    – mohana
    2 days ago






  • 1





    Pass image from php checkout config and added that image in html

    – Sohel Rana
    2 days ago











  • Yeah got it thank you

    – mohana
    2 days ago











  • @mohana do you manage that?

    – Sohel Rana
    2 days ago
















3














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>





share|improve this answer
























  • Thank you. @ Sohel

    – mohana
    2 days ago











  • Please let me know, how to add image instead of text.

    – mohana
    2 days ago






  • 1





    Pass image from php checkout config and added that image in html

    – Sohel Rana
    2 days ago











  • Yeah got it thank you

    – mohana
    2 days ago











  • @mohana do you manage that?

    – Sohel Rana
    2 days ago














3












3








3







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>





share|improve this answer













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>






share|improve this answer












share|improve this answer



share|improve this answer










answered 2 days ago









Sohel RanaSohel Rana

23.3k34461




23.3k34461













  • Thank you. @ Sohel

    – mohana
    2 days ago











  • Please let me know, how to add image instead of text.

    – mohana
    2 days ago






  • 1





    Pass image from php checkout config and added that image in html

    – Sohel Rana
    2 days ago











  • Yeah got it thank you

    – mohana
    2 days ago











  • @mohana do you manage that?

    – Sohel Rana
    2 days ago



















  • Thank you. @ Sohel

    – mohana
    2 days ago











  • Please let me know, how to add image instead of text.

    – mohana
    2 days ago






  • 1





    Pass image from php checkout config and added that image in html

    – Sohel Rana
    2 days ago











  • Yeah got it thank you

    – mohana
    2 days ago











  • @mohana do you manage that?

    – Sohel Rana
    2 days ago

















Thank you. @ Sohel

– mohana
2 days ago





Thank you. @ Sohel

– mohana
2 days ago













Please let me know, how to add image instead of text.

– mohana
2 days ago





Please let me know, how to add image instead of text.

– mohana
2 days ago




1




1





Pass image from php checkout config and added that image in html

– Sohel Rana
2 days ago





Pass image from php checkout config and added that image in html

– Sohel Rana
2 days ago













Yeah got it thank you

– mohana
2 days ago





Yeah got it thank you

– mohana
2 days ago













@mohana do you manage that?

– Sohel Rana
2 days ago





@mohana do you manage that?

– Sohel Rana
2 days ago


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

How did Captain America manage to do this?

迪纳利

南乌拉尔铁路局