Exemplo n.º 1
0
        /// <summary>
        /// Get shippping item with rules
        /// </summary>
        /// <param name="shippingItem">base shippingItem</param>
        /// <param name="pickupId">pickupId (pickpoint id)</param>
        /// <param name="pickupAddress">pickupAddress (pickpoint address)</param>
        /// <param name="additionalData">additional pickup data</param>
        /// <param name="cityToDelivery">City to delivery</param>
        /// <returns></returns>
        public static ShippingItem GetListShippingItem(ShippingItem shippingItem, int pickupId,
                                                       string pickupAddress, string additionalData, string cityToDelivery)
        {
            if (shippingItem.Ext != null &&
                (shippingItem.Ext.Type == ExtendedType.Pickpoint || shippingItem.Ext.Type == ExtendedType.CashOnDelivery || shippingItem.Ext.Type == ExtendedType.Boxberry || shippingItem.Ext.Type == ExtendedType.Cdek))
            {
                shippingItem.Ext.PickpointId      = pickupId.ToString();
                shippingItem.Ext.PickpointAddress = pickupAddress;
                shippingItem.Ext.AdditionalData   = additionalData;

                if (shippingItem.Type == ShippingType.Multiship)
                {
                    var cart      = ShoppingCartService.CurrentShoppingCart;
                    var multiship = new Multiship(GetShippingParams(shippingItem.MethodId))
                    {
                        CityTo       = cityToDelivery,
                        ShoppingCart = cart,
                        TotalPrice   = cart.TotalPrice - cart.TotalDiscount,
                    };

                    var multishipOption =
                        multiship.GetOptions(false)
                        .Find(x => x.Extend != null && x.Extend.PickpointId == pickupId.ToString());

                    if (multishipOption != null)
                    {
                        shippingItem.Rate = multishipOption.Rate;
                    }
                }
            }
            return(shippingItem);
        }
Exemplo n.º 2
0
        public static bool ShowAddressField(EnUserType type, ShippingItem shippingItem)
        {
            //доставка до двери сдеком
            if (type != EnUserType.RegisteredUser && shippingItem != null && shippingItem.Type == ShippingType.Cdek && shippingItem.Ext != null)
            {
                var tariff = Cdek.tariffs.FirstOrDefault(item => string.Equals(item.tariffId.ToString(), shippingItem.Ext.AdditionalData));
                return(tariff != null && tariff.mode.EndsWith("Д"));
            }

            return(type != EnUserType.RegisteredUser &&
                   shippingItem != null && shippingItem.Type != ShippingType.SelfDelivery &&
                   (shippingItem.Ext == null || (shippingItem.Ext != null && shippingItem.Ext.Type != ExtendedType.Pickpoint)) &&
                   (shippingItem.ShippingPoints == null || shippingItem.ShippingPoints.Count == 0));
        }
Exemplo n.º 3
0
        private IEnumerable <ShippingItem> GetShippingByProductAmount()
        {
            var list = new List <ShippingItem>();
            var item = new ShippingItem(_method)
            {
                Id       = ++_index,
                Type     = ShippingType.ShippingByProductAmount,
                IconName = _method.IconFileName.PhotoName,
                Rate     = new ShippingByProductAmount(_method.Params).GetRate(_shoppingCart.TotalItems)
            };

            if (item.Rate != -1)
            {
                list.Add(item);
            }

            return(list);
        }
Exemplo n.º 4
0
        private IEnumerable <ShippingItem> GetShippingByOrderPrice()
        {
            var shippingitem = new ShippingItem(_method)
            {
                Id           = ++_index,
                Type         = ShippingType.ShippingByOrderPrice,
                DeliveryTime = _method.Params.ElementOrDefault(ShippingByOrderPriceTemplate.DeliveryTime),
                Rate         = new ShippingByOrderPrice(_method.Params).GetRate(_totalPrice, _totalPrice - _totalDiscount),
            };

            var list = new List <ShippingItem>();

            if (shippingitem.Rate != -1)
            {
                list.Add(shippingitem);
            }

            return(list);
        }
Exemplo n.º 5
0
 public static bool ShowCustomField(EnUserType type, ShippingItem shippingItem)
 {
     return(ShowAddressField(type, shippingItem) &&
            shippingItem.DisplayCustomFields);
 }
Exemplo n.º 6
0
        public static string RenderExtend(ShippingItem shippingItem, int distance, string pickupAddress, bool isSelected)
        {
            var result = string.Empty;

            switch (shippingItem.Type)
            {
            case ShippingType.eDost:
                if (shippingItem.Ext != null && shippingItem.Ext.Type == ExtendedType.Pickpoint)
                {
                    var temp = shippingItem.Ext.Pickpointmap.IsNotEmpty()
                            ? string.Format(",{{city:'{0}', ids:null}}", shippingItem.Ext.Pickpointmap)
                            : string.Empty;

                    result =
                        string.Format(
                            "<br/><div class=\"address-pickpoint\">{0}</div>" +
                            "<a href=\"javascript:void(0);\" class='pickpoint' onclick=\"PickPoint.open(SetPickPointAnswer{1});\">{2}</a><br />",
                            isSelected ? pickupAddress : string.Empty,
                            temp, Resource.ShippingRates_PickpointSelect);
                }
                else if (shippingItem.ShippingPoints != null && shippingItem.ShippingPoints.Any())
                {
                    result = "<div class=\"shipping-points-b\"> <select class=\"shipping-points\">";
                    foreach (var point in shippingItem.ShippingPoints)
                    {
                        result += string.Format("<option data-description=\"{0}\" value=\"{1}\" {3}>{2}</option>",
                                                HttpUtility.HtmlEncode(point.Description), point.Id, point.Address,
                                                shippingItem.Ext != null && point.Id.ToString() == shippingItem.Ext.PickpointId
                                    ? "selected='selected'"
                                    : string.Empty);
                    }
                    result += "</select> ";
                    result +=
                        string.Format(
                            "<a class=\"edost-map\" target=\"_blank\" href=\"http://www.edost.ru/office.php?c={0}\">{1}</a>",
                            shippingItem.ShippingPoints.First().Id, Resource.ShippingRates_ShowOnMap);

                    result += "</div>";
                }
                break;

            case ShippingType.Multiship:
                if (shippingItem.Ext != null)
                {
                    result =
                        string.Format(
                            "<div class=\"address-multiship\">{0}</div>" +
                            "<span class=\"btn-c\"><a href=\"javascript:void(0);\" class=\"btn btn-confirm btn-middle multiship-choose\" data-mswidget-open>{1}</a></span>",
                            isSelected ? pickupAddress : string.Empty,
                            Resource.ShippingRates_PickpointSelect);
                }
                break;

            case ShippingType.ShippingByRangeWeightAndDistance:
                if (shippingItem.Params != null &&
                    shippingItem.Params.ElementOrDefault(ShippingByRangeWeightAndDistanceTemplate.UseDistance).TryParseBool())
                {
                    result =
                        string.Format(
                            " <input data-plugin=\"spinbox\" data-spinbox-options=\"{{min:0,max:100000,step:1}}\" type=\"text\" class=\"tDistance\" value=\"{0}\"  data-id='{1}'/>",
                            distance, shippingItem.MethodId);
                }
                break;

            case ShippingType.Cdek:
                result = "<input type=\"hidden\" class=\"hiddenCdekTariff\" value=\"" + shippingItem.Ext.AdditionalData + "\">";
                if (shippingItem.ShippingPoints != null)
                {
                    result += "<div class=\"shipping-points-b\"> <select class=\"shipping-points-cdek\">";
                    foreach (var point in shippingItem.ShippingPoints)
                    {
                        result += string.Format("<option data-description=\"{0}\" data-tariffid=\"{1}\" value=\"{2}\">{3}</option>",
                                                HttpUtility.HtmlEncode(point.Description), shippingItem.Ext.AdditionalData, point.Code, point.Address);
                    }
                    result += "</select></div>";
                }
                break;

            case ShippingType.CheckoutRu:

                result = "<input type=\"hidden\" class=\"hiddenCheckoutInfo\" value=\"" + shippingItem.Ext.AdditionalData + "\">";
                if (shippingItem.ShippingPoints != null)
                {
                    result += "<div class=\"shipping-points-b\"> <select class=\"shipping-points-checkout\">";
                    foreach (var point in shippingItem.ShippingPoints)
                    {
                        result +=
                            string.Format(
                                "<option data-description=\"{0}\" data-additional=\"{1}\" data-rate=\"{2}\" data-full-rate=\"{3}\" value=\"{4}\" data-checkout-address=\"{6}\">{5} - {3}</option>",
                                HttpUtility.HtmlEncode(point.Description), point.AdditionalData, point.Rate,
                                CatalogService.GetStringPrice(point.Rate), point.Code, point.Address,
                                HttpUtility.HtmlEncode(point.Address));
                    }
                    result += "</select></div>";
                }
                else
                {
                    result += "<input type=\"hidden\" class=\"hiddenCheckoutExpressRate\" value=\"" + shippingItem.Rate + "\">";
                }
                break;
            }

            return(result);
        }