Do you rerun the ApplyDiscounts() when an item is removed from the cart - because that is supposed to run
Yes, I do, in the ValidateCart function.
cart.ApplyDiscounts(_promotionEngine, new PromotionEngineSettings());
cart.ApplyDiscounts(_promotionEngine, new PromotionEngineSettings())
.Where(r => r.Status == FulfillmentStatus.Fulfilled)
.Select(c => c.Promotion?.Coupon?.Code)
.Where(i => i != null)
.Any(c => c.Equals(couponCode, StringComparison.OrdinalIgnoreCase));
Hi!
It is actually my own Promotions.
In the start up I do this:
var promotionTypeHandler = context.Locate.Advanced.GetInstance<PromotionTypeHandler>();
promotionTypeHandler.DisableBuiltinPromotions();
And then I have made my own by inheriting the basic ones:
[ContentType(GUID = "95c36376-eadc-4d2d-9142-3e1f70814422", DisplayName = "Köp artiklar få rabatt på utvalda artiklar", GroupName = "entrypromotion")]
[PromotionSettings(FixedRedemptionsPerOrder = 1)]
[ImageUrl("Images/BuyQuantityGetItemDiscount.png")]
public class BuyQuantityGetItemDiscountPromotion : BuyQuantityGetItemDiscount, IBasePromotion
{
[UIHint("image")]
[Display(Order = 5, Name = "Bild")]
public virtual ContentReference Image { get; set; }
[Display(Order = 7, Name = "Beskrivning (lång)")]
public virtual XhtmlString MainBody { get; set; }
}
public interface IBasePromotion
{
XhtmlString MainBody { get; set; }
ContentReference Image { get; set; }
}
But I guess that should not matter?
If I run this in an inkognito browser:
var s = _promotionEngine.Run(cart, new PromotionEngineSettings(RequestFulfillmentStatus.All, false));
All promotions has the status NotFullfilled but this line of code:
var discountPrices = _promotionEngine.GetDiscountPrices(variantLink, _currentMarket.GetCurrentMarket(), _currencyService.GetCurrentCurrency());
gives me discounted prices for the variantLink even to the promotion is not fullfilled. Should that be the case? I thougth GetDiscountPrices() should give me prices only if the promotion is fullfilled? I have my own pricing service, maybe I have to check that the promotion of the discounted price is fullfilled before I show it?
And then add one regular product and one free and then _promotionEngine.Run() gives me one fullfilled promotion.
I remove the regular one and still I get one fullfilled promotion until I remove the free one.
So the problem is that the free one should not be free unless there is on regular product in the cart?
Maybe I'm just missing some basics here?
Thanks!
/Kristoffer
With an empty cart:
_promotionEngine.Evaluate(variantLink, _currentMarket.GetCurrentMarket(),
_currencyService.GetCurrentCurrency());
Gives me one Fullfiled RewardDescritpion mean while this:
_promotionEngine.Run(cart, new PromotionEngineSettings(RequestFulfillmentStatus.All, false));
Gives me a list of RewardDescriptions where all item has the status NotFulfilled.
/Kristoffer
What's about BuyQuantityGetFreeItem instead? Sounds like a better match for you
No, actually not.
The customer has a lot of older products they wanted to get rid of and if you buy something you are supposed to be able to add 2 of these items with the price 0. So the price on the items should be there regular price until you add something with a price.
I found one user error and that is that you could choose whatever from the whole catalog, including the free items, which of couse fulfills the promotion when I add one of the free ones.
So in test purpose I now changed it to that the user needs to buy one specific item and then can then get items for free. And this is what happens starting with an empty cart.
All free items have a price by default in the product listing. Correct.
I add the specific item in the cart but there is still a price for the free items in the listing, _promotionEngine.GetDiscountPrices() returns nothing for the free items. Not correct.
I add one free item to the cart, and in the checkout the price for the free item is 0, and the price is shown using lineItem.GetExtendedPrice(currency). Correct.
I remove the specific item, price is back in the cart for the free item. Correct.
Wheter I have the specific item in the cart or not, these give me nothing:
var s = _promotionEngine.Evaluate(variantLink, _currentMarket.GetCurrentMarket(), _currencyService.GetCurrentCurrency(), RequestFulfillmentStatus.Fulfilled);
var discountPrices = _promotionEngine.GetDiscountPrices(variantLink, _currentMarket.GetCurrentMarket(), _currencyService.GetCurrentCurrency());
why is
lineItem.GetExtendedPrice(currency)
giving me the discounted price not the two above?
Thanks!
/Kristoffer
Hi!
I still need some help to understand here:
I am a bit confused here how to use the promotion engine the correct way.
Thanks!
/Kristoffer
Hi!
I just tested this in Foundation, Commerce 13.21 and this must be a bug or I just totally misunderstand the functionallity.
I'm using a "Buy Products for Discount from Other Selection" promotion.
1st case.
Buy at least 1 item of from these entries:
Fashion [catalog]
Include subcategories: Yes
Get these entries:
Morgan Sneaker [variant, SKU-42518256]
Morgan Sneaker [variant, Morgan-Sneaker_1]
At the following discount:
100% off
Price for Morgan Sneaker with an empty cart:
$0
Price in the cart with only one Morgan Sneaker in the cart:
$0
2nd case
Buy at least 1 item of from these entries:
Jodhpur Boot [variant, JODHPUR-BOOT_1]
Jodhpur Boot [variant, SKU-39813617]
Include subcategories: Yes
Get these entries:
Morgan Sneaker [variant, SKU-42518256]
Morgan Sneaker [variant, Morgan-Sneaker_1]
At the following discount:
100% off
Price for Morgan Sneaker with an empty cart:
$280, correct
Price for Morgan Sneaker with a Jodhpur Boot [variant, JODHPUR-BOOT_1] in the cart:
$280
Price for Morgan Sneaker in then cart with a Jodhpur Boot [variant, JODHPUR-BOOT_1] and a Morgan Sneaker in the cart:
$0
Both these examples are according to me wrong except $280 with an empty cart in the second case.
In the first case you can by something for $0 even though the promotion says you have to buy at least one other thing.
You should not have to add an item to the cart to get the promotion price, how can you promote it in that case?
Maybe I'm on the wrong track here then please let me know how it should work, otherwise please look into this so that we can figure out how to use the promotion manager, thanks!
/Kristoffer
Hi!
I have a promotion where you can get products with 100% discount if you buy something else.
When I activate that campaign the products that you get for free gets the price 0 without that the criteria, "buy something else" eg adding another item to the cart, is fulfilled.
And if I add a regualar product and then a free product, the price is 0 which is correct, but when I remove the regular item from the cart the price is not updated for the free item?
What is the correct way to get the actuall current price? I mean the price should be 100 until I added a regular item to the cart and then get the price 0.
Is there a Epi standard way or do I need to check each product for active campaigns?
Thanks!
/Kristoffer