• Hello,

    Behavior description:
    1. We use simple Bulk Rule for a bunch of products this way “Buy 2 – get 10% off, buy 3 or more – get 15% off”.
    2. We use MyRewards By Long Watch Studio plugin for a long time now and the settings are set that loyalty points can be used with any product, any discount, any gift cards and applied after all cart calculations are done (customer can reduce order price to 0 with loyalty points).
    3. When product with ADP rule exist in cart (quantity does not matter) customers can apply loyalty points, BUT, when at least one coupon is applied (for example we also have 10% off for first order), then loyalty points are just dropped / ignored (only coupons are left in discount list). When no ADP ruled products are in cart everything is working as expected.

    I hope you will help to bypass the problem and navigate me how I can solve this.

    Thank you.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support aprokaev

    (@aprokaev)

    Hello

    Could you share screenshot of >WooCommerce>Pricing Rules>Settings>Coupons ?
    We need screenhsot of bulk rule too .

    Thread Starter mxcster

    (@mxcster)

    Plugin Support aprokaev

    (@aprokaev)

    Thank you!

    I setup same rule and installed MyRewards
    I configured reward as “100 points gives 100 usd” https://snipboard.io/o8wc9z.jpg
    I manually added 100 points for user , and MyRewards created 1 coupon (with fixed amount 100)

    Cart seems to be ok https://snipboard.io/Te8zpd.jpg
    Item cost 20, but after ADRP -15% = 17
    Item subtotal = 170
    MyRewards coupon applied -100
    Total 70

    Did I do correct steps? I’ve never used MyRewards before.

    Plugin Support aprokaev

    (@aprokaev)

    My bad, I missed important thing!

    I switched to “Point Value in cart” mode. but I still see correct total https://snipboard.io/9koAGp.jpg

    If you have staging website – please try to deactivate other WooCommerce plugins until you find conflicting one.

    Thread Starter mxcster

    (@mxcster)

    Thank you for investigation.

    Can you try percentage discount coupon with “Individual use only” and “Exclude sale items” both set to ON? We get this discount auto generated with Omnisend, that’s how we discovered combination of ADP ruled product + coupon + loyalty points do not stack in cart, and loyalty points are removed. I also turned off all plugins in dev environment, and get same result.

    Plugin Support aprokaev

    (@aprokaev)

    As I see, MyRewards adds points as another coupon.
    but WooCoommerce coupon (with active “individual use only”) suppresses all other coupons .

    So I deactivate ADP plugin, tried to use points – and I got this error message https://snipboard.io/iCKZvq.jpg

    I don’t see solution , probably MyRewards team can help.

    Thread Starter mxcster

    (@mxcster)

    Here is a snippet from MyRewards to apply loyalty points with any coupons (it actually works, but not in combo described above). Maybe you can take a look and find a conflict or lack of logic?

    /**
    * Stack *loyalty points* (MyRewards) with ANY coupon, even if that other coupon is "individual use".
    */

    /** Detector: MyRewards points coupon? (by code prefix "mrwrds") */
    if ( ! function_exists( 'km_is_loyalty_points_coupon' ) ) {
    function km_is_loyalty_points_coupon( $coupon ): bool {
    if ( $coupon instanceof WC_Coupon ) {
    $code = (string) $coupon->get_code();
    } else {
    $code = (string) $coupon; // coupon code string
    }
    return (bool) preg_match( '/^wr_points_on_cart/i', $code );
    }
    }

    /**
    * Allow applying a coupon even when an individual-use coupon is present,
    * IF either one is the loyalty points coupon.
    *
    * Signature: ($allow, WC_Coupon $coupon, WC_Coupon $individual_use_coupon, array $applied_coupons)
    */
    add_filter( 'woocommerce_apply_with_individual_use_coupon', function( $allow, $coupon, $individual_use_coupon = null, $applied_coupons = array() ) {
    if ( $coupon instanceof WC_Coupon && km_is_loyalty_points_coupon( $coupon ) ) {
    return true; // always allow adding loyalty alongside individual-use
    }
    if ( $individual_use_coupon instanceof WC_Coupon && km_is_loyalty_points_coupon( $individual_use_coupon ) ) {
    return true; // allow adding any coupon if the existing individual-use is actually loyalty
    }
    return $allow;
    }, 10, 4 );

    /**
    * When an individual-use coupon is applied, Woo would remove other coupons.
    * Keep removing others as usual, EXCEPT never remove the loyalty points coupon.
    *
    * Signature: ($to_remove, WC_Coupon $coupon, array $applied_coupons)
    */
    add_filter( 'woocommerce_apply_individual_use_coupon', function( $to_remove, $coupon, $applied_coupons = array() ) {
    // If we are applying the loyalty coupon, never remove anything.
    if ( $coupon instanceof WC_Coupon && km_is_loyalty_points_coupon( $coupon ) ) {
    return array();
    }

    // Otherwise (applying some other coupon, possibly individual-use),
    // do not remove the loyalty coupon from the cart.
    $filtered = array();
    foreach ( (array) $to_remove as $code ) {
    if ( ! km_is_loyalty_points_coupon( $code ) ) {
    $filtered[] = $code;
    }
    }
    return $filtered;
    }, 10, 3 );

    /**
    * Safety: ensure loyalty coupons are never treated as "individual use".
    * (If MyRewards ever marks them so, override at runtime.)
    *
    * Signature: ($is_individual_use, WC_Coupon $coupon)
    */
    add_filter( 'woocommerce_coupon_get_individual_use', function( $is_individual, $coupon ) {
    if ( $coupon instanceof WC_Coupon && km_is_loyalty_points_coupon( $coupon ) ) {
    return false;
    }
    return $is_individual;
    }, 10, 2 );
    Thread Starter mxcster

    (@mxcster)

    May the problem be that MyRewards points on cart are actually virtual coupon, and ADP rules remove them when rebuilding the cart?

    Plugin Support aprokaev

    (@aprokaev)

    If I remove individual-use coupon — Myrewards works ok even if our plugin active.
    so virtual coupon is not a problem.

    I don’t see your previous reply (with custom code), I tested this code and it works when our plugin inactive.

    Please submit ticket to https://algolplus.freshdesk.com/ and we’ll try figure solution next week.

Viewing 9 replies - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.