Exemplo n.º 1
0
        /// <summary>
        /// Sets the shipping addresses.
        /// </summary>
        private void SetShippingAddresses()
        {
            OrderAddress address = null;

            var currentContact = CustomerContext.Current.CurrentContact;

            if (Cart.OrderForms[0].Shipments.Count > 0 && !string.IsNullOrEmpty(CartHelper.Cart.OrderForms[0].Shipments[0].ShippingAddressId))
            {
                string shippingAddressId = CartHelper.Cart.OrderForms[0].Shipments[0].ShippingAddressId;

                var cusomterAddress = currentContact == null ? null : currentContact.ContactAddresses.FirstOrDefault(ca => ca.Name.ToString().Equals(shippingAddressId));
                if (cusomterAddress != null)
                {
                    address = new OrderAddress();
                    CustomerAddress.CopyCustomerAddressToOrderAddress(cusomterAddress, address);
                }
                else
                {
                    address = CartHelper.FindAddressByName(shippingAddressId);
                }
            }
            else
            {
                var defaultShippingAdd = currentContact == null ? null : currentContact.ContactAddresses.FirstOrDefault(
                    a => currentContact.PreferredShippingAddressId.HasValue &&
                    currentContact.PreferredShippingAddressId.Value == a.PrimaryKeyId.Value);
                // Set default shipping address to new order.
                if (defaultShippingAdd != null)
                {
                    address = new OrderAddress();
                    CustomerAddress.CopyCustomerAddressToOrderAddress(defaultShippingAdd, address);

                    var shipment = Cart.OrderForms[0].Shipments[0];

                    shipment.ShippingAddressId = address.Name;

                    Cart.OrderAddresses.Add(address);
                }
            }

            ShippingAddressInfo.OrderAddress = address;
            ShippingAddressInfo.DataBind();
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Bind ShipmentId to button on AddressView control
            ShippingAddressInfo.ShipmentId = SplitShipment.ShipmentId.ToString();

            if (!string.IsNullOrEmpty(SplitShipment.ShippingAddressId))
            {
                // If Shipping method is hand off method -> Use Store to pickup
                var address = _cartHelper.FindAddressByName(SplitShipment.ShippingAddressId);
                if (address != null)
                {
                    ShippingAddressInfo.OrderAddress = address;
                    ShippingAddressInfo.DataBind();

                    if (ShippingManager.AddressIsHandoffLocation(address))
                    {
                        ShippingAddressInfo.UseWarehouseAddress = true;
                        var litMessage = shippingOptions.Controls[0].FindControl("litMessage") as Literal;
                        if (litMessage != null)
                        {
                            litMessage.Text = ShippingManager.PickupShippingMethodName;
                        }
                    }
                    else
                    {
                        SetShippingMethod(BindShippingMethods());
                    }
                }
            }
            else
            {
                SetShippingMethod(BindShippingMethods());
            }

            //Lineitem data
            LineItemsID.ShipmentLineItems = Shipment.GetShipmentLineItems(this.SplitShipment);
            LineItemsID.BindData();

            //Subtotal each line item
            OrderSubtotalID.SplitShipment = SplitShipment;
            OrderSubtotalID.DataBind();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Sets the shipping address
 /// </summary>
 /// <param name="address"> Shipping address </param>
 public void SetShippingAddresses(OrderAddress address)
 {
     ShippingAddressInfo.OrderAddress = address;
     ShippingAddressInfo.DataBind();
 }