亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

woocommerce 所有產品尺寸的列表

woocommerce 所有產品尺寸的列表

PHP
慕的地6264312 2022-07-16 16:32:47
我需要獲取所有產品尺寸(寬度和高度)。我使用這段代碼:$allProducts = wc_get_products(array(    'status' => 'publish',));$allWidthArr = array();$allHeightArr = array();foreach ( $allProducts as $product ) {    $allWidthArr[] = $product->get_width();    $allHeightArr[] = $product->get_height();}我可以在不循環所有產品的情況下獲取這些數據嗎?
查看完整描述

1 回答

?
慕妹3146593

TA貢獻1820條經驗 獲得超9個贊

我建議使用 MYSQL 查詢。


嘗試以下代碼行,


global $wpdb;


$list_of_heights = $wpdb->get_results('SELECT post_meta.meta_value FROM '.$wpdb->prefix.'posts posts INNER JOIN '.$wpdb->prefix.'postmeta post_meta

ON post_meta.post_id=posts.ID where post_type="product" and post_meta.meta_key="_height"',ARRAY_N);


$list_of_widths = $wpdb->get_results('SELECT post_meta.meta_value FROM '.$wpdb->prefix.'posts posts INNER JOIN '.$wpdb->prefix.'postmeta post_meta

    ON post_meta.post_id=posts.ID where post_type="product" and post_meta.meta_key="_width"',ARRAY_N);


查看完整回答
反對 回復 2022-07-16
  • 1 回答
  • 0 關注
  • 148 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號