November Happy Hour will be moved to Thursday December 5th.

On changing the CurrentMarket, the repeater sems not to update the basket items from the updated Market

Vote:
 

Hi,

  I have a CMS website with Commerce having a Header control that contains a repeater (a mini basket).  On changing the CurrentMarket, the repeater sems not to update the basket items from the updated Market.  The label with the name of the Market is updated correctly, but the items from cart remain from the previous Market.

   I tried remove any possible cache from the control or the page, and bind the data collection in every mode possible in the Header user control but items still persist.

   Is there any other cache added by Episerver that shoudld be removed in a special way, or am I missing some spects ?     

   Please help.

   Many thanks in advance !!

/Liviu H.

 

 

#89933
Aug 28, 2014 18:51
Vote:
 

Hi LiviuH,

The cart contains the line items and the line items are added to the cart by the out of the box CartHelper class. You can download the source code for the cart helper class from EPiServer World if you want to find out how it creates the line items or even change it.

The existing line items will not be changed when changing the CurrentMarket out of the box. You will need to implement this logic. Only entries that has been added after you changed the market will have the new market price.

Hope this helps!

/T

#89938
Aug 28, 2014 20:48
Vote:
 

Hi,

The "recommended" way for market and cart is that each customer get one cart per market. That's mean, when user changes market, you can create a new cart for new market (or load the existing one).

When you set the current market, you'll need to call this for creating/getting new cart:

_cartHelper = new CartHelper(string name, Guid userId, IMarket market)

Regards,

/Q

#89949
Aug 29, 2014 4:54
Vote:
 

Hi guys,

   Yes, definitely the _cartHelper = new CartHelper(CurrentCart.Name) where 

        ///


        /// Gets the current cart.
        ///

        public Cart CurrentCart
        {
            get
            {
                return OrderContext.Current.GetCart(Cart.DefaultName, SecurityContext.Current.CurrentUserId, CurrentMarket.MarketId);
            }
        }

is the solution. If this initialization is made in page load, than the CurrentMarket is updated and the items are retrieved correctly.

Thanks a lot for your feedback!

Cheers,

Liviu

#90064
Edited, Sep 01, 2014 15:41
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.