Files
piratepoet/lib/Segments
Rodrigo Primo 120aa74511 Fix query to get subscribers of the "has WC subscription" segment
There was an issue in the old query used to get subscribers of the "has WooCommerce subscription" segment. When getting the IDs of the users
that purchased a given subscription, it would get all the entries from wp_woocommerce_order_items without checking the value of ordem_item_type.

The problem is that wp_woocommerce_order_items contains entries for the purchased product, but also other things like shipping and tax information. The WooCommerce Subscriptions extension uses wp_woocommerce_order_items to store data when a user switches from one subscription to another. This was causing users to be included in the "has WooCommerce subscription" segment even after they had switched from the subscription that belonged to the segment to another one.

This problem was fixed by adding another condition to the part of the query that joins with wp_woocommerce_order_items to get only entries that have the value 'line_item' for the field 'order_item_type'. This excludes entries where the value of 'order_item_type' is 'line_item_switched', which is what WC Subscriptions uses to track subscriptions that a user used to have before switching to something else.

[MAILPOET-3898]
2021-11-22 12:53:39 +01:00
..