Add multiple attributes to product from php

I’m trying to update a WooCommerce product entry with data from an API, where the values from the API match taxonomy terms I’ve created in my WordPress site.

For most fields this works, but I have one attribute that can contain multiple terms. Using update_post_meta I’m adding these, imploded to a string seperated by |.

$meta[] = array(
    'key' => 'pa_aantal_spelers',
    'value' => implode($players, ' | '),
    'visible' => 1,

When I view the product in the dashboard, the attribute looks good but the values aren’t interpreted correctly on the front-end on the site. When I then save the product, with the piped string as the attribute value, the value is set correctly.

Any advice on how I should be setting these multiple terms in the product attribute?


Read more here: Add multiple attributes to product from php

Leave a Reply

Your email address will not be published. Required fields are marked *