Magento 1.9.0.1 Grouped Product Drop Down problem with sub-products quantity












2















I replaced the table view with a drop down view. Now, the file "template/catalog/product/view/type/grouped.phtml" looks like this:



..



<form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" class="add-to-cart" id="product_addtocart_form_<?php echo $_product->getId()?>"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
<div style="float:right;border:1px solid;padding:5px; width: 100%;">
<?php if($_product->isGrouped()): ?>
<?php $_subAssociatedProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product); ?>
<?php if(count($_subAssociatedProducts)){?>
<!--<div class="groupedTitle">Dimensiune / Grosime</div>-->
<select id="grouped_products" name="grouped_products" onchange="addSuperQty('<?php echo $_product->getId()?>',this.value);">
<?php foreach ($_subAssociatedProducts as $_item) {?>
<option value="<?php echo $_item->getId()?>" id="<?php echo number_format($_item->getFinalPrice(),2); ?>"><?php echo $this->htmlEscape($_item->getName())?></option>
<?php } ?>
</select>
<?php }?>
<span id="span_<?php echo $this->getId()?>"></span>
<input type="button" value="-" id="minus1" class="minus" />
<input type="text" size="3" name="qty" onchange="changeQty(this.value,'<?php echo $_product->getId()?>');" id="<?php echo $_product->getId()?>_qty" maxlength="12" value="<?php echo $_product->getProductDefaultQty() * 1 ?>" class="input-text qty" />
<input type="button" value="+" id="add1" class="plus" />
<?php else:?>
<input type="button" value="-" id="minus1" class="minus" />
<input type="text" size="3" name="qty" id="qty" maxlength="12" value="<?php echo $_product->getProductDefaultQty() * 1 ?>" class="input-text qty" />
<input type="button" value="+" id="add1" class="plus" />

<?php endif; ?>
<button type="button" class="button btn-cart" onclick="this.form.submit()"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
</div>
</form>


..



<script type="text/javascript">
function addSuperQty(spanId,itemId)
{
var qty = document.getElementById(spanId+'_qty').value;
var ID = 'span_'+spanId;
document.getElementById(ID).innerHTML = '<input type="hidden" value="'+qty+'" id="super_group_'+spanId+'" name="super_group['+itemId+']" />';
}

function changeQty(val,itemId)
{
document.getElementById('super_group_'+itemId).value = val;
}
</script>


For all my grouped products, the default value is 0. So this:



<?php echo $_product->getProductDefaultQty() * 1 ?>


Displays 0 for the quantity each time. What is wrong? On older Magento versions it worked.



When I set a bigger product quantity and try to add the product (sub product) into my account, I receive this error: Please specify the quantity of product(s).



Please help me to fix the problem. Thanks!










share|improve this question





























    2















    I replaced the table view with a drop down view. Now, the file "template/catalog/product/view/type/grouped.phtml" looks like this:



    ..



    <form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" class="add-to-cart" id="product_addtocart_form_<?php echo $_product->getId()?>"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
    <div style="float:right;border:1px solid;padding:5px; width: 100%;">
    <?php if($_product->isGrouped()): ?>
    <?php $_subAssociatedProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product); ?>
    <?php if(count($_subAssociatedProducts)){?>
    <!--<div class="groupedTitle">Dimensiune / Grosime</div>-->
    <select id="grouped_products" name="grouped_products" onchange="addSuperQty('<?php echo $_product->getId()?>',this.value);">
    <?php foreach ($_subAssociatedProducts as $_item) {?>
    <option value="<?php echo $_item->getId()?>" id="<?php echo number_format($_item->getFinalPrice(),2); ?>"><?php echo $this->htmlEscape($_item->getName())?></option>
    <?php } ?>
    </select>
    <?php }?>
    <span id="span_<?php echo $this->getId()?>"></span>
    <input type="button" value="-" id="minus1" class="minus" />
    <input type="text" size="3" name="qty" onchange="changeQty(this.value,'<?php echo $_product->getId()?>');" id="<?php echo $_product->getId()?>_qty" maxlength="12" value="<?php echo $_product->getProductDefaultQty() * 1 ?>" class="input-text qty" />
    <input type="button" value="+" id="add1" class="plus" />
    <?php else:?>
    <input type="button" value="-" id="minus1" class="minus" />
    <input type="text" size="3" name="qty" id="qty" maxlength="12" value="<?php echo $_product->getProductDefaultQty() * 1 ?>" class="input-text qty" />
    <input type="button" value="+" id="add1" class="plus" />

    <?php endif; ?>
    <button type="button" class="button btn-cart" onclick="this.form.submit()"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
    </div>
    </form>


    ..



    <script type="text/javascript">
    function addSuperQty(spanId,itemId)
    {
    var qty = document.getElementById(spanId+'_qty').value;
    var ID = 'span_'+spanId;
    document.getElementById(ID).innerHTML = '<input type="hidden" value="'+qty+'" id="super_group_'+spanId+'" name="super_group['+itemId+']" />';
    }

    function changeQty(val,itemId)
    {
    document.getElementById('super_group_'+itemId).value = val;
    }
    </script>


    For all my grouped products, the default value is 0. So this:



    <?php echo $_product->getProductDefaultQty() * 1 ?>


    Displays 0 for the quantity each time. What is wrong? On older Magento versions it worked.



    When I set a bigger product quantity and try to add the product (sub product) into my account, I receive this error: Please specify the quantity of product(s).



    Please help me to fix the problem. Thanks!










    share|improve this question



























      2












      2








      2








      I replaced the table view with a drop down view. Now, the file "template/catalog/product/view/type/grouped.phtml" looks like this:



      ..



      <form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" class="add-to-cart" id="product_addtocart_form_<?php echo $_product->getId()?>"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
      <div style="float:right;border:1px solid;padding:5px; width: 100%;">
      <?php if($_product->isGrouped()): ?>
      <?php $_subAssociatedProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product); ?>
      <?php if(count($_subAssociatedProducts)){?>
      <!--<div class="groupedTitle">Dimensiune / Grosime</div>-->
      <select id="grouped_products" name="grouped_products" onchange="addSuperQty('<?php echo $_product->getId()?>',this.value);">
      <?php foreach ($_subAssociatedProducts as $_item) {?>
      <option value="<?php echo $_item->getId()?>" id="<?php echo number_format($_item->getFinalPrice(),2); ?>"><?php echo $this->htmlEscape($_item->getName())?></option>
      <?php } ?>
      </select>
      <?php }?>
      <span id="span_<?php echo $this->getId()?>"></span>
      <input type="button" value="-" id="minus1" class="minus" />
      <input type="text" size="3" name="qty" onchange="changeQty(this.value,'<?php echo $_product->getId()?>');" id="<?php echo $_product->getId()?>_qty" maxlength="12" value="<?php echo $_product->getProductDefaultQty() * 1 ?>" class="input-text qty" />
      <input type="button" value="+" id="add1" class="plus" />
      <?php else:?>
      <input type="button" value="-" id="minus1" class="minus" />
      <input type="text" size="3" name="qty" id="qty" maxlength="12" value="<?php echo $_product->getProductDefaultQty() * 1 ?>" class="input-text qty" />
      <input type="button" value="+" id="add1" class="plus" />

      <?php endif; ?>
      <button type="button" class="button btn-cart" onclick="this.form.submit()"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
      </div>
      </form>


      ..



      <script type="text/javascript">
      function addSuperQty(spanId,itemId)
      {
      var qty = document.getElementById(spanId+'_qty').value;
      var ID = 'span_'+spanId;
      document.getElementById(ID).innerHTML = '<input type="hidden" value="'+qty+'" id="super_group_'+spanId+'" name="super_group['+itemId+']" />';
      }

      function changeQty(val,itemId)
      {
      document.getElementById('super_group_'+itemId).value = val;
      }
      </script>


      For all my grouped products, the default value is 0. So this:



      <?php echo $_product->getProductDefaultQty() * 1 ?>


      Displays 0 for the quantity each time. What is wrong? On older Magento versions it worked.



      When I set a bigger product quantity and try to add the product (sub product) into my account, I receive this error: Please specify the quantity of product(s).



      Please help me to fix the problem. Thanks!










      share|improve this question
















      I replaced the table view with a drop down view. Now, the file "template/catalog/product/view/type/grouped.phtml" looks like this:



      ..



      <form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" class="add-to-cart" id="product_addtocart_form_<?php echo $_product->getId()?>"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
      <div style="float:right;border:1px solid;padding:5px; width: 100%;">
      <?php if($_product->isGrouped()): ?>
      <?php $_subAssociatedProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product); ?>
      <?php if(count($_subAssociatedProducts)){?>
      <!--<div class="groupedTitle">Dimensiune / Grosime</div>-->
      <select id="grouped_products" name="grouped_products" onchange="addSuperQty('<?php echo $_product->getId()?>',this.value);">
      <?php foreach ($_subAssociatedProducts as $_item) {?>
      <option value="<?php echo $_item->getId()?>" id="<?php echo number_format($_item->getFinalPrice(),2); ?>"><?php echo $this->htmlEscape($_item->getName())?></option>
      <?php } ?>
      </select>
      <?php }?>
      <span id="span_<?php echo $this->getId()?>"></span>
      <input type="button" value="-" id="minus1" class="minus" />
      <input type="text" size="3" name="qty" onchange="changeQty(this.value,'<?php echo $_product->getId()?>');" id="<?php echo $_product->getId()?>_qty" maxlength="12" value="<?php echo $_product->getProductDefaultQty() * 1 ?>" class="input-text qty" />
      <input type="button" value="+" id="add1" class="plus" />
      <?php else:?>
      <input type="button" value="-" id="minus1" class="minus" />
      <input type="text" size="3" name="qty" id="qty" maxlength="12" value="<?php echo $_product->getProductDefaultQty() * 1 ?>" class="input-text qty" />
      <input type="button" value="+" id="add1" class="plus" />

      <?php endif; ?>
      <button type="button" class="button btn-cart" onclick="this.form.submit()"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
      </div>
      </form>


      ..



      <script type="text/javascript">
      function addSuperQty(spanId,itemId)
      {
      var qty = document.getElementById(spanId+'_qty').value;
      var ID = 'span_'+spanId;
      document.getElementById(ID).innerHTML = '<input type="hidden" value="'+qty+'" id="super_group_'+spanId+'" name="super_group['+itemId+']" />';
      }

      function changeQty(val,itemId)
      {
      document.getElementById('super_group_'+itemId).value = val;
      }
      </script>


      For all my grouped products, the default value is 0. So this:



      <?php echo $_product->getProductDefaultQty() * 1 ?>


      Displays 0 for the quantity each time. What is wrong? On older Magento versions it worked.



      When I set a bigger product quantity and try to add the product (sub product) into my account, I receive this error: Please specify the quantity of product(s).



      Please help me to fix the problem. Thanks!







      product ce-1.9.0.1 grouped-products customer-account quantity






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 28 '14 at 21:25







      Pascut

















      asked Oct 28 '14 at 5:17









      PascutPascut

      219518




      219518






















          3 Answers
          3






          active

          oldest

          votes


















          3














          The name of the input box is wrong in your case. It must be super_group[#item_id]. Please replace item_id with the actual #item id. You can achieve it using jquery/javascript, etc.






          share|improve this answer
























          • I'm using javascript. Please take a look again at the code from above. I added the js part. Still not working.

            – Pascut
            Oct 28 '14 at 21:26











          • It was a javascript error. Thanks for telling me about js :)

            – Pascut
            Oct 28 '14 at 21:36





















          1














          I've found the problem.
          I used $this instead of $_product on this line:



          <span id="span_<?php echo $this->getId()?>"></span>


          So now I have:



          <span id="span_<?php echo $_product->getId()?>"></span>


          There was a JavaScript error. I was too sleepy to notice this error. (use Firebug)






          share|improve this answer































            0














            I'm trying to apply the same as Pascut, the first block of code I assume it fully replaces the file "template/catalog/product/view/type/grouped.phtml". The second javascript block, where should I put it? I tried but doesnt work.



            Thanks






            share|improve this answer








            New contributor




            pindapoe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.




















              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%2f41602%2fmagento-1-9-0-1-grouped-product-drop-down-problem-with-sub-products-quantity%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              3














              The name of the input box is wrong in your case. It must be super_group[#item_id]. Please replace item_id with the actual #item id. You can achieve it using jquery/javascript, etc.






              share|improve this answer
























              • I'm using javascript. Please take a look again at the code from above. I added the js part. Still not working.

                – Pascut
                Oct 28 '14 at 21:26











              • It was a javascript error. Thanks for telling me about js :)

                – Pascut
                Oct 28 '14 at 21:36


















              3














              The name of the input box is wrong in your case. It must be super_group[#item_id]. Please replace item_id with the actual #item id. You can achieve it using jquery/javascript, etc.






              share|improve this answer
























              • I'm using javascript. Please take a look again at the code from above. I added the js part. Still not working.

                – Pascut
                Oct 28 '14 at 21:26











              • It was a javascript error. Thanks for telling me about js :)

                – Pascut
                Oct 28 '14 at 21:36
















              3












              3








              3







              The name of the input box is wrong in your case. It must be super_group[#item_id]. Please replace item_id with the actual #item id. You can achieve it using jquery/javascript, etc.






              share|improve this answer













              The name of the input box is wrong in your case. It must be super_group[#item_id]. Please replace item_id with the actual #item id. You can achieve it using jquery/javascript, etc.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Oct 28 '14 at 5:54









              Nasir PerwaizNasir Perwaiz

              75449




              75449













              • I'm using javascript. Please take a look again at the code from above. I added the js part. Still not working.

                – Pascut
                Oct 28 '14 at 21:26











              • It was a javascript error. Thanks for telling me about js :)

                – Pascut
                Oct 28 '14 at 21:36





















              • I'm using javascript. Please take a look again at the code from above. I added the js part. Still not working.

                – Pascut
                Oct 28 '14 at 21:26











              • It was a javascript error. Thanks for telling me about js :)

                – Pascut
                Oct 28 '14 at 21:36



















              I'm using javascript. Please take a look again at the code from above. I added the js part. Still not working.

              – Pascut
              Oct 28 '14 at 21:26





              I'm using javascript. Please take a look again at the code from above. I added the js part. Still not working.

              – Pascut
              Oct 28 '14 at 21:26













              It was a javascript error. Thanks for telling me about js :)

              – Pascut
              Oct 28 '14 at 21:36







              It was a javascript error. Thanks for telling me about js :)

              – Pascut
              Oct 28 '14 at 21:36















              1














              I've found the problem.
              I used $this instead of $_product on this line:



              <span id="span_<?php echo $this->getId()?>"></span>


              So now I have:



              <span id="span_<?php echo $_product->getId()?>"></span>


              There was a JavaScript error. I was too sleepy to notice this error. (use Firebug)






              share|improve this answer




























                1














                I've found the problem.
                I used $this instead of $_product on this line:



                <span id="span_<?php echo $this->getId()?>"></span>


                So now I have:



                <span id="span_<?php echo $_product->getId()?>"></span>


                There was a JavaScript error. I was too sleepy to notice this error. (use Firebug)






                share|improve this answer


























                  1












                  1








                  1







                  I've found the problem.
                  I used $this instead of $_product on this line:



                  <span id="span_<?php echo $this->getId()?>"></span>


                  So now I have:



                  <span id="span_<?php echo $_product->getId()?>"></span>


                  There was a JavaScript error. I was too sleepy to notice this error. (use Firebug)






                  share|improve this answer













                  I've found the problem.
                  I used $this instead of $_product on this line:



                  <span id="span_<?php echo $this->getId()?>"></span>


                  So now I have:



                  <span id="span_<?php echo $_product->getId()?>"></span>


                  There was a JavaScript error. I was too sleepy to notice this error. (use Firebug)







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Oct 28 '14 at 21:36









                  PascutPascut

                  219518




                  219518























                      0














                      I'm trying to apply the same as Pascut, the first block of code I assume it fully replaces the file "template/catalog/product/view/type/grouped.phtml". The second javascript block, where should I put it? I tried but doesnt work.



                      Thanks






                      share|improve this answer








                      New contributor




                      pindapoe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.

























                        0














                        I'm trying to apply the same as Pascut, the first block of code I assume it fully replaces the file "template/catalog/product/view/type/grouped.phtml". The second javascript block, where should I put it? I tried but doesnt work.



                        Thanks






                        share|improve this answer








                        New contributor




                        pindapoe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.























                          0












                          0








                          0







                          I'm trying to apply the same as Pascut, the first block of code I assume it fully replaces the file "template/catalog/product/view/type/grouped.phtml". The second javascript block, where should I put it? I tried but doesnt work.



                          Thanks






                          share|improve this answer








                          New contributor




                          pindapoe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.










                          I'm trying to apply the same as Pascut, the first block of code I assume it fully replaces the file "template/catalog/product/view/type/grouped.phtml". The second javascript block, where should I put it? I tried but doesnt work.



                          Thanks







                          share|improve this answer








                          New contributor




                          pindapoe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          share|improve this answer



                          share|improve this answer






                          New contributor




                          pindapoe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          answered 20 mins ago









                          pindapoepindapoe

                          1




                          1




                          New contributor




                          pindapoe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.





                          New contributor





                          pindapoe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






                          pindapoe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






























                              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%2f41602%2fmagento-1-9-0-1-grouped-product-drop-down-problem-with-sub-products-quantity%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

                              What other Star Trek series did the main TNG cast show up in?

                              Berlina muro

                              Berlina aerponto