• Resolved bassimbg

    (@bassimbg)


    How can I retrieve only one argument of the API get call from product?
    for example I want to get only price and quantity from all products?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Phil

    (@fullysupportedphil)

    Automattic Happiness Engineer

    There are calls for each of these values:

    get_price()
    get_stock_quantity()

    I would recommend reviewing the API documentation, which you can find here:
    https://woocommerce.github.io/code-reference/packages/WooCommerce.html

    Thread Starter bassimbg

    (@bassimbg)

    I am looking to fetch only ID and Name from the product and not all the fields, I am using print_r($woocommerce->get(‘products’)); and getting all the fields of the product while, I am looking to have output such as:
    Array
    (
    [0] => stdClass Object
    (
    [id] => 3621
    [name] => Product xx1

    [1] => stdClass Object
    (
    [id] => 3620
    [name] => Product xx2
    )
    )

    Phil

    (@fullysupportedphil)

    Automattic Happiness Engineer

    I wouldn’t be able to say the exact call that you’ll need to make, as our support team doesn’t provide API and coding support. I’d recommend joining our developer slack community as you’ll be able to get more developer-specific input there:

    WooCommerce Developer Slack.

    That would be a good place to ask this ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Get one argument of product’ is closed to new replies.