Exemplo n.º 1
0
        public virtual async Task <ICartBuilder> MergeWithCartAsync(ShoppingCart cart)
        {
            foreach (var lineItem in cart.Items)
            {
                AddLineItem(lineItem);
            }

            _cart.Coupon = cart.Coupon;

            _cart.Shipments.Clear();
            _cart.Shipments = cart.Shipments;

            _cart.Payments.Clear();
            _cart.Payments = cart.Payments;

            await EvaluatePromotionsAndTaxes();

            await _cartApi.CartModuleDeleteCartsAsync(new List <string> {
                cart.Id
            });

            _cacheManager.Remove(CartCaheKey, _cartCacheRegion);

            return(this);
        }
Exemplo n.º 2
0
        public IQuoteRequestBuilder Update(QuoteRequestFormModel quoteRequest)
        {
            _cacheManager.Remove(GetQuoteRequestCacheKey(_quoteRequest.StoreId, _quoteRequest.CustomerId), _quoteRequestCacheRegion);

            _quoteRequest.Comment = quoteRequest.Comment;
            _quoteRequest.Status  = quoteRequest.Status;
            _quoteRequest.Tag     = quoteRequest.Tag;

            _quoteRequest.Addresses.Clear();
            if (quoteRequest.BillingAddress != null)
            {
                _quoteRequest.Addresses.Add(quoteRequest.BillingAddress);
            }
            if (quoteRequest.ShippingAddress != null)
            {
                _quoteRequest.Addresses.Add(quoteRequest.ShippingAddress);
            }

            if (quoteRequest.Items != null)
            {
                foreach (var item in quoteRequest.Items)
                {
                    var existingItem = _quoteRequest.Items.FirstOrDefault(i => i.Id == item.Id);
                    if (existingItem != null)
                    {
                        existingItem.Comment           = item.Comment;
                        existingItem.SelectedTierPrice = new TierPrice
                        {
                            ListPrice = new Money(item.SelectedTierPrice.Price, _quoteRequest.Currency),
                            Quantity  = item.SelectedTierPrice.Quantity
                        };
                        existingItem.ProposalPrices.Clear();
                        foreach (var proposalPrice in item.ProposalPrices)
                        {
                            existingItem.ProposalPrices.Add(new TierPrice
                            {
                                ListPrice = new Money(proposalPrice.Price, _quoteRequest.Currency),
                                Quantity  = proposalPrice.Quantity
                            });
                        }
                    }
                }
            }

            return(this);
        }
Exemplo n.º 3
0
 protected virtual void InvalidateCache()
 {
     //Invalidate cart in cache
     _cacheManager.Remove(GetCartCacheKey(Cart.StoreId, Cart.Name, Cart.CustomerId, Cart.Currency.Code), _cartCacheRegion);
     _cacheManager.Remove(GetCartCacheKey(Cart.Id), _cartCacheRegion);
 }