Skip to content

Instantly share code, notes, and snippets.

@lunchin
Created October 27, 2015 11:59
Show Gist options
  • Save lunchin/a8219d5fc228313be0cc to your computer and use it in GitHub Desktop.
Save lunchin/a8219d5fc228313be0cc to your computer and use it in GitHub Desktop.
OrderRepository 9.2.0
var cart = OrderRepository.LoadOrCreate<Cart>(PrincipalInfo.CurrentPrincipal.GetContactId(), Cart.DefaultName).FirstOrDefault();
var price = PriceService.GetDefaultPrice(marketId,
DateTime.UtcNow,
new CatalogKey(new Guid(variation.ApplicationId), variation.Code),
SiteContext.Current.Currency);
var lineItem = CreateLineItem(variation, quantity, price.UnitPrice.Amount);
cart.Forms.First().Shipments.First().LineItems.Add(lineItem);
PromotionEngine.Run(cart);
OrderRepository.Save(cart);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment