Add a file uploader to payment method in Magento 2
I have a payment method which I need to add an image uploader. I know Magento has its own file uploader Ui component, but I'm not being able to add it to the payment method.
I have tried to add something like this to the paymentmethod.html file, but apparently this script doesn't work on html.
<div class="upload-wrapper" data-bind="scope: 'uploader'">
<!-- ko template: getTemplate() --><!-- /ko -->
</div>
<script type="text/x-magento-init">
{
".upload-wrapper": {
"Magento_Ui/js/core/app": {
"components": {
"uploader": {
"component": "Magento_Ui/js/form/element/file-uploader",
"template": "ui/form/element/uploader/uploader",
"allowedExtensions": "jpg",
"uploaderConfig": {
"url": "<?php echo $block->getUrl('module/upload/ajax'); ?>"
}
}
}
}
}
}
</script>
I tried to add this component through the js file, but didn't work. I also tried to add a .phtml template to the payment method, but it's just not working. I spent hours researching and just can't get to a solution.
In my mind, in the method renderer js file I need to load the component and then call it on the html file, but how can I do it?
magento2 payment-methods uicomponent file-upload
add a comment |
I have a payment method which I need to add an image uploader. I know Magento has its own file uploader Ui component, but I'm not being able to add it to the payment method.
I have tried to add something like this to the paymentmethod.html file, but apparently this script doesn't work on html.
<div class="upload-wrapper" data-bind="scope: 'uploader'">
<!-- ko template: getTemplate() --><!-- /ko -->
</div>
<script type="text/x-magento-init">
{
".upload-wrapper": {
"Magento_Ui/js/core/app": {
"components": {
"uploader": {
"component": "Magento_Ui/js/form/element/file-uploader",
"template": "ui/form/element/uploader/uploader",
"allowedExtensions": "jpg",
"uploaderConfig": {
"url": "<?php echo $block->getUrl('module/upload/ajax'); ?>"
}
}
}
}
}
}
</script>
I tried to add this component through the js file, but didn't work. I also tried to add a .phtml template to the payment method, but it's just not working. I spent hours researching and just can't get to a solution.
In my mind, in the method renderer js file I need to load the component and then call it on the html file, but how can I do it?
magento2 payment-methods uicomponent file-upload
Someone please help me!
– Filcp
Aug 29 '18 at 19:07
Did You manage to do this? I have same problem.
– Robert Rupa
2 days ago
add a comment |
I have a payment method which I need to add an image uploader. I know Magento has its own file uploader Ui component, but I'm not being able to add it to the payment method.
I have tried to add something like this to the paymentmethod.html file, but apparently this script doesn't work on html.
<div class="upload-wrapper" data-bind="scope: 'uploader'">
<!-- ko template: getTemplate() --><!-- /ko -->
</div>
<script type="text/x-magento-init">
{
".upload-wrapper": {
"Magento_Ui/js/core/app": {
"components": {
"uploader": {
"component": "Magento_Ui/js/form/element/file-uploader",
"template": "ui/form/element/uploader/uploader",
"allowedExtensions": "jpg",
"uploaderConfig": {
"url": "<?php echo $block->getUrl('module/upload/ajax'); ?>"
}
}
}
}
}
}
</script>
I tried to add this component through the js file, but didn't work. I also tried to add a .phtml template to the payment method, but it's just not working. I spent hours researching and just can't get to a solution.
In my mind, in the method renderer js file I need to load the component and then call it on the html file, but how can I do it?
magento2 payment-methods uicomponent file-upload
I have a payment method which I need to add an image uploader. I know Magento has its own file uploader Ui component, but I'm not being able to add it to the payment method.
I have tried to add something like this to the paymentmethod.html file, but apparently this script doesn't work on html.
<div class="upload-wrapper" data-bind="scope: 'uploader'">
<!-- ko template: getTemplate() --><!-- /ko -->
</div>
<script type="text/x-magento-init">
{
".upload-wrapper": {
"Magento_Ui/js/core/app": {
"components": {
"uploader": {
"component": "Magento_Ui/js/form/element/file-uploader",
"template": "ui/form/element/uploader/uploader",
"allowedExtensions": "jpg",
"uploaderConfig": {
"url": "<?php echo $block->getUrl('module/upload/ajax'); ?>"
}
}
}
}
}
}
</script>
I tried to add this component through the js file, but didn't work. I also tried to add a .phtml template to the payment method, but it's just not working. I spent hours researching and just can't get to a solution.
In my mind, in the method renderer js file I need to load the component and then call it on the html file, but how can I do it?
magento2 payment-methods uicomponent file-upload
magento2 payment-methods uicomponent file-upload
edited Aug 29 '18 at 5:45
Ansar Husain
1,670217
1,670217
asked Aug 29 '18 at 5:16
FilcpFilcp
12
12
Someone please help me!
– Filcp
Aug 29 '18 at 19:07
Did You manage to do this? I have same problem.
– Robert Rupa
2 days ago
add a comment |
Someone please help me!
– Filcp
Aug 29 '18 at 19:07
Did You manage to do this? I have same problem.
– Robert Rupa
2 days ago
Someone please help me!
– Filcp
Aug 29 '18 at 19:07
Someone please help me!
– Filcp
Aug 29 '18 at 19:07
Did You manage to do this? I have same problem.
– Robert Rupa
2 days ago
Did You manage to do this? I have same problem.
– Robert Rupa
2 days ago
add a comment |
0
active
oldest
votes
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%2f239994%2fadd-a-file-uploader-to-payment-method-in-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f239994%2fadd-a-file-uploader-to-payment-method-in-magento-2%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
Someone please help me!
– Filcp
Aug 29 '18 at 19:07
Did You manage to do this? I have same problem.
– Robert Rupa
2 days ago