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

Woocommerce get attributes

programmeradmin3浏览0评论

Hello i got many errors in my debug.log about product attribute called wrong way.

here is what i got : PHP Notice: post was called incorrectly. Product properties should not be accessed directly.

here is my code :

$formateur = $product->attributes[formateur][options][0];

what should i use now ? does this can affect my website ?

i tried to use get_attributes() but i get an array :

Array ( [duree] => WC_Product_Attribute Object ( [data:protected] => Array ( [id] => 0 [name] => Durée [options] => Array ( [0] => 35 heures – 5 jours ) [position] => 0 [visible] => 1 [variation] => ) ) [formateur] => WC_Product_Attribute Object ( [data:protected] => Array ( [id] => 0 [name] => Formateur [options] => Array ( [0] => Expert FEECS ) [position] => 1 [visible] => 1 [variation] => ) ) [lieu] => WC_Product_Attribute Object ( [data:protected] => Array ( [id] => 0 [name] => Lieu [options] => Array ( [0] => Intra ou Inter ) [position] => 2 [visible] => 1 [variation] => ) ) [niveau] => WC_Product_Attribute Object ( [data:protected] => Array ( [id] => 0 [name] => Niveau [options] => Array ( [0] => niveau 1 ) [position] => 3 [visible] => 1 [variation] => ) ) )

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论