The idea would be to fully replace the AddressInformation[XSLT].xslt macro with a .net macro. Even though this is hard coded at the moment, i would set the fields in an asp.net usercontrol and then get redirected to "/shop/checkout/shipping.aspx" but it doesnt pickup the correct shipping based on the country of United Kingdon."
I was also trying the code below, but couldn't get this working either.
/* SHIPPING */ // First we'll need a shipping method using the name as defined in the backend, e.g. Ground or Air var shippingMethod = ShippingMethod.SingleOrDefault(x => x.Name == "Download"); var shipment = order.CreateShipment(shippingMethod, address); // Add all order lines to shipment using a handy extension mehod in UCommerce.Extensions called ForEach order.OrderLines.ForEach(x => shipment.AddOrderLine(x)); // Execute basket pipeline to make sure totals are up to date // Also save order and new shipment PipelineFactory.Create<PurchaseOrder>("basket").Execute(order);
C# Shipping Screen Issue
I'm trying to replace some of the the AddressShipping[XSLT] macro with a c# so that I have more control over the validation etc.
I have the sample below but I'm missing something. Any help would be appreciated.
protected void Button1_Click(object sender, EventArgs e)
{
try
{
PurchaseOrder order = SiteContext.Current.OrderContext.GetBasket().PurchaseOrder;
var address = order.BillingAddress ?? new OrderAddress();
address.AddressName = "Billing";
address.FirstName = "firstName";
address.LastName = "lastName";
address.EmailAddress = "emailAddress";
address.PhoneNumber = "phoneNumber";
address.MobilePhoneNumber = "mobilePhoneNumber";
address.CompanyName = "company";
address.Line1 = "line1";
address.Line2 = "line2";
address.PostalCode = "postCode";
address.City = "city";
address.State = "state";
address.Attention = "attention";
address.Country = Country.FirstOrDefault(x => x.Name == "United Kingdom");
address.PurchaseOrder = order;
order.BillingAddress = address;
order.Save(); // Saves cascade to children, so the address is saved as well
Response.Redirect("/shop/checkout/shipping.aspx");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
Hi Craig,
What behavior are you seeing or would you like to see? I feel like I'm missing a key piece of information to provide any helpful insight :)
Hi Soren,
The idea would be to fully replace the AddressInformation[XSLT].xslt macro with a .net macro. Even though this is hard coded at the moment, i would set the fields in an asp.net usercontrol and then get redirected to "/shop/checkout/shipping.aspx" but it doesnt pickup the correct shipping based on the country of United Kingdon."
Its as if I'm missing something?
Don't you need to add a shipping address first?
Hi Sean,
I was also trying the code below, but couldn't get this working either.
/* SHIPPING */
// First we'll need a shipping method using the name as defined in the backend, e.g. Ground or Air
var shippingMethod = ShippingMethod.SingleOrDefault(x => x.Name == "Download");
var shipment = order.CreateShipment(shippingMethod, address);
// Add all order lines to shipment using a handy extension mehod in UCommerce.Extensions called ForEach
order.OrderLines.ForEach(x => shipment.AddOrderLine(x));
// Execute basket pipeline to make sure totals are up to date
// Also save order and new shipment
PipelineFactory.Create<PurchaseOrder>("basket").Execute(order);
Is the shipping address not being added to the order?
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.