Developer forum

Forum » Swift » reOrder function

reOrder function

Rivan Chandra
Rivan Chandra
Reply

Hi,

I need to add reorder in "my orders" menu with swift.

I tried to use order.GetString("Ecom:Order.ReorderID") and string reorderLink = $"/my-account/my-orders?CC{Pageview.CurrentParagraph.ID}=Orders&ReorderID={order.Id}";
Which is the information that I get it from Rapido.

But the result is failed.

Is there a way to add reorder in swift?

Regards,

Rivan

2.png

Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Your screendump is from Rapido - and I guess you are moving that feature from Rapido template to Swift template?

Swift is using the new customer center module that uses viewmodels - GetString("Ecom:Order.ReorderID") is a template tag and that will never return anything in a viewmodel template. Currently the new viewmodel version of the customer center does not support re-ordering like this.

You have 2 options

  1. Replace this feature with the old customer center module
  2. Use cartcmd=addmulit (https://doc.dynamicweb.com/documentation-9/ecommerce/frontend/cart-commands) by itereating the orderlines and create a form with hidden inputs.

If you are using Rapido template and that is in the Rapido template it does not work, we need to see more of your template code and paragraph setup.

Thanks, Nicolai

Votes for this answer: 1
 
Rivan Chandra
Rivan Chandra
Reply

Hi,

Thank you for the respond.

I am trying to use add Multi for reorder function based on Cart Commands (dynamicweb.com) in Swift and it does not work. Perhaps I am doing it wrong?

Code:

<form method="post" class="col-md-12">
           
            @foreach (var orderline in order.OrderLines)
            {
              if(orderline.ProductId != "")
              {
                Count = Count +1;
 
                string ProductLoopCounter = "ProductLoopCounter" + Count;
                string ProductIDCounter = "ProductID" + Count;
                string QuantityCounter = "Quantity" + Count;
 
                <input type="text" name="@ProductLoopCounter" id="@ProductLoopCounter" value="@Count" />
                <input type="text" name="@ProductIDCounter" id="@ProductIDCounter" value="@orderline.ProductId" />
                <input type="text" name="@QuantityCounter" value="@orderline.Quantity" />
              }
            }
 
            <!--One button to add to cart-->
            <button class="btn btn-primary pull-right" type="submit" name="CartCmd" value="addmulti">Addmulti</button>
            <button class="btn btn-primary pull-right" type="submit" name="CartCmd" value="setmulti">Setmulti</button>
 
          </form>


But when I try to use CartCmd=Add, it is working.

Code:

@foreach (var orderline in order.OrderLines)
          {
            if(orderline.ProductId != "")
            {
              <p>@orderline.ProductName</p>
              <form method="post" class="col-md-12">
                <input type="hidden" name="ProductId" value="@orderline.ProductId" />
                <input type="hidden" name="VariantId" value="@orderline.ProductVariantId" />
                <button class="btn btn-primary pull-right" type="submit" name="CartCmd" value="Add">Add</button>
              </form>
            }
          }

I attached the code file just in case.

Thank you and regards,


Rivan

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Rivan,

 

At first glance everything seems fine. Have you tried to enforce the VariantId and the UnitId fields?

 

BTW, they should really be hidden fields and you only need the "AddMulti" button. Neither should have any influence though.

 

Best Regards,

Nuno Aguiar

 
Nicolai Pedersen
Reply

It looks right

UnitID and VariantID is not needed.

Is the products in stock? Do they have a price? Are they variants or masters? And do you have a link where we can see it?

Thanks

 
Rivan Chandra
Rivan Chandra
Reply

Hi everyone,

Thank you very much for the respond. I tried with my local computer with fresh Swift install then try with reOrder function immediately.

The add multi is working now. Turns out the cause is the product stock is 0.

Thank you very much and regards,

 

Rivan

 

You must be logged in to post in the forum