まず、plugin_loadedフックは、このために右フックのようです(私が間違っている可能性がある)ではない...
今、あなたはあなたの製品を得るために、いくつかの最低限の引数を追加する必要があります。
$products = wc_get_products(array(
'numberposts' => -1,
'post_status' => 'published', // Only published products
// 'meta_key' => '_customer_user',
// 'meta_value' => get_current_user_id(), // Or $user_id
));
あなたが何かを得ることを確認する(例えば)カートページの一番上に出力を表示するには、テストの目的のためだけにしてみてください:
add_action('woocommerce_before_cart', 'custom_raw_output');
function custom_raw_output(){
$products = wc_get_products(array(
'numberposts' => -1,
'post_status' => 'published',
));
echo '<pre>'; print_r($products); echo '</pre>';
}
コードは(あなたのアクティブな子テーマのfunction.phpファイルに行きますまたはテーマ)または任意のプラグインファイルでも使用できます。
...
イエップ。完全に正しい。それは問題を起こした行動でした。それを考慮しなかった。 – sarte