Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
3037cd4
feat(ras): helper method for ESP master list
miguelpeixe Aug 21, 2024
063bc1b
fix: ensure bool return
miguelpeixe Aug 21, 2024
e17ccf0
feat(ras): woo sync tools
miguelpeixe Aug 22, 2024
499bd5b
chore: update textdomain
miguelpeixe Aug 22, 2024
3b5848d
chore: use namespace for WooCommerce_Connection
miguelpeixe Aug 22, 2024
3d09777
chore: rename class
miguelpeixe Aug 22, 2024
fdda98d
chore: remove superfluous check
miguelpeixe Aug 22, 2024
ba4292d
fix: method calling
miguelpeixe Aug 22, 2024
7658806
chore: woo sync is now an ESP sync
miguelpeixe Aug 22, 2024
5c4b971
feat(ras): unify ESP connector strategy for data events
miguelpeixe Aug 22, 2024
406bd7c
feat: check master list and make ::sync() protected
miguelpeixe Aug 22, 2024
24ecd80
chore: fix doc
miguelpeixe Aug 22, 2024
d8642c9
Merge branch 'feat/woo-sync-tools' into feat/esp-connector-with-sync
miguelpeixe Aug 22, 2024
e5e9a15
chore: remove duplicate check
miguelpeixe Aug 22, 2024
8a7f0b2
chore: adjust wording
miguelpeixe Aug 22, 2024
d3b206c
Merge branch 'feat/woo-sync-tools' into feat/esp-connector-with-sync
miguelpeixe Aug 22, 2024
b854ff1
feat: support custom context
miguelpeixe Aug 22, 2024
f808a92
feat: support custom context
miguelpeixe Aug 22, 2024
098dca9
chore: update context defaults
miguelpeixe Aug 22, 2024
64d6079
Merge branch 'feat/woo-sync-tools' into feat/esp-connector-with-sync
miguelpeixe Aug 22, 2024
c8239ef
feat(ras): sync class
miguelpeixe Aug 22, 2024
7968490
chore: move some newsletters logic to the sync class
miguelpeixe Aug 22, 2024
4ba2118
fix: const
miguelpeixe Aug 22, 2024
5e25857
fix: more sync class integration with newsletters
miguelpeixe Aug 23, 2024
29d26c0
chore: move meta handling for sync
miguelpeixe Aug 23, 2024
bddcf90
feat: traits for metadata and woo
miguelpeixe Aug 23, 2024
6ac15f6
fix: dependencies
miguelpeixe Aug 23, 2024
f80495c
chore: rename method
miguelpeixe Aug 23, 2024
cc14d08
Merge branch 'feat/woo-sync-tools' into feat/esp-connector-with-sync
miguelpeixe Aug 23, 2024
707c4de
Merge branch 'feat/esp-connector-with-sync' into feat/ras-sync-class
miguelpeixe Aug 23, 2024
d741958
refactor: remove traits
miguelpeixe Aug 23, 2024
f86891a
chore: fix redundant const name
miguelpeixe Aug 23, 2024
3bd55da
fix: class access
miguelpeixe Aug 24, 2024
72735d8
Merge branch 'feat/woo-sync-tools' into feat/esp-connector-with-sync
miguelpeixe Aug 24, 2024
604ed75
Merge branch 'feat/esp-connector-with-sync' into feat/ras-sync-class
miguelpeixe Aug 24, 2024
cee6e1a
chore: move normalize contact metadata
miguelpeixe Aug 26, 2024
ab7d325
chore: update method name and removed unused test
miguelpeixe Aug 26, 2024
fd27a50
chore: update method name
miguelpeixe Aug 26, 2024
076840f
Merge branch 'feat/esp-connector-with-sync' into feat/ras-sync-class
miguelpeixe Aug 26, 2024
c4b9276
fix: let the normalizer transform the keys
miguelpeixe Aug 26, 2024
53e706d
fix: log ignored keys
miguelpeixe Aug 26, 2024
58d4618
fix: remove mc logic
miguelpeixe Aug 26, 2024
cf81320
chore: remove unused test
miguelpeixe Aug 26, 2024
282b130
fix: better handling of allowed keys
miguelpeixe Aug 26, 2024
44ca1e4
Merge branch 'trunk' into feat/woo-sync-tools
miguelpeixe Aug 27, 2024
d642822
Merge branch 'feat/woo-sync-tools' into feat/esp-connector-with-sync
miguelpeixe Aug 27, 2024
a6c1365
fix: add membership_saved handler
miguelpeixe Aug 27, 2024
4bb4273
Merge branch 'feat/esp-connector-with-sync' into feat/ras-sync-class
miguelpeixe Aug 27, 2024
25bd81d
chore: merge tweaks
miguelpeixe Aug 27, 2024
fbb3808
fix: tests
miguelpeixe Aug 27, 2024
38183ef
chore: fix assertion
miguelpeixe Aug 27, 2024
2261c71
fix: assertion
miguelpeixe Aug 27, 2024
a256b54
Merge branch 'trunk' into feat/woo-sync-tools
miguelpeixe Aug 27, 2024
8d8f398
Merge branch 'feat/woo-sync-tools' into feat/esp-connector-with-sync
miguelpeixe Aug 27, 2024
489a23b
Merge branch 'feat/esp-connector-with-sync' into feat/ras-sync-class
miguelpeixe Aug 27, 2024
97b8056
fix: method calling and remove unused code
miguelpeixe Aug 27, 2024
a8656cd
fix: method calling
miguelpeixe Aug 27, 2024
6ff08d8
Merge branch 'trunk' into feat/woo-sync-tools
miguelpeixe Aug 28, 2024
245fafa
Merge branch 'feat/woo-sync-tools' into feat/esp-connector-with-sync
miguelpeixe Aug 28, 2024
7768028
Merge branch 'feat/esp-connector-with-sync' into feat/ras-sync-class
miguelpeixe Aug 28, 2024
5dcef2e
chore: merge bf9e9978d76cd3e99a2fb2774d80e3a65f8369ca
miguelpeixe Aug 28, 2024
340d561
fix: variable name
miguelpeixe Aug 28, 2024
b07e1b1
fix: method calling
miguelpeixe Aug 28, 2024
9a2bdce
Merge branch 'trunk' into feat/esp-connector-with-sync
miguelpeixe Aug 29, 2024
373e157
fix: update methods and constant
miguelpeixe Aug 29, 2024
a45a961
Merge branch 'feat/esp-connector-with-sync' into feat/ras-sync-class
miguelpeixe Aug 29, 2024
84d16e1
fix: change method call
miguelpeixe Aug 29, 2024
1d198b9
fix: remove "reader_registered" metadata filter and favor the sync fi…
miguelpeixe Aug 30, 2024
c56aa6e
Merge branch 'feat/esp-connector-with-sync' into feat/ras-sync-class
miguelpeixe Aug 30, 2024
4d4b0b1
Merge branch 'trunk' into feat/ras-sync-class
miguelpeixe Aug 30, 2024
026f96a
chore: simplify method
miguelpeixe Aug 30, 2024
45534a6
chore: remove deprecated strategy
miguelpeixe Aug 30, 2024
cb14d17
fix: improve and test `can_esp_sync()`
miguelpeixe Sep 2, 2024
b6c293f
test: fix method name
miguelpeixe Sep 2, 2024
e300265
fix: remove newsletters mocks
miguelpeixe Sep 2, 2024
659e6f9
fix: namespace
miguelpeixe Sep 2, 2024
31f49a5
fix: typo
miguelpeixe Sep 2, 2024
b9ef4b2
test: esp sync ras seting
miguelpeixe Sep 2, 2024
58e8e1a
fix: simplify master list fetch
miguelpeixe Sep 2, 2024
3493d24
fix: simplify logic
miguelpeixe Sep 2, 2024
1bd45c5
Merge branch 'trunk' into feat/ras-sync-class
miguelpeixe Sep 4, 2024
77793e7
fix: utm meta key
miguelpeixe Sep 4, 2024
8ba3612
fix: support raw utm keys
miguelpeixe Sep 4, 2024
e3d8ae1
fix: utm tests
miguelpeixe Sep 4, 2024
5b06af1
fix: skip utm if not enabled
miguelpeixe Sep 4, 2024
32584d8
fix: dont format woo_team key
miguelpeixe Sep 4, 2024
d22dd80
fix: remove Sync extension from Metadata and WooCommerce classes
miguelpeixe Sep 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions includes/class-newspack.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ private function includes() {
include_once NEWSPACK_ABSPATH . 'includes/reader-activation/class-reader-activation-emails.php';
include_once NEWSPACK_ABSPATH . 'includes/reader-activation/class-reader-activation.php';
include_once NEWSPACK_ABSPATH . 'includes/reader-activation/class-reader-data.php';
include_once NEWSPACK_ABSPATH . 'includes/reader-activation/class-esp-sync.php';
include_once NEWSPACK_ABSPATH . 'includes/reader-activation/class-esp-sync-admin.php';
include_once NEWSPACK_ABSPATH . 'includes/reader-activation/sync/class-sync.php';
include_once NEWSPACK_ABSPATH . 'includes/reader-activation/sync/class-metadata.php';
include_once NEWSPACK_ABSPATH . 'includes/reader-activation/sync/class-woocommerce.php';
include_once NEWSPACK_ABSPATH . 'includes/reader-activation/sync/class-esp-sync.php';
include_once NEWSPACK_ABSPATH . 'includes/reader-activation/sync/class-esp-sync-admin.php';
include_once NEWSPACK_ABSPATH . 'includes/data-events/class-utils.php';
include_once NEWSPACK_ABSPATH . 'includes/data-events/class-data-events.php';
include_once NEWSPACK_ABSPATH . 'includes/data-events/class-webhooks.php';
Expand Down Expand Up @@ -152,7 +155,6 @@ private function includes() {
include_once NEWSPACK_ABSPATH . 'includes/plugins/class-jetpack.php';
include_once NEWSPACK_ABSPATH . 'includes/plugins/class-gravityforms.php';
include_once NEWSPACK_ABSPATH . 'includes/plugins/google-site-kit/class-googlesitekit.php';
include_once NEWSPACK_ABSPATH . 'includes/plugins/class-newspack-newsletters.php';
include_once NEWSPACK_ABSPATH . 'includes/plugins/class-mailchimp-for-woocommerce.php';
include_once NEWSPACK_ABSPATH . 'includes/plugins/class-onesignal.php';
include_once NEWSPACK_ABSPATH . 'includes/plugins/class-organic-profile-block.php';
Expand Down
2 changes: 1 addition & 1 deletion includes/data-events/class-memberships.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private static function get_order_data( $order_id, $order ) {
*/
public static function woocommerce_checkout_order_processed( $order_id ) {
$order = \wc_get_order( $order_id );
if ( ! \Newspack\WooCommerce_Connection::should_sync_order( $order ) ) {
if ( ! Reader_Activation\Sync\WooCommerce::should_sync_order( $order ) ) {
return;
}
$data = self::get_order_data( $order_id, $order );
Expand Down
2 changes: 1 addition & 1 deletion includes/data-events/class-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static function get_order_data( $order_id, $process_donations_only = fals
if ( ! $order ) {
return;
}
if ( ! \Newspack\WooCommerce_Connection::should_sync_order( $order ) ) {
if ( ! \Newspack\Reader_Activation\Sync\WooCommerce::should_sync_order( $order ) ) {
return;
}

Expand Down
32 changes: 13 additions & 19 deletions includes/data-events/connectors/class-esp-connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
namespace Newspack\Data_Events\Connectors;

use Newspack\Data_Events;
use Newspack\WooCommerce_Connection;
use Newspack\Newspack_Newsletters;
use Newspack\Reader_Activation;
use Newspack\Reader_Activation\Sync;
use Newspack_Newsletters_Contacts;

defined( 'ABSPATH' ) || exit;
Expand Down Expand Up @@ -53,17 +52,15 @@ public static function register_handlers() {
* @param int $client_id ID of the client that triggered the event.
*/
public static function reader_registered( $timestamp, $data, $client_id ) {
$account_key = Newspack_Newsletters::get_metadata_key( 'account' );
$registration_date_key = Newspack_Newsletters::get_metadata_key( 'registration_date' );
$metadata = [
$account_key => $data['user_id'],
$registration_date_key => gmdate( Newspack_Newsletters::METADATA_DATE_FORMAT, $timestamp ),
$metadata = [
'account' => $data['user_id'],
'registration_date' => gmdate( Sync\Metadata::DATE_FORMAT, $timestamp ),
];
if ( isset( $data['metadata']['current_page_url'] ) ) {
$metadata[ Newspack_Newsletters::get_metadata_key( 'registration_page' ) ] = $data['metadata']['current_page_url'];
$metadata['registration_page'] = $data['metadata']['current_page_url'];
}
if ( isset( $data['metadata']['registration_method'] ) ) {
$metadata[ Newspack_Newsletters::get_metadata_key( 'registration_method' ) ] = $data['metadata']['registration_method'];
$metadata['registration_method'] = $data['metadata']['registration_method'];
}

$contact = [
Expand Down Expand Up @@ -93,7 +90,7 @@ public static function reader_logged_in( $timestamp, $data, $client_id ) {
return;
}

$contact = WooCommerce_Connection::get_contact_from_customer( $customer );
$contact = Sync\WooCommerce::get_contact_from_customer( $customer );

self::sync( $contact, 'RAS Reader login' );
}
Expand All @@ -117,7 +114,7 @@ public static function order_completed( $timestamp, $data, $client_id ) {
}

$order_id = $data['platform_data']['order_id'];
$contact = WooCommerce_Connection::get_contact_from_order( $order_id, $data['referer'] );
$contact = Sync\WooCommerce::get_contact_from_order( $order_id, $data['referer'] );

if ( ! $contact ) {
return;
Expand Down Expand Up @@ -148,7 +145,7 @@ public static function membership_saved( $timestamp, $data, $client_id ) {
$contact = [ 'email' => $data['email'] ];
foreach ( $filtered_enabled_fields as $key => $value ) {
if ( isset( $data[ $key ] ) ) {
$contact['metadata'][ Newspack_Newsletters::get_metadata_key( $key ) ] = $data[ $key ];
$contact['metadata'][ $key ] = $data[ $key ];
}
}

Expand All @@ -167,7 +164,7 @@ public static function subscription_updated( $timestamp, $data, $client_id ) {
return;
}

$contact = WooCommerce_Connection::get_contact_from_order( $data['subscription_id'] );
$contact = Sync\WooCommerce::get_contact_from_order( $data['subscription_id'] );

if ( ! $contact ) {
return;
Expand Down Expand Up @@ -216,12 +213,9 @@ public static function newsletter_updated( $timestamp, $data ) {
}
}

$account_key = Newspack_Newsletters::get_metadata_key( 'account' );
$newsletter_selection_key = Newspack_Newsletters::get_metadata_key( 'newsletter_selection' );

$metadata = [
$account_key => $data['user_id'],
$newsletter_selection_key => implode( ', ', $lists_names ),
'account' => $data['user_id'],
'newsletter_selection' => implode( ', ', $lists_names ),
];
$contact = [
'email' => $data['email'],
Expand All @@ -241,7 +235,7 @@ public static function network_new_reader( $timestamp, $data, $client_id ) {
$user_id = $data['user_id'];
$registration_site = $data['registration_site'];

$contact = WooCommerce_Connection::get_contact_from_customer( new \WC_Customer( $user_id ) );
$contact = Sync\WooCommerce::get_contact_from_customer( new \WC_Customer( $user_id ) );

if ( ! $contact ) {
return;
Expand Down
Loading