1

Connected to Woocommerce API and Retrieving all Products

getAllProducts = wcapi.get('products')
products = getAllProducts.json()

This code returns 3 Products in json format

for product in products:
print(['id'])

Attempting to retrieve each product id from the json Data but when the code runs it prints

['id']
['id']
['id']

The number of IDS is correct as i have 3 products in my store. How can i return each product ID and store them into a variable for later use. Below is a snipped of the json data.

[{'id': 944, 'name': 'my product 1'}]

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.