Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt Brailsford 3326 posts 17654 karma points MVP 8x c-trib
    Oct 27, 2021 @ 08:52
    Matt Brailsford
    0

    Orderline price calculator for a Bundle

    Question by Paulius Putna

    Hi Matt,

    I have the opposite question. What if I want to keep the "main" product unit price as it is instead of sum of all sub products?

    I have this, with no luck:

    public class BundleOrderLineCalculator : OrderLineCalculator { private readonly IStoreService _storeService; private readonly IProductPriceFreezerService _productPriceFreezerService;

        public BundleOrderLineCalculator(ITaxService taxService, IStoreService storeService, IProductPriceFreezerService productPriceFreezerService) : base(taxService, storeService, productPriceFreezerService)
        {
            _storeService = storeService;
            _productPriceFreezerService = productPriceFreezerService;
        }
    
        public override Price CalculateOrderLineUnitPrice(OrderReadOnly order, OrderLineReadOnly orderLine, Guid currencyId, TaxRate taxRate)
        {
            if (orderLine.OrderLines.Any())
            {
                var store = _storeService.GetStore(order.StoreId);
                var price = _productPriceFreezerService.GetProductPrice(order.StoreId, order.Id, orderLine.ProductReference, orderLine.ProductVariantReference, currencyId).Value;
                var calculated = Price.Calculate(price, taxRate, currencyId, store.PricesIncludeTax);
    
                return calculated;
            }
    
            return base.CalculateOrderLineUnitPrice(order, orderLine, currencyId, taxRate);
        }
    }
    

    Thanks

  • Matt Brailsford 3326 posts 17654 karma points MVP 8x c-trib
    Oct 27, 2021 @ 09:00
    Matt Brailsford
    0

    So you need a bundle order line to be whatever it's unit price is but everything within the bundle to be 0 priced?

Please Sign in or register to post replies

Write your reply to:

Draft