Posted on 16/06/2008 10:24:52
paul wrote:
Besides the payment and shipping I whant to set some other values in step 3 om the order in ecom. I have created two order fields and I have named the input tage with the same name but it doesn't set the values.
It works great in step 2.
Can't you set values in step 3 besides payment and shipping?
I need to set two more values in this step, the EcomOrderPaymentMethod and the EcomShippingMethod
How can I do that?
Hi Paul,
Custom field values are only harvested upon submission of customer data. However, using a NoificationSubscriber you can achieve what you're requesting.
In you template for choosing payment and delivery (by default Method.html) add the fields you want the customer to fill:
<input type="text" name="MyField1" id="MyField1" />
<input type="text" name="MyField2" id="MyField2" />
Then in your subscriber you subscribe to the FeesHarvested which is invoked when this form is submitted. In this context you're able to work with the Request.Form, and hence you can fill the custom order field using your own code. The code below should be pretty copy/pastable:)
using Dynamicweb;
using Dynamicweb.Extensibility;
namespace CustomModules.CustomModules.Classes.OrderSubscribers
{
[Subscribe(Dynamicweb.Notifications.eCommerce.Order.Steps.FeesHarvested)]
public class AfterFee : NotificationSubscriber
{
public override void OnNotify(string notification, object[] args)
{
Dynamicweb.eCommerce.Orders.Order Order = (Dynamicweb.eCommerce.Orders.Order)args[0];
Dynamicweb.Base.w("!" + Dynamicweb.Base.ChkString(Dynamicweb.Base.Request("CustomFelt")) + "!");
foreach (Dynamicweb.eCommerce.Orders.OrderFieldValue ofv in Order.OrderFieldValues)
{
if (ofv.OrderField.SystemName == "MyField1" || ofv.OrderField.SystemName == "MyField2")
{
ofv.Value = Dynamicweb.Base.ChkString(Dynamicweb.Base.Request(ofv.OrderField.SystemName));
Order.Save();
}
}
}
}
}
The values are saved and available in your confirmation and mail templates as well as in backend.