File tree Expand file tree Collapse file tree 5 files changed +53
-113
lines changed Expand file tree Collapse file tree 5 files changed +53
-113
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ WooCommerce Rest API with Laravel
44#Install
55
66```
7- composer require codexshaper/laravel- woocommerce
7+ composer require codexshaper/woocommerce
88```
99
1010#Publish config file
Original file line number Diff line number Diff line change @@ -10,34 +10,4 @@ class Customer
1010 use QueryBuilderTrait;
1111
1212 protected $ endpoint = 'customers ' ;
13-
14- public function all ($ options = [])
15- {
16- return WooCommerce::all ('customers ' , $ options );
17- }
18-
19- public function find ($ id , $ options = [])
20- {
21- return WooCommerce::find ("customers/ {$ id }" , $ options );
22- }
23-
24- public function create ($ data )
25- {
26- return WooCommerce::create ('customers ' , $ data );
27- }
28-
29- public function update ($ id , $ data )
30- {
31- return WooCommerce::update ("customers/ {$ id }" , $ data );
32- }
33-
34- public function delete ($ id , $ options = [])
35- {
36- return WooCommerce::delete ("customers/ {$ id }" , $ options );
37- }
38-
39- public function batch ($ data )
40- {
41- return WooCommerce::create ('customers/batch ' , $ options );
42- }
4313}
Original file line number Diff line number Diff line change @@ -11,36 +11,6 @@ class Order
1111
1212 protected $ endpoint = 'orders ' ;
1313
14- public function all ($ options = [])
15- {
16- return WooCommerce::all ('orders ' , $ options );
17- }
18-
19- public function find ($ id , $ options = [])
20- {
21- return collect (WooCommerce::find ("orders/ {$ id }" , $ options ));
22- }
23-
24- public function create ($ data )
25- {
26- return WooCommerce::create ('orders ' , $ data );
27- }
28-
29- public function update ($ id , $ data )
30- {
31- return WooCommerce::update ("orders/ {$ id }" , $ data );
32- }
33-
34- public function delete ($ id , $ options = [])
35- {
36- return WooCommerce::delete ("orders/ {$ id }" , $ options );
37- }
38-
39- public function batch ($ data )
40- {
41- return WooCommerce::create ('orders/batch ' , $ data );
42- }
43-
4414 /*
4515 * Note
4616 */
Original file line number Diff line number Diff line change @@ -10,56 +10,4 @@ class Product
1010 use QueryBuilderTrait;
1111
1212 protected $ endpoint = 'products ' ;
13-
14- /**
15- * Retrieve all products
16- *
17- * @param array $options
18- *
19- * @return array
20- */
21- public function all ($ options = [])
22- {
23- return WooCommerce::all ('products ' , $ options );
24- }
25-
26- /**
27- * Retrieve single product
28- *
29- * @param integer $id
30- * @param array $options
31- *
32- * @return object
33- */
34- public function find ($ id , $ options = [])
35- {
36- return collect (WooCommerce::find ("products/ {$ id }" , $ options ));
37- }
38-
39- /**
40- * Create new product
41- *
42- * @param array $data
43- *
44- * @return object
45- */
46- public function create ($ data )
47- {
48- return WooCommerce::create ('products ' , $ data );
49- }
50-
51- public function update ($ id , $ data )
52- {
53- return WooCommerce::update ("products/ {$ id }" , $ data );
54- }
55-
56- public function delete ($ id , $ options = [])
57- {
58- return WooCommerce::delete ("products/ {$ id }" , $ options );
59- }
60-
61- public function batch ($ data )
62- {
63- return WooCommerce::create ('products/batch ' , $ options );
64- }
6513}
Original file line number Diff line number Diff line change @@ -11,6 +11,58 @@ trait QueryBuilderTrait
1111 */
1212 protected $ options = [];
1313
14+ /**
15+ * Retrieve all products
16+ *
17+ * @param array $options
18+ *
19+ * @return array
20+ */
21+ public function all ($ options = [])
22+ {
23+ return WooCommerce::all ($ this ->endpoint , $ options );
24+ }
25+
26+ /**
27+ * Retrieve single product
28+ *
29+ * @param integer $id
30+ * @param array $options
31+ *
32+ * @return object
33+ */
34+ public function find ($ id , $ options = [])
35+ {
36+ return collect (WooCommerce::find ("{$ this ->endpoint }/ {$ id }" , $ options ));
37+ }
38+
39+ /**
40+ * Create new product
41+ *
42+ * @param array $data
43+ *
44+ * @return object
45+ */
46+ public function create ($ data )
47+ {
48+ return WooCommerce::create ($ this ->endpoint , $ data );
49+ }
50+
51+ public function update ($ id , $ data )
52+ {
53+ return WooCommerce::update ("{$ this ->endpoint }/ {$ id }" , $ data );
54+ }
55+
56+ public function delete ($ id , $ options = [])
57+ {
58+ return WooCommerce::delete ("{$ this ->endpoint }/ {$ id }" , $ options );
59+ }
60+
61+ public function batch ($ data )
62+ {
63+ return WooCommerce::create ('{$this->endpoint}/batch ' , $ options );
64+ }
65+
1466 /**
1567 * Retrieve data
1668 *
You can’t perform that action at this time.
0 commit comments