Skip to content

Instantly share code, notes, and snippets.

@matiaslopezd
Last active February 14, 2020 03:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matiaslopezd/ad6b8ea839d9052f8cb183dea3ff4b28 to your computer and use it in GitHub Desktop.
Save matiaslopezd/ad6b8ea839d9052f8cb183dea3ff4b28 to your computer and use it in GitHub Desktop.
How to use Woocommerce Rest API v3 - Not legacy! | Como usar Rest API de Woocommerce v3 - No heredada

Autorización

Para usar la Rest API es necesario proveer de consumer_key y consumer_secret en la URL como parámetros. (Nunca pude pasarlo en la cabecera)

Ejemplo:

https://mywebsite.com/wp-json/wc/v3/products?consumer_key=XXXX&consumer_secret=XXXX

Filtrar Productos

Para filtrar productos por category, attribute o attribute_term se necesita entender la nonemclatura de cada parámetro:

  • category: Es el ID como integer
  • attribute: Es el slug como string. Es muy importante entender que el sug se compone de un prefix pa_. Ejemplo: pa_color
  • attribute_term: Es el ID como integer

También es posible filtrar por múltiples attributes.

Ejemplo

https://mywebsite.com/wp-json/wc/v3/products?consumer_key=XXXX&consumer_secret=XXXX&attribute=pa_color&attribute_term=34&attribute=pa_box&atrribute_term=52

Authorization

For use Rest API need provide consumer_key and consumer_secret in URL like parameters. (I could never provide by header)

Example:

https://mywebsite.com/wp-json/wc/v3/products?consumer_key=XXXX&consumer_secret=XXXX

Filter Products

For filter products by category, attribute or attribute_term need understand the nomenclature of every parameter:

  • category: Is the ID like a integer
  • attribute: Is a the slug like string. Is really important understand that the slug is composed of a prefix pa_. Example: pa_color
  • attribute_term: Is the ID like a integer

Also can filter by multiple attributes.

Example

https://mywebsite.com/wp-json/wc/v3/products?consumer_key=XXXX&consumer_secret=XXXX&attribute=pa_color&attribute_term=34&attribute=pa_box&atrribute_term=52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment