@@ -9,33 +9,33 @@ class WooCommerce extends ApiAbstract
99{
1010 protected $ endpoint = 'woocommerce ' ;
1111
12- public function setConsumerData ( $ consumerKey , $ consumerSecret , $ store , $ apiKey , $ currency )
12+ public function setConsumerData ( $ consumerKey , $ consumerSecret , $ store , $ currency , $ group_id , $ resubscribe )
1313 {
14-
1514 $ endpoint = $ this ->endpoint . '/consumer_data ' ;
1615
17- $ params = array_merge ($ this ->prepareParams (), ['consumer_key ' => $ consumerKey , 'consumer_secret ' => $ consumerSecret , 'store ' => $ store , 'api_key ' => $ apiKey , 'currency ' => $ currency ] );
18-
16+ $ params = array_merge ($ this ->prepareParams (),
17+ ['consumer_key ' => $ consumerKey ,
18+ 'consumer_secret ' => $ consumerSecret ,
19+ 'store ' => $ store ,
20+ 'currency ' => $ currency ,
21+ 'group_id ' => $ group_id ,
22+ 'resubscribe ' => $ resubscribe ]);
1923 $ response = $ this ->restClient ->post ( $ endpoint , $ params );
2024
2125 return $ response ['body ' ];
2226 }
2327
24- public function setWebhooks ($ shop )
25- {
26- $ endpoint = $ this ->endpoint .'/webhooks ' ;
27-
28- $ params = array_merge ($ this ->prepareParams (), ['shop ' => $ shop ] );
29-
30- return $ this ->restClient ->post ( $ endpoint , $ params );
31- }
32-
3328 public function saveOrder ($ orderData , $ shop )
3429 {
3530 $ endpoint = 'woocommerce/alternative_save_order ' ;
3631
3732 $ params = array_merge ($ this ->prepareParams (), ['order_data ' => $ orderData , 'shop ' => $ shop ] );
38- return $ this ->restClient ->post ( $ endpoint , $ params );
33+ $ response = $ this ->restClient ->post ( $ endpoint , $ params );
34+ if (isset ($ response ['body ' ])){
35+ return $ response ['body ' ];
36+ } else {
37+ return true ;
38+ }
3939 }
4040
4141 public function toggleShopConnection ($ shop , $ activeState )
@@ -47,14 +47,21 @@ public function toggleShopConnection($shop, $activeState)
4747 return $ this ->restClient ->post ( $ endpoint , $ params );
4848 }
4949
50- public function sendCartData ($ shopUrl , $ cartData ) {
50+ public function sendCartData ($ shopUrl , $ cartData )
51+ {
5152 $ endpoint = 'woocommerce/save_cart ' ;
5253
5354 $ params = array_merge ($ this ->prepareParams (), ['cart_data ' => $ cartData , 'shop ' => $ shopUrl ] );
54- return $ this ->restClient ->post ( $ endpoint , $ params );
55+ $ response = $ this ->restClient ->post ( $ endpoint , $ params );
56+ if (isset ($ response ['body ' ])){
57+ return $ response ['body ' ];
58+ } else {
59+ return true ;
60+ }
5561 }
5662
57- public function sendSubscriberData ($ data ) {
63+ public function sendSubscriberData ($ data )
64+ {
5865 $ endpoint = 'woocommerce/save_subscriber ' ;
5966
6067 $ params = array_merge ($ this ->prepareParams (), ['data ' =>$ data ] );
@@ -67,12 +74,31 @@ public function sendSubscriberData($data) {
6774 }
6875 }
6976
70- public function sendOrderProcessingData ($ data ) {
77+ public function sendOrderProcessingData ($ data )
78+ {
7179 $ endpoint = 'woocommerce/order_processing ' ;
7280
7381 $ params = array_merge ($ this ->prepareParams (), ['data ' =>$ data ] );
74- $ this ->restClient ->post ( $ endpoint , $ params );
82+ $ response = $ this ->restClient ->post ( $ endpoint , $ params );
7583
76- return true ;
84+ if (isset ($ response ['body ' ])){
85+ return $ response ['body ' ];
86+ } else {
87+ return true ;
88+ }
89+ }
90+
91+ public function getShopSettings ($ shopUrl )
92+ {
93+ $ shopName = parse_url ($ shopUrl , PHP_URL_HOST );
94+ $ endpoint = 'woocommerce/settings/ ' .$ shopName ;
95+
96+ return $ this ->restClient ->get ( $ endpoint );
97+ }
98+
99+ public function validateAccount ()
100+ {
101+ $ endpoint = 'woocommerce/initial_account_settings ' ;
102+ return $ this ->restClient ->get ($ endpoint );
77103 }
78104}
0 commit comments