Example #1
0
        public string GetShippingCost(bool useProductShippingCost, string productID, string shippingID, object price)
        {
            decimal shippingCost = 0;
            decimal handlingFee  = 0;
            Product product      = DataAccessContext.ProductRepository.GetOne(
                AdminConfig.CurrentCulture, productID, new StoreRetriever().GetCurrentStoreID());

            CartItem      cartItem      = new CartItem(Cart.Null.CartID, product, 1);
            CartItemGroup cartItemGroup = new CartItemGroup(cartItem);

            ShippingOption shippingOption = DataAccessContext.ShippingOptionRepository.GetOne(
                AdminConfig.CurrentCulture, shippingID);

            if (!shippingOption.IsNull)
            {
                ShippingMethod shippingMethod = shippingOption.CreateNonRealTimeShippingMethod();

                shippingCost = shippingMethod.GetShippingCost(cartItemGroup, WholesaleStatus.Null, 0)
                               + CartItemPromotion.GetShippingCostFromPromotion(shippingMethod,
                                                                                cartItemGroup,
                                                                                WholesaleStatus.Null,
                                                                                0);
                handlingFee = shippingMethod.GetHandlingFee(cartItemGroup, WholesaleStatus.Null);
            }
            return(FormatNumber(shippingCost + handlingFee));
        }
    private string GetFormattedError(Coupon coupon, CartItemGroup cartItemGroup)
    {
        switch (coupon.Validate(cartItemGroup, StoreContext.Customer))
        {
        case Coupon.ValidationStatus.InvalidCustomer:
            return(GetCustomerError());

        case Coupon.ValidationStatus.BelowMinimumOrderAmount:
            return(GetOrderAmountError(coupon));

        case Coupon.ValidationStatus.InvalidProduct:
            if (coupon.ProductFilter == Coupon.ProductFilterEnum.ByProductIDs)
            {
                return(GetProductError(coupon));
            }
            else
            {
                return(GetCategoryError(coupon));
            }

        case Coupon.ValidationStatus.Expired:
            return(GetExpiredError(coupon));

        case Coupon.ValidationStatus.InvalidCode:
            return(GetInvalidCodeError());

        case Coupon.ValidationStatus.BelowMinimumQuantity:
            return(GetBelowMinimumQuantityError(coupon));

        default:
            return(String.Empty);
        }
    }
Example #3
0
        protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
        {
            CartItemGroup  CartItem = item is CartItemGroup itemGroup ? itemGroup : default;
            CollectionView view     = container as CollectionView;
            var            vm       = view.BindingContext as ShrineMenuPageViewModel;
            ObservableCollection <CartItemGroup> cartItemGroups = vm.CartItemsGroups as ObservableCollection <CartItemGroup>;

            var index = cartItemGroups.IndexOf(item is CartItemGroup cartItemGroup ? cartItemGroup : default);
    private decimal GetDiscountLine(ICartItem[] items, out IList <decimal> discountLines)
    {
        CartItemGroup group = new CartItemGroup(items);

        DiscountCalculator cal = new DiscountCalculator();

        return(cal.GetDiscount(group, StoreContext.CheckoutDetails.Coupon, StoreContext.Customer, out discountLines));
    }
    public void DisplayCouponErrorMessage(Coupon coupon, CartItemGroup cartItemGroup)
    {
        HideAllControls();

        string errorMessage = GetFormattedError(coupon, cartItemGroup);

        if (!String.IsNullOrEmpty(errorMessage))
        {
            DisplayError(errorMessage);
        }
    }
    private decimal GetDiscountWithoutCoupon()
    {
        QuantityDiscountCalculator quantityDiscountCalculator = new QuantityDiscountCalculator();

        CartItemGroup cartItemGroupWithoutRecurring = new CartItemGroup(
            StoreContext.ShoppingCart.GetCartItemsWithoutRecurring());

        IList <decimal> discountLines = new List <decimal>();

        return(quantityDiscountCalculator.GetDiscount(
                   cartItemGroupWithoutRecurring, StoreContext.WholesaleStatus, out discountLines));
    }
Example #7
0
    private bool ValidateCoupon()
    {
        if (uxCouponIDText.Text == "")
        {
            return(true);
        }

        Coupon        coupon        = DataAccessContext.CouponRepository.GetOne(uxCouponIDText.Text);
        CartItemGroup cartItemGroup = StoreContext.ShoppingCart.GetAllCartItems();

        return(coupon.Validate(cartItemGroup, StoreContext.Customer) == Coupon.ValidationStatus.OK);
    }
Example #8
0
    private void ShowCouponWarningMessage(ICartItem[] cart)
    {
        Coupon coupon = StoreContext.CheckoutDetails.Coupon;

        CartItemGroup cartItemGroup = new CartItemGroup(cart);

        if (coupon.Validate(cartItemGroup, StoreContext.Customer) != Coupon.ValidationStatus.OK)
        {
            uxCouponMessageDisplay.DisplayCouponErrorMessage(coupon, cartItemGroup);
            uxWarningMessageLiteral.Text += "<p>[$Coupon.WarningNotApplied]</p>";
            uxWarningMessageDiv.Visible   = true;
        }
    }
Example #9
0
    protected string GetTooltipBody(object cartItem)
    {
        CartItemGroup cartItemGroup = new CartItemGroup((ICartItem)cartItem);

        CartDisplayService displayService = new CartDisplayService();
        string             tooltipBody    = displayService.GetCheckoutTooltipBody(
            StoreContext.CheckoutDetails,
            cartItemGroup,
            StoreContext.Customer,
            StoreContext.Currency);

        return(WebUtilities.ReplaceNewLine(tooltipBody));
    }
Example #10
0
    private void ShowCouponWarningMessage(ICartItem[] cart)
    {
        Coupon coupon = StoreContext.CheckoutDetails.Coupon;

        CartItemGroup cartItemGroup = new CartItemGroup(cart);

        if (coupon.Validate(cartItemGroup, StoreContext.Customer) != Coupon.ValidationStatus.OK)
        {
            string errorMessage = uxCouponMessageDisplay.GetCouponErrorMessage(coupon, cartItemGroup);
            errorMessage += "<p>[$Coupon.WarningNotApplied]</p>";
            uxMessage.DisplayMessage(errorMessage);
        }
    }
    public string GetCouponErrorMessage(Coupon coupon, CartItemGroup cartItemGroup)
    {
        HideAllControls();

        return(GetFormattedError(coupon, cartItemGroup));
    }