🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

ng2woo

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng2woo

Angular2+ wrapper for the WooCommerce API

0.1.0
Source
npm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

WaNG (In development)

Angular2+ wrapper for the WooCommerce API

Please note this library is not yet pubished or active, it is currently being developed. Visit the Discord Channel if you have an idea or feature request for this project.

GitHub version dependencies Status GitHub issues Discord Chat

Installation

To install this library, run:

$ npm install woo-wrapper --save (not yet published)

Usage

Import woo-wrapper in any Angular application by running:

$ npm install woo-wrapper (not yet published)

and then from your Angular AppModule:

...
// Import WaNG
import { WooApiModule, WooApiService } from 'woo-wrapper';

// Add your WooCommerce Credentials
const WooCommerceConfig = {
  url: 'your_site_url',
  consumerKey: 'ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  consumerSecret: 'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  wpAPI: true,
  version: 'wc/v1'
};

@NgModule({
  declarations: [...],
  imports: [
    ...
    // Specify as an import and pass in your config
    WooApiModule.forRoot(WooCommerceConfig)
  ],
  // Add the Api service to the provider
  providers: [WooApiService]
})
export class AppModule { }

Once woo-wrapper is imported, you can use the WooApiService:

import { Component, OnInit } from '@angular/core';
// Import the services
import { WooApiService } from 'woo-wrapper';


@Component({...})
export class HomePage implements OnInit { 

  products: any;
  // Inject the service
  constructor(private woo: WooApiService) { }

  ngOnInit(): void {
    // Fetch all products
    this.woo.fetchItems('products')
      .then(products => console.log(products));
  }

}

Methods

fetchItems(itemType)

  • Accepts: string (required) - the type of WooCommerce item you want to fetch (products, orders, customers, categories). Accepts query parameters, see the WooCommerce Api docs for a full list of query parameters.
  • Returns: Promise

Example

this.woo.fetchItems('products')
  .then(products => console.log(products));

Development

To generate all *.js, *.js.map and *.d.ts files:

$ npm run tsc

To lint all *.ts files:

$ npm run lint

License

MIT © Michael Doye

Keywords

angular

FAQs

Package last updated on 21 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts