簡體   English   中英

自定義分類WooCommerce Rest API

[英]Custom Taxonomy WooCommerce Rest API

我目前正在使用的Wordpress應用程序是使用WooCommerce和Tabify。

大多數字段都定義為自定義字段,我可以通過在查詢中添加filter[meta]=true來獲得,但有兩個StatusRegion已被定義為Custom Taxonomies。

我一直在尋找一種方法來使用Rest API獲取這些數據,但到目前為止還沒有運氣。

誰能指出我正確的方向?

我最終想通了。 也許這不是最實用的解決方案,每次我更新WooCommerce插件時都必須重新應用,但只需更新這樣的產品API

private function get_product_data( $product ) {
    return array(
       // your other properties go here
       'region' => wp_get_post_terms( $product->id, 'productRegion', array( 'fields' => 'names' ) ),
       'status' => wp_get_post_terms( $product->id, 'productActive', array( 'fields' => 'names' ) ),
    )
}

現在我只是從響應中訪問region [0]和status [0]並做我需要做的任何事情。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM