Ejemplo n.º 1
0
        private void AdjustRate(ShippingRateDisplay r)
        {
            switch (AdjustmentType)
            {
            case ShippingMethodAdjustmentType.Amount:
                r.Rate = r.Rate + Adjustment;
                break;

            case ShippingMethodAdjustmentType.None:
                // Do Nothing
                break;

            case ShippingMethodAdjustmentType.Percentage:
                r.Rate = r.Rate + r.Rate * (Adjustment / 100m);
                break;
            }
        }
Ejemplo n.º 2
0
        public ShippingRateDisplay GetCopy()
        {
            var result = new ShippingRateDisplay();

            result.DisplayName         = DisplayName;
            result.ProviderId          = ProviderId;
            result.ProviderServiceCode = ProviderServiceCode;
            result.Rate             = Rate;
            result.ShippingMethodId = ShippingMethodId;
            result.ResponseMessage  = ResponseMessage;

            foreach (var item in SuggestedPackages)
            {
                result.SuggestedPackages.Add(item.Clone());
            }

            return(result);
        }
Ejemplo n.º 3
0
        public Collection <ShippingRateDisplay> GetRates(Order o, Store currentStore)
        {
            var groups = o.GetShippingGroups(Bvin);
            var result = new Collection <ShippingRateDisplay>();
            var p      = AvailableServices.FindById(ShippingProviderId, currentStore);

            if (p != null)
            {
                Settings.Add("PayerName", (o.ShippingAddress.FirstName + " " + o.ShippingAddress.LastName));
                p.BaseSettings.Clear();
                p.BaseSettings.Merge(Settings);

                var shipment  = ConvertGroupsToShipments(groups);
                var tempRates = p.RateShipment(shipment);

                if (tempRates != null)
                {
                    for (var i = 0; i <= tempRates.Count - 1; i++)
                    {
                        var r = new ShippingRateDisplay(tempRates[i])
                        {
                            ShippingMethodId = Bvin
                        };

                        if (r.DisplayName == string.Empty)
                        {
                            r.DisplayName = Name;
                        }

                        AdjustRate(r);

                        // Free shipping if no included items
                        if (shipment.Items.Count < 1)
                        {
                            r.Rate = 0;
                        }

                        result.Add(r);
                    }
                }
            }

            return(result);
        }