Fix: FluentCart real-time orders ignore Selected Product filter#126
Open
AmitPaul-akp wants to merge 1 commit into
Open
Fix: FluentCart real-time orders ignore Selected Product filter#126AmitPaul-akp wants to merge 1 commit into
AmitPaul-akp wants to merge 1 commit into
Conversation
Real-time FluentCart orders trigger every enabled campaign whose status matches, regardless of "Show Purchase Of: Selected Product" or "Exclude Products" settings. The product/category filter was only being applied inside get_orders() (Regenerate path), not in the nx_can_entry filter chain used by live orders. Extend FluentCart::nx_can_entry to apply the same _excludes_product / _show_purchaseof check that get_orders() uses, so the real-time path enforces product filtering consistently.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Real-time FluentCart orders trigger every enabled NotificationX sales campaign whose status matches the incoming order, regardless of the campaign's
Show Purchase Of: Selected ProductorExclude Productssettings. The product/category filter is only honored on the Regenerate path.Reproduction
Actual: both Campaign A and Campaign B fire.
Root cause
FluentCart::nx_can_entry()- the only callback registered onnx_can_entry_fluentcart- checks order/payment/shipping/fulfillment status only. It does not apply_show_purchaseof()/_excludes_product().Real-time orders flow through:
fluent_cart/order_paid_done->save_new_records()->parent::save()->update_notification()->apply_filters('nx_can_entry_fluentcart', ...)...so live orders bypass the product filter entirely. The Regenerate path works because
get_orders()calls_excludes_product()/_show_purchaseof()itself before constructing entries.For comparison, the WooCommerce source registers two callbacks on the same filter - status check and the Conversions type's product filter - at
WooCommerce.php:110-111. FluentCart only registered the status one.Fix
Extend
FluentCart::nx_can_entry()to apply the same_excludes_product === _show_purchaseofcondition thatget_orders()already uses. Behavior is now consistent between Regenerate and real-time paths.nx_can_entry), +25 / -2.fluentcart_inline) inherits the fix viaFluentCart::get_instance()reference - no Pro-side changes required.Safety
product_control, noproduct_exclude_by):_excludes_productreturnsfalse,_show_purchaseofreturnstrue-> differ -> entry passes. No regression.'none' / 'none'configs: returnstrue/false-> still differ -> entry passes. No regression.product_id: guarded withif ($product_id)-> falls through, original behavior preserved.get_the_terms()result guarded withis_wp_error()+!empty().php -l(PHP 8.2): clean.Test plan
Selected ProductvaluesExclude Productsset: excluded product does not trigger; non-excluded doesProduct Categoryfilter: orders for products in the selected category fire; others don'tReported by client via Fluent Boards task #81314.