├── README.md
├── services.js
└── wcapi.js
/README.md:
--------------------------------------------------------------------------------
1 | # WC-API-JS-Client
2 |
3 | Add a reference to your index.html file
4 |
5 | ``
6 |
7 | ``
8 |
9 | ##### Do not forget to add your `store URL`, `consumer key` and `consumer secret` to the _services.js_ file.
10 |
11 | Inject the `WC` service in your controllers.
12 |
13 | ```javascript
14 | app.controller('myCtrl', function($scope, WC){
15 | var Woocommerce = WC.WC();
16 |
17 | Woocommerce.get('products/categories', function(err, data, res){
18 | if(err)
19 | console.log(err);
20 | console.log(JSON.parse(res));
21 | })
22 | });
23 | ```
24 |
25 | **You may need to change the Module Name accordingly in the services.js file.**
26 |
27 | *Works like a Charm in Ionic and AngularJS apps (Keys are mentioned in the client apps which can be exploited, so use at your own risk).*
28 | _For more endpoints check the documentation at [https://github.com/woothemes/wc-api-node](https://github.com/woothemes/wc-api-node "WC NODE API")_
29 |
30 |
31 |
--------------------------------------------------------------------------------
/services.js:
--------------------------------------------------------------------------------
1 | angular.module('starter.services',[])
2 | .service('WC', function(){
3 | return {
4 | WC: function(){
5 | var Woocommerce = new WoocommerceAPI({
6 | url: 'http://www.your_website.com',
7 | consumerKey: 'ck_your_consumer_key_here',
8 | consumerSecret: 'cs_your_consumer_secret_here',
9 | wpAPI: true, //or false if you want to use the legacy API v3
10 | version: 'wc/v2' //or wc/v1
11 | })
12 | return Woocommerce;
13 | }
14 | }});
15 |
--------------------------------------------------------------------------------