Developer forum

Forum » Development » Custom orderfield values

Custom orderfield values

Bo Leanderson
Reply

Hello!
I have a question regarding order fields:

I have created a custom order field in backend as an integer. Its default value is 0.

I now have added radio buttons in the loop so it iterates the amount of radio buttons.
However, I'm currently struggling with trying to get the radio buttons send the parameter
with the radio button.

The foreach loop is for Shippingmethods and I have set up an if/else case.
However the orderfieldvalue isn't changing. I have tried (a razor code page):

@foreach (LoopItem i in GetLoop("Shippingmethods"))
                     {
                         var orderLineFieldCollection = new OrderLineFieldCollection(); 
                         var order = new Order(); 
                         var eFreight = order.OrderFieldValues.GetOrderFieldValue("eFreight").Value; 
                         if(GetValue("Ecom:Cart.Shippingmethod.ID"== "SHIP13")
                         {
                             eFreight = "1"; 
                         }
                         else
                         {
                             eFreight = "0";
                         } 
                          
     <input type="radio" onclick="" value="@eFreight" id="Radio1" onchange="" name="p"/> @i.GetValue("Ecom:Cart.Shippingmethod.Name")
     <br/>
                     }

What am I missing for the eFreight value to work? 


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

What are you trying to accomplish exactly? Not all of this makes sense to me (such as "trying to get the radio buttons send the parameter with the radio button.". Also, your code creates a new order and a new field collection, so those would never contain any real values.

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
This post has been marked as an answer

Also, the name of your radio button is probably incorrect as it needs to contain the system name of your field. Maybe this loop helps to find out its exact name: http://doc.dynamicweb.com/template-tags/ecommerce/shopping-cart/cart#CustomOrderFields

Votes for this answer: 1
 
Bo Leanderson
Reply

After some tweaking I got the expected result. The value now register correctly in backend. Thank you!

 

You must be logged in to post in the forum