@@ -58,7 +58,7 @@ public static function init() {
5858 \add_action ( 'wc_memberships_user_membership_created ' , [ __CLASS__ , 'wc_membership_created ' ], 10 , 2 );
5959
6060 // WC Subscriptions hooks in and creates subscription at priority 100, so use priority 101.
61- \add_action ( 'woocommerce_order_status_completed ' , [ __CLASS__ , 'order_processed ' ], 101 );
61+ \add_action ( 'woocommerce_checkout_order_processed ' , [ __CLASS__ , 'order_processed ' ], 101 );
6262 \add_action ( 'option_woocommerce_subscriptions_failed_scheduled_actions ' , [ __CLASS__ , 'filter_subscription_scheduled_actions_errors ' ] );
6363
6464 \add_action ( 'wp_login ' , [ __CLASS__ , 'sync_reader_on_customer_login ' ], 10 , 2 );
@@ -208,7 +208,12 @@ public static function get_contact_from_order( $order, $payment_page_url = false
208208 if ( empty ( $ order_subscriptions ) ) {
209209 $ metadata [ Newspack_Newsletters::get_metadata_key ( 'membership_status ' ) ] = 'Donor ' ;
210210 $ metadata [ Newspack_Newsletters::get_metadata_key ( 'total_paid ' ) ] = (float ) $ customer ->get_total_spent ();
211- $ metadata [ Newspack_Newsletters::get_metadata_key ( 'product_name ' ) ] = '' ;
211+
212+ if ( 'pending ' === $ order ->get_status () ) {
213+ $ metadata [ Newspack_Newsletters::get_metadata_key ( 'total_paid ' ) ] += (float ) $ order ->get_total ();
214+ }
215+
216+ $ metadata [ Newspack_Newsletters::get_metadata_key ( 'product_name ' ) ] = '' ;
212217 $ order_items = $ order ->get_items ();
213218 if ( $ order_items ) {
214219 $ metadata [ Newspack_Newsletters::get_metadata_key ( 'product_name ' ) ] = reset ( $ order_items )->get_name ();
@@ -256,8 +261,11 @@ public static function get_contact_from_order( $order, $payment_page_url = false
256261 $ metadata [ Newspack_Newsletters::get_metadata_key ( 'next_payment_date ' ) ] = $ next_payment_date ;
257262 }
258263
259- $ metadata [ Newspack_Newsletters::get_metadata_key ( 'total_paid ' ) ] = (float ) $ customer ->get_total_spent ();
260- $ metadata [ Newspack_Newsletters::get_metadata_key ( 'total_paid ' ) ] += (float ) $ current_subscription ->get_total ();
264+ $ metadata [ Newspack_Newsletters::get_metadata_key ( 'total_paid ' ) ] = (float ) $ customer ->get_total_spent ();
265+
266+ if ( 'pending ' === $ order ->get_status () ) {
267+ $ metadata [ Newspack_Newsletters::get_metadata_key ( 'total_paid ' ) ] += (float ) $ current_subscription ->get_total ();
268+ }
261269
262270 $ metadata [ Newspack_Newsletters::get_metadata_key ( 'product_name ' ) ] = '' ;
263271 if ( $ current_subscription ) {
0 commit comments