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;








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.










share|improve this question






























    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.










    share|improve this question


























      0












      0








      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.










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 11 at 17:36







      MadzQuestioning

















      asked Jun 11 at 16:32









      MadzQuestioningMadzQuestioning

      2639




      2639




















          1 Answer
          1






          active

          oldest

          votes


















          0














          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>





          share|improve this answer























          • This seems a lot cleaner than my solution. Will use this. Thanks

            – MadzQuestioning
            Jun 12 at 7:41











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









          0














          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>





          share|improve this answer























          • This seems a lot cleaner than my solution. Will use this. Thanks

            – MadzQuestioning
            Jun 12 at 7:41















          0














          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>





          share|improve this answer























          • This seems a lot cleaner than my solution. Will use this. Thanks

            – MadzQuestioning
            Jun 12 at 7:41













          0












          0








          0







          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>





          share|improve this answer













          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>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          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

















          • 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

















          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%2f277994%2fextend-custom-button-and-trigger-mage-catalogaddtocart%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

          Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form