最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Add multiple attributes to product from php

programmeradmin0浏览0评论

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?

Thanks

发布评论

评论列表(0)

  1. 暂无评论