@@ -13,17 +13,20 @@ class WooCommerce extends ApiAbstract
13
13
{
14
14
protected $ endpoint = 'woocommerce ' ;
15
15
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 )
17
17
{
18
18
$ endpoint = $ this ->endpoint . '/consumer_data ' ;
19
19
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
+
27
30
$ response = $ this ->restClient ->post ( $ endpoint , $ params );
28
31
29
32
return $ response ['body ' ];
@@ -51,7 +54,7 @@ public function toggleShopConnection($shop, $activeState)
51
54
return $ this ->restClient ->post ( $ endpoint , $ params );
52
55
}
53
56
54
- public function sendCartData ($ shopUrl , $ cartData )
57
+ public function sendCartData ($ shopUrl , $ cartData )
55
58
{
56
59
$ endpoint = 'woocommerce/save_cart ' ;
57
60
@@ -62,23 +65,23 @@ public function sendCartData($shopUrl, $cartData)
62
65
} else {
63
66
return true ;
64
67
}
65
- }
68
+ }
66
69
67
- public function sendSubscriberData ($ data )
70
+ public function sendSubscriberData ($ data )
68
71
{
69
72
$ endpoint = 'woocommerce/save_subscriber ' ;
70
73
71
74
$ params = array_merge ($ this ->prepareParams (), ['data ' =>$ data ] );
72
75
$ response = $ this ->restClient ->post ( $ endpoint , $ params );
73
-
76
+
74
77
if (isset ($ response ['body ' ])){
75
78
return $ response ['body ' ];
76
79
} else {
77
80
return false ;
78
81
}
79
82
}
80
83
81
- public function sendOrderProcessingData ($ data )
84
+ public function sendOrderProcessingData ($ data )
82
85
{
83
86
$ endpoint = 'woocommerce/order_processing ' ;
84
87
@@ -92,11 +95,11 @@ public function sendOrderProcessingData($data)
92
95
}
93
96
}
94
97
95
- public function getShopSettings ($ shopUrl )
98
+ public function getShopSettings ($ shopUrl )
96
99
{
97
100
$ shopName = parse_url ($ shopUrl , PHP_URL_HOST );
98
101
$ endpoint = 'woocommerce/settings/ ' .$ shopName ;
99
-
102
+
100
103
return $ this ->restClient ->get ( $ endpoint );
101
104
}
102
105
@@ -105,4 +108,18 @@ public function validateAccount()
105
108
$ endpoint = 'woocommerce/initial_account_settings ' ;
106
109
return $ this ->restClient ->get ($ endpoint );
107
110
}
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
+ }
108
125
}
0 commit comments