Add missing promotion compatibility strategies

Created on 1 November 2018, almost 7 years ago
Updated 3 February 2023, over 2 years ago

Implementing remaining promotion compatibility strategies:

  • Only with the selected promotions
  • Any promotion except the selected promotions

โœจ Feature request
Status

Needs work

Version

2.0

Component

Promotions

Created by

๐Ÿ‡บ๐Ÿ‡ฆUkraine oleksiy Lutsk ๐Ÿ‡บ๐Ÿ‡ฆ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡น๐Ÿ‡ทTurkey rgnyldz

    Patch seems to apply without any issue bu nothing happens when I click on "Only with the selected promotions" or "Any promotion except the selected promotions"

    I'm on drupal 10.0.1, commerce 2.32 and php8.1

  • ๐Ÿ‡น๐Ÿ‡ทTurkey rgnyldz

    My mistake, I did not run db update and cleared cache.

  • ๐Ÿ‡น๐Ÿ‡ทTurkey rgnyldz

    I also have an edge case for you :)

    I created a content type called Campaigns so the admins can create a page containing the promotion information and display it on a page with a reference field to promotions. So they have to only work on one page for all the info like promotion itself and images, descriptions etc.

    But inside the node edit page the radio buttons inside the inline entity form(simple) do not work. I presume that the patch is specific for the promotion edit page ?

  • ๐Ÿ‡ณ๐Ÿ‡ดNorway zaporylie

    It seems to me like this patch won't work with coupons as the coupon validation constraint calls Promotion::applies() and that happens after the promotion preprocess removes all the promotion adjustments and before the processor adds them back.

    Disclaimer - I didn't test that theory but working on something similar now so wanted to chime in.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium bceyssens Genk ๐Ÿ‡ง๐Ÿ‡ช

    patch #20 seems to work for us with latest 2.x dev version.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance nicolas bouteille

    Hello,

    We have the same need than what was described on #9
    For Black Friday, we want to offer -50% on all products, but also -70% on some categories.
    Our clients need to be able to buy a product at -50% and another at -70% in the same cart / order.
    It looks like as described in #9, in Commerce right now, when a promotion in incompatible with another one, it means they cannot be used in the same cart / order at all, even though they don't affect the same product. Which I think is too bad :/
    I was actually surprised to discover this is the behavior so far.
    Since Lisa's idea has been posted 6 years ago, then reposted on #9 4 years ago, I can only imagine this requires a lot of work and will not be available anytime soonโ€ฆ but can I suggest that this idea be at least mentioned in the description / roadmap of this issue?

    Also, in the mean time, could you advise me on how you would implement my current need?
    I was thinking about adding a custom plugin to be able to exclude specific products or taxonomies.
    That way, I could create -50% on all products except one category, and another promo -70% on this specific category. Marking both promo compatible so that they can be both used at the same time but making sure on my end that they cannot affect one same product.

    That makes me think that somebody has probably already created this kind of excluding plugin?

    Thanks for your help.

    Nicolas

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance nicolas bouteille

    Ok just some follow up, here's how I managed to create a new condition to exclude some products (I will do the same for categories)
    I just created a new plugin OrderItemExcludeProduct that extends OrderItemProduct and only overrides the evaluate() function to negate it:

    public function evaluate(EntityInterface $entity) {
        return ! parent::evaluate($entity);
      }
    

    I also took care of displaying a huge warning to make sure the person creating the promotion also adds another condition such as Specific product category AND selects 'Condition operator' : 'All conditions must pass'. If not, the consequence will be : the promotion will be applied on any product not excluded here, even if it does not match the other condition(s)...

    By the way, the default value for Condition operator is 'Only one condition must pass' but shouldn't it say 'At least one condition must pass'?
    I just tested this and it does not break if I have more than one condition passing...

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States derekw

    Patch no longer applies to 3.0.2

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance flocondetoile Lyon

    changed version

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance flocondetoile Lyon

    patch rerolled against 3.1.0 version

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance flocondetoile Lyon

    For those who need the patch without the hook_update_N, as me who run this patch since 4 years (I implements the update_N in a custom module to not break other futur hook_update_N of the module), here it is.

  • ๐Ÿ‡ฎ๐Ÿ‡ฑIsrael jsacksick

    @flocondetoile: Can we get an MR? So we can see if the tests are passing/failing?

  • ๐Ÿ‡ฎ๐Ÿ‡ฑIsrael jsacksick

    I opened an MR with the patch from #31.

  • ๐Ÿ‡ฎ๐Ÿ‡ฑIsrael jsacksick

    I'm curious, this patch was never RTBCED, @flocondetoile: Have you been encountering any issue in the projects where this has been applied?
    I also think there are some use cases that won't work properly (due to how coupons are applied for example).

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance flocondetoile Lyon

    I ran this patch since 4 years without issues. But I didn't have use case with coupons. I used it to make promotions incompatibles with others, without any coupons behavior associated with them.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States derekw

    I did have trouble using this patch when a coupon was applied and both were targeted at order items. When the coupon was applied no other discounts were applied even if they were applicable. Fortunately the coupon use was a rare case for us. Otherwise the patch worked.

    Instead of using the Compatibility with other promotions feature I added custom conditions to evaluate order item product variation attributes for determining promotion applicability, and that was adequate to deconflict promotions.

Production build 0.71.5 2024