Magento 2 How to add configurable product to cart in product view page?How to add multiple products to cart magento 2Add to cart issue - Magento 2.1How to add Please Select option in programmatically created select attribute for products?How to add custom options programmatically for configurable product in Magento 2Product attribute not visible in admin , when creating configurable productMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento2 How to Show Sepereatly Configurable Product attribute and Product Custom OptionsMagento 2 add products to cart by using code?Product name in cart for configurable product?How to add custom option before adding to cart by code in Magento 2?

Are hand made posters acceptable in Academia?

How do I prevent inappropriate ads from appearing in my game?

"Marked down as someone wanting to sell shares." What does that mean?

Why didn't Voldemort know what Grindelwald looked like?

Highest stage count that are used one right after the other?

Should I be concerned about student access to a test bank?

What is the purpose of using a decision tree?

Weird lines in Microsoft Word

Did I make a mistake by ccing email to boss to others?

Why does the Persian emissary display a string of crowned skulls?

Why is participating in the European Parliamentary elections used as a threat?

PTIJ: Which Dr. Seuss books should one obtain?

Does capillary rise violate hydrostatic paradox?

How can I, as DM, avoid the Conga Line of Death occurring when implementing some form of flanking rule?

New Order #2: Turn My Way

If the Dominion rule using their Jem'Hadar troops, why is their life expectancy so low?

Travelling in US for more than 90 days

Is this saw blade faulty?

Turning a hard to access nut?

Friend wants my recommendation but I don't want to give it to him

I keep switching characters, how do I stop?

How to preserve electronics (computers, ipads, phones) for hundreds of years?

Is there any common country to visit for persons holding UK and Schengen visas?

Why do Radio Buttons not fill the entire outer circle?



Magento 2 How to add configurable product to cart in product view page?


How to add multiple products to cart magento 2Add to cart issue - Magento 2.1How to add Please Select option in programmatically created select attribute for products?How to add custom options programmatically for configurable product in Magento 2Product attribute not visible in admin , when creating configurable productMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento2 How to Show Sepereatly Configurable Product attribute and Product Custom OptionsMagento 2 add products to cart by using code?Product name in cart for configurable product?How to add custom option before adding to cart by code in Magento 2?













0















How can I add Configurable Product to shopping cart in product view page ? I try this code to show the custom option.`



$customOptions = $_objectManager->get('MagentoCatalogModelProductOption')->getProductOptionCollection($_product);
$optStr = "";
foreach($customOptions as $optionKey => $optionVal):
$optStr .= "<div class='custom-options'><label>".$optionVal->getTitle()." </label>";
$optStr .= "<select name='options[".$optionVal->getId()."]'>";
foreach($optionVal->getValues() as $valuesKey => $valuesVal)
$optStr .= "<option value='".$valuesVal->getId()."'>".$valuesVal->getTitle()."</option>";

$optStr .= "</select></div>";
endforeach;
echo($optStr);


Custom options are shown but when I tried to add to cart, it doesn't work.










share|improve this question




























    0















    How can I add Configurable Product to shopping cart in product view page ? I try this code to show the custom option.`



    $customOptions = $_objectManager->get('MagentoCatalogModelProductOption')->getProductOptionCollection($_product);
    $optStr = "";
    foreach($customOptions as $optionKey => $optionVal):
    $optStr .= "<div class='custom-options'><label>".$optionVal->getTitle()." </label>";
    $optStr .= "<select name='options[".$optionVal->getId()."]'>";
    foreach($optionVal->getValues() as $valuesKey => $valuesVal)
    $optStr .= "<option value='".$valuesVal->getId()."'>".$valuesVal->getTitle()."</option>";

    $optStr .= "</select></div>";
    endforeach;
    echo($optStr);


    Custom options are shown but when I tried to add to cart, it doesn't work.










    share|improve this question


























      0












      0








      0








      How can I add Configurable Product to shopping cart in product view page ? I try this code to show the custom option.`



      $customOptions = $_objectManager->get('MagentoCatalogModelProductOption')->getProductOptionCollection($_product);
      $optStr = "";
      foreach($customOptions as $optionKey => $optionVal):
      $optStr .= "<div class='custom-options'><label>".$optionVal->getTitle()." </label>";
      $optStr .= "<select name='options[".$optionVal->getId()."]'>";
      foreach($optionVal->getValues() as $valuesKey => $valuesVal)
      $optStr .= "<option value='".$valuesVal->getId()."'>".$valuesVal->getTitle()."</option>";

      $optStr .= "</select></div>";
      endforeach;
      echo($optStr);


      Custom options are shown but when I tried to add to cart, it doesn't work.










      share|improve this question
















      How can I add Configurable Product to shopping cart in product view page ? I try this code to show the custom option.`



      $customOptions = $_objectManager->get('MagentoCatalogModelProductOption')->getProductOptionCollection($_product);
      $optStr = "";
      foreach($customOptions as $optionKey => $optionVal):
      $optStr .= "<div class='custom-options'><label>".$optionVal->getTitle()." </label>";
      $optStr .= "<select name='options[".$optionVal->getId()."]'>";
      foreach($optionVal->getValues() as $valuesKey => $valuesVal)
      $optStr .= "<option value='".$valuesVal->getId()."'>".$valuesVal->getTitle()."</option>";

      $optStr .= "</select></div>";
      endforeach;
      echo($optStr);


      Custom options are shown but when I tried to add to cart, it doesn't work.







      magento2






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 17 hours ago







      Viji

















      asked 19 hours ago









      VijiViji

      155




      155




















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



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266503%2fmagento-2-how-to-add-configurable-product-to-cart-in-product-view-page%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















          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%2f266503%2fmagento-2-how-to-add-configurable-product-to-cart-in-product-view-page%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

          Sum ergo cogito? 1 nng

          419 nièngy_Soadمي 19bal1.5o_g

          Queiggey Chernihivv 9NnOo i Zw X QqKk LpB