How to add custom text block in onpage check-out The 2019 Stack Overflow Developer Survey...

Ubuntu Server install with full GUI

How do PCB vias affect signal quality?

Is Cinnamon a desktop environment or a window manager? (Or both?)

Is one supposed to eat the zero'ah (shank bone) from the Seder plate?

Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?

Keeping a retro style to sci-fi spaceships?

How do you keep chess fun when your opponent constantly beats you?

What do these terms in Caesar's Gallic wars mean?

APIPA and LAN Broadcast Domain

Why not take a picture of a closer black hole?

Is it okay to consider publishing in my first year of PhD?

If I can cast sorceries at instant speed, can I use sorcery-speed activated abilities at instant speed?

Loose spokes after only a few rides

How did passengers keep warm on sail ships?

Why doesn't shell automatically fix "useless use of cat"?

A word that means fill it to the required quantity

Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?

Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?

Worn-tile Scrabble

Cooking pasta in a water boiler

How to support a colleague who finds meetings extremely tiring?

Flight paths in orbit around Ceres?

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

What information about me do stores get via my credit card?



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







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
    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


















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
    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














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 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



















  • 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










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
    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












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
    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
















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
    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














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 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



















  • 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


















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

Cannot install PyQt5 The Next CEO of Stack OverflowCannot install tcpreplay 3.4.4cannot...

Kapp-Putsch Acontecimentos | Outros artigos | Menu de navegação

Why did early computer designers eschew integers? The Next CEO of Stack OverflowWhat register...