CoreShop icon indicating copy to clipboard operation
CoreShop copied to clipboard

Control discountability per Specific Price Rule

Open EinShoppo opened this issue 1 year ago • 3 comments

Q A
Bug report? no
Feature request? yes
BC Break report? yes/no
RFC? no

Hello @dpfaffenbauer,

We have a requirement from a customer and I would like to hear your opinion on this as it is also potentially an interesting feature for CoreShop.

The starting point is the following: Our customer builds his product prices using the “Specific Price Rules”. There are different price rules for each customer group and time-based prices. There are also “Cart Price Rules” that allow, for example, a 10% discount per item. Now this discount should not always be granted, since books in Germany, for example, are subject to fixed prices. We have therefore added a new attribute "discountable" to the product class, which we check for within the "Cart Price Rule" using the CartItemPriceRule condition.

All of this works wonderfully, but now our customer would like to be able to use the “Specific Price Rule” to control whether the price can be discounted via the Cart Rule, not globally on the product. The background is that, for example, customer group A can receive a discount, customer group B however not. For another item it could be the other way around and for a third item the discount should in principle be possible, but not for a price scheduled for the future because the price already represents a special price.

As you can see, the customer needs a high degree of flexibility. To achieve this, my idea is as follows:

  • OrderItems are provided with a new flag attribute "discountable" (default: true)
  • Create a new "Specific Price Rule Action" called "non-discountable" (since discountable products are the default)
  • When this action is applied, the OrderItem attribute discountable is set to false
  • There is a new CartItemPriceRule condition "discountable" for the Cart Price Rules, which checks the value of the discountable attribute of the OrderItem

In this way it is possible to control the discountability depending on a specific price rule. Somehow I'm unsure whether the idea with the non-discountable action is a good one, but I can't think of another solution. What do you think about it? Would this be interesting for the core?

Best regards

EinShoppo avatar Feb 05 '24 10:02 EinShoppo

@EinShoppo I love the idea. We have to be careful about priorities. What if a price rule action triggers before discountable is set?

dpfaffenbauer avatar Feb 07 '24 13:02 dpfaffenbauer

@dpfaffenbauer Oh, you're probably right. We ourselves always use the specific price rules with "stop propagation", so only one of these rules is executed for each product. But we could run into a prioritization problem if you have multiple specific rules for the same product and without stopping propagation after a valid rule. Apart from this problem, I was thinking that the "not-discountable" action can only be set in specific price rules. The validation against the discountable flag controlled by the action, on the other hand, should only take place in the cart price rules - and these are always executed last, aren't they? So I don't think we have a prioritization problem in case of using "stop propagation" in specific rules, or am I missing something?

In my opinion, however, we should consider how the general product price rules (not the specific ones) are integrated. This is a bit more problematic, as the action has to set the attribute on the order item, but the general product price rules change the price of the product - and the general rules run after the specific ones, don't they? That looks more like a problem that needs to be solved. The general rules would not only have to receive the price for a product (calculated by a specific rule), but also the discountable flag in some way.

Maybe we can discuss this next week, as the topic is quite complex. I hope to see you in Bremen. :-)

EinShoppo avatar Feb 09 '24 07:02 EinShoppo

@EinShoppo Yes, lets discuss that in Bremen next week. I was waiting to answer here but since Lufthansa canceled again I thought to read it anyway ;)

dpfaffenbauer avatar Feb 09 '24 07:02 dpfaffenbauer

That is done

dpfaffenbauer avatar Apr 21 '24 13:04 dpfaffenbauer