Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Craig Cronin 304 posts 503 karma points
    Oct 06, 2012 @ 19:41
    Craig Cronin
    0

    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);

                }

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 10, 2012 @ 09:20
    Søren Spelling Lund
    0

    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 :)

  • Craig Cronin 304 posts 503 karma points
    Oct 10, 2012 @ 19:15
    Craig Cronin
    0

    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?

  • Sean Mooney 131 posts 158 karma points c-trib
    Oct 10, 2012 @ 22:10
    Sean Mooney
    0

    Don't you need to add a shipping address first?

  • Craig Cronin 304 posts 503 karma points
    Oct 10, 2012 @ 22:25
    Craig Cronin
    0

    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);


  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 17, 2012 @ 10:50
    Søren Spelling Lund
    0

    Is the shipping address not being added to the order?

Please Sign in or register to post replies

Write your reply to:

Draft