Skip to content

Commit 71df4c8

Browse files
Merge pull request #49 from mailerlite/2857-missing-woo-sync-method
added missing woo sync customer method
2 parents 151bbc5 + 65d9289 commit 71df4c8

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

src/Api/WooCommerce.php

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@ class WooCommerce extends ApiAbstract
1313
{
1414
protected $endpoint = 'woocommerce';
1515

16-
public function setConsumerData( $consumerKey, $consumerSecret, $store, $currency, $group_id, $resubscribe )
16+
public function setConsumerData( $consumerKey, $consumerSecret, $store, $currency, $group_id, $resubscribe, $ignoreList, $create_segments)
1717
{
1818
$endpoint = $this->endpoint . '/consumer_data';
1919

20-
$params = array_merge($this->prepareParams(),
21-
['consumer_key' => $consumerKey,
22-
'consumer_secret' => $consumerSecret,
23-
'store' => $store,
24-
'currency' => $currency,
25-
'group_id' => $group_id,
26-
'resubscribe' => $resubscribe]);
20+
$params = array_merge($this->prepareParams(),
21+
['consumer_key' => $consumerKey,
22+
'consumer_secret' => $consumerSecret,
23+
'store' => $store,
24+
'currency' => $currency,
25+
'group_id' => $group_id,
26+
'resubscribe' => $resubscribe,
27+
'ignore_list' => $ignoreList,
28+
'create_segments' => $create_segments]);
29+
2730
$response = $this->restClient->post( $endpoint, $params );
2831

2932
return $response['body'];
@@ -51,7 +54,7 @@ public function toggleShopConnection($shop, $activeState)
5154
return $this->restClient->post( $endpoint, $params );
5255
}
5356

54-
public function sendCartData($shopUrl, $cartData)
57+
public function sendCartData($shopUrl, $cartData)
5558
{
5659
$endpoint = 'woocommerce/save_cart';
5760

@@ -62,23 +65,23 @@ public function sendCartData($shopUrl, $cartData)
6265
} else {
6366
return true;
6467
}
65-
}
68+
}
6669

67-
public function sendSubscriberData($data)
70+
public function sendSubscriberData($data)
6871
{
6972
$endpoint = 'woocommerce/save_subscriber';
7073

7174
$params = array_merge($this->prepareParams(), ['data'=>$data] );
7275
$response = $this->restClient->post( $endpoint, $params );
73-
76+
7477
if (isset($response['body'])){
7578
return $response['body'];
7679
} else {
7780
return false;
7881
}
7982
}
8083

81-
public function sendOrderProcessingData($data)
84+
public function sendOrderProcessingData($data)
8285
{
8386
$endpoint = 'woocommerce/order_processing';
8487

@@ -92,11 +95,11 @@ public function sendOrderProcessingData($data)
9295
}
9396
}
9497

95-
public function getShopSettings($shopUrl)
98+
public function getShopSettings($shopUrl)
9699
{
97100
$shopName = parse_url($shopUrl, PHP_URL_HOST);
98101
$endpoint = 'woocommerce/settings/'.$shopName;
99-
102+
100103
return $this->restClient->get( $endpoint);
101104
}
102105

@@ -105,4 +108,18 @@ public function validateAccount()
105108
$endpoint = 'woocommerce/initial_account_settings';
106109
return $this->restClient->get($endpoint);
107110
}
111+
112+
public function syncCustomer($email, $fields, $shopUrl)
113+
{
114+
$endpoint = 'woocommerce/sync_customer';
115+
$params = array_merge($this->prepareParams(), ['email' => $email, 'subscriber_fields' => $fields, 'shop' => $shopUrl] );
116+
117+
$response = $this->restClient->post( $endpoint, $params );
118+
119+
if (isset($response['body'])) {
120+
return $response['body'];
121+
} else {
122+
return true;
123+
}
124+
}
108125
}

0 commit comments

Comments
 (0)