77
88namespace Newspack \Data_Events ;
99
10- use Newspack \Memberships as NewspackMemberships ;
10+ use Newspack \Content_Gate ;
1111use Newspack \Reader_Activation ;
1212use Newspack \Data_Events ;
1313use WP_Error ;
1717 */
1818final class Memberships {
1919
20- const METADATA_NAME = 'memberships_content_gate ' ;
20+ const METADATA_NAME = 'gate_post_id ' ;
2121
2222 /**
2323 * The name of the action for form submissions
@@ -74,7 +74,7 @@ public static function checkout_cart_item_data( $cart_item_data ) {
7474 */
7575 public static function checkout_create_order_line_item ( $ item , $ cart_item_key , $ values , $ order ) {
7676 if ( ! empty ( $ values [ self ::METADATA_NAME ] ) ) {
77- $ order ->add_meta_data ( '_memberships_content_gate ' , $ values [ self ::METADATA_NAME ] );
77+ $ order ->add_meta_data ( '_gate_post_id ' , $ values [ self ::METADATA_NAME ] );
7878 }
7979 }
8080
@@ -149,7 +149,7 @@ public static function registration_submission( $email, $authenticate, $user_id,
149149 return ;
150150 }
151151 $ data = array_merge (
152- NewspackMemberships ::get_gate_metadata (),
152+ Content_Gate ::get_gate_metadata (),
153153 [
154154 'action ' => self ::FORM_SUBMISSION ,
155155 'action_type ' => 'registration ' ,
@@ -182,7 +182,7 @@ public static function registration_submission_with_status( $email, $authenticat
182182 $ action = self ::FORM_SUBMISSION_FAILURE ;
183183 }
184184 $ data = array_merge (
185- NewspackMemberships ::get_gate_metadata (),
185+ Content_Gate ::get_gate_metadata (),
186186 [
187187 'action ' => $ action ,
188188 'action_type ' => 'registration ' ,
@@ -202,13 +202,13 @@ public static function registration_submission_with_status( $email, $authenticat
202202 * @return ?array
203203 */
204204 private static function get_order_data ( $ order_id , $ order ) {
205- $ is_from_gate = $ order ->get_meta ( '_memberships_content_gate ' );
205+ $ is_from_gate = $ order ->get_meta ( '_gate_post_id ' ) ? $ order -> get_meta ( ' _gate_post_id ' ) : $ order -> get_meta ( ' _memberships_content_gate ' ); // Handle legacy _memberships_content_gate meta key.
206206 if ( ! $ is_from_gate ) {
207207 return ;
208208 }
209209 $ item = array_shift ( $ order ->get_items () );
210210 $ data = array_merge (
211- NewspackMemberships ::get_gate_metadata (),
211+ Content_Gate ::get_gate_metadata (),
212212 [
213213 'action_type ' => 'paid_membership ' ,
214214 'order_id ' => $ order_id ,
0 commit comments