Developer forum

Forum » Ecommerce - Standard features » Change quantity of products in BOM

Change quantity of products in BOM

Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Hi,

I'm working with BOM and would like to give the customer the ability, to change the quantity of the products inside the BOM.

I already iterate through the BOMProductItems, but haven't been able to find examples of setting the quantity of the BOM-products anywhere, other than retrieving the quantity from the orderlines at the cart.

Best regards
Kurt Moskjaer Andersen


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Kurt

You can add a field with name="{Bom-item-Id}Quantity" with the number you want to add. You have 2 scenarios - where you have just one product in the configuration or where you have a group of products to choose from:

For BOM products (just one product in the config, loop

LoopStart(BOMProductItems)

<input type="number" name="<!--@Ecom:Product.Item.ID-->Quantity">

LoopEnd(BOMProductItems)

You have something similar to this on bom configurators:

<!--@LoopStart(BOMConfigurators)-->
<tr>
  <td>
  <b><!--@Ecom:Product.Configurator.Name--></b><br>
      <select name="<!--@Ecom:Product.Configurator.ID-->">
          <!--@LoopStart(ConfiguratorProducts)-->
          <option value="<!--@Ecom:Product.ID-->" <!--@Ecom:Product.Configurator.Selected-->><!--@Ecom:Product.Name--> (<!--@Ecom:Product.ActualPrice-->)</option>

<input type="number" name="<!--@Ecom:Product.Configurator.ID-->Quantity">
          <!--@LoopEnd(ConfiguratorProducts)-->
      </select>


  </td>
</tr>    
<!--@LoopEnd(BOMConfigurators)-->

 

Votes for this answer: 1
 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Hi Nicolai,

Perfect, just what I needed :)

/Kurt

 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

A quick side-question:

I have listed the BOM-items on the product page, but whenever I change the quantity of one of the items and add the top-product to the cart, the total quantity of the top-product is changed, but not the quantity of the BOM-item.

/Kurt

Screenshot_6.png
 
Nicolai Pedersen
Reply

Sounds like a wrong context you submit the quantity in. Can you provide your template code?

 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

In short, this is how the form is made, on the product-page:

--

<form name="@GetString("Ecom:Product.ID")" id="PRODFORM_@GetString("Ecom:Product.ID")" method="get" Action="Default.aspx?ID=@GetString("Ecom:Product:Page.ID")">
    @GetString("Ecom:Product.Form")
 
var BOMItems = GetLoop("BOMProductItems");
if (BOMProducts.Any()) {
foreach (var BOM in BOMItems) {
<input type="number" class="form__input  form__input--minor" value="1" name="@BOM.GetString("Ecom:Product.Item.ID")Quantity">
}
}
<button class="button button--right js-toggle-class" data-toggle-class="product--extra-active" onclick="$('#PRODFORM_@GetString("Ecom:Product.ID")').submit();" data-toggle-target="#bestilling"> <span class="icon icon--inline"> &#xf00c; </span> Bestil varer </button>
</form>
 
Nicolai Pedersen
Reply

Which version are you using?

 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

I'm using version 8.8.1.6

 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

I won't post the url to the solution here, but I can send it to you in an e-mail

/Kurt

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Kurt

OK - feature was implemented in 8.7, so you should be ok. See template snippet below - I think I gave you some wrong info on the naming of the quantity field.-

 

<div id="includingproducts">

<!--@LoopStart(BOMProducts)-->

<!--@HeaderStart-->

<h2>

Including products</h2>

<ul>

<!--@HeaderEnd-->

<input type="text" value="1" name="<!--@Ecom:Product.ID-->Quantity" />

<li class="listitem<!--@BOMProducts.LoopMod2-->"><a href="<!--@Ecom:Product.Link.Clean.PID-->">

<!--@Ecom:Product.Name-->

</a></li>

<!--@FooterStart-->

</ul>

<!--@FooterEnd-->

<!--@LoopEnd(BOMProducts)-->

<table cellspacing="0" cellpadding="0" border="0">

<!--@LoopStart(BOMConfigurators)-->

 

<tr>

<td>

<b><!--@Ecom:Product.Configurator.Name--></b><br>

<input type="text" value="1" name="<!--@Ecom:Product.Configurator.ID-->Quantity" />

<select name="<!--@Ecom:Product.Configurator.ID-->">

<option value="">Nothing</option>

<!--@LoopStart(ConfiguratorProducts)-->

<option value="<!--@Ecom:Product.ID-->" <!--@Ecom:Product.Configurator.Selected-->><!--@Ecom:Product.Name--> (<!--@Ecom:Product.ActualPrice-->)</option>

<!--@LoopEnd(ConfiguratorProducts)-->

</SELECT>

</td>

</tr>

<!--@LoopEnd(BOMConfigurators)-->

</table>

Votes for this answer: 1
 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Well, I've tried it, but it just adds a separate product to the cart, without product number and name, but on a separate orderline.

/Kurt

Screenshot_3.png
 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

And it doesn't matter if I use the BOMProducts or the BOMProductItems loop.

 
Nicolai Pedersen
Reply

Hi Kurt

I cannot answer what is wrong. We need to take a look at the implementation, and for that we need the URL.

I've send this thread to service desk so they can contact you - or feel free to create a case.

BR Nicolai

 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Thanks, Nicolai. I will look into it further and submit a case, if needed.

/Kurt

 
Aki Ruuskanen
Aki Ruuskanen
Reply

Hi,

I have a similiar problem. 

I can select different quantities for the BOMProducts. So thats fine. 

But if a select for example 100 of the main product, all the BOMProducts also get 100 in quantity. 

And if an select "3" for one of the BOMProducts and "10" on the main product, the BOMProduct gets "13" as quantity. 

Testpage: http://rapidodemo.softgear.se/english/testproducts/massa-och-event/visitkort-standard

Code:

<form action="" method="post" class="">
    <div class="row no-gutters product-quantity-controller">
        <div class="col-3 col-lg-2 amount">
            <input type="hidden" name="productid" value='@GetValue("Ecom:Product.ID")'>
            <input type="hidden" name="cartcmd" value="add">
            Antal:<input id="quantity" ="NumericQuantityText w-100 h-100 text-center border-0" maxlength="4" name="quantity" type="text" value="1">
        </div>
    <div>
    @* BOMProducts *@
    @if (GetLoop("BOMProducts").Count > 0)
    {
        <h2 class="section-title">Dessa följer med</h2>
        foreach (LoopItem BOMProductItem in GetLoop("BOMProducts"))
        {
            string link = "/" + BOMProductItem.GetString("Ecom:Product.LinkGroup.Clean") + (!String.IsNullOrEmpty(BOMProductItem.GetString("Ecom:Product.VariantID")) ? "&VariantID=" + BOMProductItem.GetString("Ecom:Product.VariantID") : "");
            <div class="grid__col--border grid">
                <div class="grid__cell grid__cell--align-middle-left">
                    <a href="@link" class="u-pull--left u-margin-right">
                        <img src="/Admin/Public/GetImage.ashx?width=50&image=@BOMProductItem.GetString("Ecom:Product.ImageSmall.Default.Clean")&Compression=99" />
                    </a>
                    <a href="@link">@BOMProductItem.GetString("Ecom:Product.Name") - @BOMProductItem.GetString("Ecom:Product.Price")</a>
                </div>
            </div>
        }
    }
    <h2>Välj utrustning:</h2>
    @foreach(LoopItem li in GetLoop("BOMConfigurators")){
        <div>
        <h4>@li.GetValue("Ecom:Product.Configurator.NoneSelected.Text")</h4>
        <input type="text" value="1" name='@li.GetValue("Ecom:Product.Configurator.ID")Quantity' />
        <select name='@li.GetValue("Ecom:Product.Configurator.ID")'>
        @foreach(LoopItem cp in li.GetLoop("ConfiguratorProducts")){
             <option value='@cp.GetValue("Ecom:Product.ID")' >@cp.GetValue("Ecom:Product.Name") (@cp.GetValue("Ecom:Product.ActualPrice") SEK) </option>
        }
        </select>
  </div>
}


</div>

    <div class="col-12 col-lg-4 cart-button-wrapper">

        <input type="submit" alt="KÖÖP" value="KÖP" class="btn btn-primary btn-buy float-right w-100">

    </div>

</div>

</form>
 
Jose Caudevilla
Reply

Hi , i have the same problem , did you find any solution?

 

Thanks,

Jose.

 

You must be logged in to post in the forum