Extend custom button and trigger mage.catalogAddToCartHow do I add a submit button to a UI Component Form?Calling Controller action after running codeMagento 2- How to move custom options after cart button?Custom add to cart button results in 'We can't find product error'How to add 'addToCart' GA event to Add To Cart button on wishlist page?Additional Add to Cart ButtonMagento 2: How to add block inside block html content through XML filehow to pass product page selected value to cart in magento2on add to cart click save custom option data in datbase and display it on cart page in magento2Magento 2.3: How to Echo From Controller On Button Click?
Why is "Congress shall have power to enforce this article by appropriate legislation" necessary?
How do I remove this inheritance-related code smell?
How did the Vostok ejection seat safely eject an astronaut from a sealed space capsule?
What does this Swiss black on yellow rectangular traffic sign with a symbol looking like a dart mean?
What happened to Hopper's girlfriend in season one?
How did Gollum enter Moria?
Extending prime numbers digit by digit while retaining primality
Is declining an undergraduate award which causes me discomfort appropriate?
How can a warlock learn from a spellbook?
What are the current battlegrounds for people’s “rights” in the UK?
What triggered jesuits' ban on infinitesimals in 1632?
Is the continuity test limit resistance of a multimeter standard?
Can the pre-order traversal of two different trees be the same even though they are different?
What does it cost to buy a tavern?
Should I include an appendix for inessential, yet related worldbuilding to my story?
Why is it easier to balance a non-moving bike standing up than sitting down?
I just entered the USA without passport control at Atlanta airport
Dates on degrees don’t make sense – will people care?
What was the first third-party commercial application for MS-DOS?
What is the meaning of "понаехать"?
How could empty set be unique if it could be vacuously false
Mathematically modelling RC circuit with a linear input
Am I legally required to provide a (GPL licensed) source code even after a project is abandoned?
Prisoner on alien planet escapes by making up a story about ghost companions and wins the war
Extend custom button and trigger mage.catalogAddToCart
How do I add a submit button to a UI Component Form?Calling Controller action after running codeMagento 2- How to move custom options after cart button?Custom add to cart button results in 'We can't find product error'How to add 'addToCart' GA event to Add To Cart button on wishlist page?Additional Add to Cart ButtonMagento 2: How to add block inside block html content through XML filehow to pass product page selected value to cart in magento2on add to cart click save custom option data in datbase and display it on cart page in magento2Magento 2.3: How to Echo From Controller On Button Click?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I created a custom button. What I want is for it to trigger the Add to cart
function. Aside from the default add to cart button I want a new add to cart button that will do the same thing. How can I achieve this in Magento 2?
Edit: The reason I want to do this is because my custom button is inside a separate form but what I want is when I click the submit button I want to submit the values of options from other form. I have custom options and have it's value so when I click my submit button I want to submit the value of that other form since the other form containing the custom button only contains the button and no other fields.
magento2 magento2.2 magento2.3 magento-2.0
add a comment |
I created a custom button. What I want is for it to trigger the Add to cart
function. Aside from the default add to cart button I want a new add to cart button that will do the same thing. How can I achieve this in Magento 2?
Edit: The reason I want to do this is because my custom button is inside a separate form but what I want is when I click the submit button I want to submit the values of options from other form. I have custom options and have it's value so when I click my submit button I want to submit the value of that other form since the other form containing the custom button only contains the button and no other fields.
magento2 magento2.2 magento2.3 magento-2.0
add a comment |
I created a custom button. What I want is for it to trigger the Add to cart
function. Aside from the default add to cart button I want a new add to cart button that will do the same thing. How can I achieve this in Magento 2?
Edit: The reason I want to do this is because my custom button is inside a separate form but what I want is when I click the submit button I want to submit the values of options from other form. I have custom options and have it's value so when I click my submit button I want to submit the value of that other form since the other form containing the custom button only contains the button and no other fields.
magento2 magento2.2 magento2.3 magento-2.0
I created a custom button. What I want is for it to trigger the Add to cart
function. Aside from the default add to cart button I want a new add to cart button that will do the same thing. How can I achieve this in Magento 2?
Edit: The reason I want to do this is because my custom button is inside a separate form but what I want is when I click the submit button I want to submit the values of options from other form. I have custom options and have it's value so when I click my submit button I want to submit the value of that other form since the other form containing the custom button only contains the button and no other fields.
magento2 magento2.2 magento2.3 magento-2.0
magento2 magento2.2 magento2.3 magento-2.0
edited Jun 11 at 17:36
MadzQuestioning
asked Jun 11 at 16:32
MadzQuestioningMadzQuestioning
2639
2639
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can place following code to achieve your desired result.
<button class="button" type="button" id="custom_addtocart_button">Add to Cart</button>
<script>
require(['jquery'], function($)
$(document).on('click', '#custom_addtocart_button', function()
$('#product-addtocart-button').trigger('click');
);
)
</script>
This seems a lot cleaner than my solution. Will use this. Thanks
– MadzQuestioning
Jun 12 at 7:41
add a 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%2f277994%2fextend-custom-button-and-trigger-mage-catalogaddtocart%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
You can place following code to achieve your desired result.
<button class="button" type="button" id="custom_addtocart_button">Add to Cart</button>
<script>
require(['jquery'], function($)
$(document).on('click', '#custom_addtocart_button', function()
$('#product-addtocart-button').trigger('click');
);
)
</script>
This seems a lot cleaner than my solution. Will use this. Thanks
– MadzQuestioning
Jun 12 at 7:41
add a comment |
You can place following code to achieve your desired result.
<button class="button" type="button" id="custom_addtocart_button">Add to Cart</button>
<script>
require(['jquery'], function($)
$(document).on('click', '#custom_addtocart_button', function()
$('#product-addtocart-button').trigger('click');
);
)
</script>
This seems a lot cleaner than my solution. Will use this. Thanks
– MadzQuestioning
Jun 12 at 7:41
add a comment |
You can place following code to achieve your desired result.
<button class="button" type="button" id="custom_addtocart_button">Add to Cart</button>
<script>
require(['jquery'], function($)
$(document).on('click', '#custom_addtocart_button', function()
$('#product-addtocart-button').trigger('click');
);
)
</script>
You can place following code to achieve your desired result.
<button class="button" type="button" id="custom_addtocart_button">Add to Cart</button>
<script>
require(['jquery'], function($)
$(document).on('click', '#custom_addtocart_button', function()
$('#product-addtocart-button').trigger('click');
);
)
</script>
answered Jun 12 at 5:04
Yash ShahYash Shah
1,156210
1,156210
This seems a lot cleaner than my solution. Will use this. Thanks
– MadzQuestioning
Jun 12 at 7:41
add a comment |
This seems a lot cleaner than my solution. Will use this. Thanks
– MadzQuestioning
Jun 12 at 7:41
This seems a lot cleaner than my solution. Will use this. Thanks
– MadzQuestioning
Jun 12 at 7:41
This seems a lot cleaner than my solution. Will use this. Thanks
– MadzQuestioning
Jun 12 at 7:41
add a 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%2f277994%2fextend-custom-button-and-trigger-mage-catalogaddtocart%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