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

Entry added to CartHelper doesn't have pricePlace

Vote:
 

I have a problem when I try to add an Entry to my cart. In my ShoppingCart controller I have a method that takes the code attribute of a variant and use it to add it to the cart as an Entry.

This lines of code insert the entry in my cart, but not with all the attributes.

Entry newEntry = CatalogContext.Current.GetCatalogEntry(code);
_cartHelper.AddEntry(newEntry,quantity,false);
_cartHelper.Cart.AcceptChanges();

When I try to access the line item, it has an PlacedPrice equal to 0. Also when I run the CartValidate workflow, the Cart.Total is 0. If I set the PlacedPrice to a number it works...

LineItem lineItem = _cartHelper.Cart.OrderForms[0].LineItems.First(lineI => lineI.Code == code);
var priceOfLineItem = lineItem.PlacedPrice; -> this equal 0

I have to specify that I set up the price in the Commerce Manager, when I added the variant.

I'm pretty much new to the Episerver world, so take me easy:D I'm using Episerver 7.5

Thank you.

#131833
Aug 06, 2015 14:26
Vote:
 

Hi, 

Make sure you add the price valid for the current time and current market.

/Q

#131834
Aug 06, 2015 14:40
Vote:
 

Checked. That's not the problem.

#131838
Aug 06, 2015 17:01
Vote:
 

Hi,

Try to create an order in Commerce Manager and add that variation to your order. Is the price correct?

/Q

#131859
Aug 07, 2015 9:37
Vote:
 

I'm having the same issue. Through Commerce Manager wasn't able to add that variation because couldn't find it. 

Solved it like this:

Entry entry = _variation.LoadEntry(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull); 
            
var helper = new CartHelper(Cart.DefaultName);

helper.AddEntry(entry, amount, false);
            
LineItem item = helper.Cart.OrderForms[0].LineItems[helper.Cart.OrderForms[0].LineItems.Count - 1];
var price = GetPrice();
item.PlacedPrice = price.Amount;

helper.Cart.AcceptChanges();


Where GetPrice() method just returns the appropriate "entry.PriceValues" value.

#132022
Edited, Aug 12, 2015 13:19
Vote:
 
public static Price GetDefautPriceMoney(this VariationContent variation, IMarket market = null)
        {
            ReadOnlyPricingLoader pricingLoader = ServiceLocator.Current.GetInstance<ReadOnlyPricingLoader>();

            ItemCollection<Price> prices;

            prices = variation.GetPrices();
          
            if (prices != null)
            {
                if(market != null)
                    return prices.FirstOrDefault(x => x.MarketId.Equals(market.MarketId) && x.UnitPrice.Currency == market.DefaultCurrency && x.CustomerPricing.PriceTypeId == CustomerPricing.PriceType.AllCustomers);
                return prices.FirstOrDefault(x => x.CustomerPricing.PriceTypeId == CustomerPricing.PriceType.AllCustomers);
            }
            return null;

        }



Regards
/K

#132042
Aug 12, 2015 19:01
* 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.