• Resolved samuellinde

    (@samuellinde)


    We have a product attribute for manufacturer’s SKU, and sometimes need to make calls to the products REST API endpoint filtering on that attribute (returning a single product, obviously, but thats not the main issue). I just can’t figure out how the parameters should be formatted.

    The documentation for filtering on attributes seems to refer to global attributes, which have a “proper” slug if I understand correctly. But when we set up the shop we got the impression that global attributes was intended for things that we maybe wanted to be able to filter by in the frontend, which is why we settled for using custom attributes per product (all using the same label, obviously).

    Are we looking at things from the wrong end? Is there a better way to store these values that would let us filter properly via the API?

    Cheers!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter samuellinde

    (@samuellinde)

    No suggestions so far – is there any other way to filter on custom attributes/fields? Any plugin I should look for?

    Luminus Alabi

    (@luminus)

    Automattic Happiness Engineer

    Hi @samuellinde,

    I’m a little confused here. WooCommerce already has an SKU field by default, so I’m not sure why you have a custom SKU attribute for your products.

    That aside, if you’ve got multiple products that have the same attribute, setting that up as a global attribute just makes things a lot easier.

    For example, if you run a tee shirt store, all your shirts are going to have the size and colour attributes. Instead of using attributes for each product, you can just select the relevant colours or sizes for each product.

    You’d then be able to retrieve an attribute as documented here – https://woocommerce.github.io/woocommerce-rest-api-docs/?php#retrieve-a-product-attribute

    Luminus Alabi

    (@luminus)

    Automattic Happiness Engineer

    @samuellinde,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

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

The topic ‘[REST API] Filter products on attribute’ is closed to new replies.