is_type('simple')) { $allowed_products[$pid] = $p; } } // 兜底:如果为 exclude/all 模式,但由于缓存或其他原因导致 allowed_products 为空,则直接读取所有 simple 产品 if (empty($allowed_products) && in_array($select_mode, array('exclude','all'), true)) { $all_ids = wc_get_products(array( 'type' => array('simple'), 'status' => array('publish'), 'catalog_visibility' => 'any', 'limit' => -1, 'return' => 'ids', )); if (is_array($all_ids)) { foreach ($all_ids as $pid) { $p = wc_get_product($pid); if ($p && $p->is_type('simple')) { $allowed_products[$pid] = $p; } } } } $groups = array(); if (!empty($term_ids)) { $is_grouped = true; $others = array(); foreach ($allowed_products as $pid => $p) { $terms = get_the_terms($pid, $group_taxonomy); $matched = false; if (is_array($terms)) { foreach ($terms as $t) { if (in_array($t->term_id, $term_ids, true)) { if (!isset($groups[$t->term_id])) { $groups[$t->term_id] = array('term' => $t, 'items' => array()); } $groups[$t->term_id]['items'][] = $p; $matched = true; } } } if (!$matched) $others[] = $p; } if (!empty($others)) $groups[0] = array('term' => null, 'items' => $others); } else { $is_grouped = false; $groups[0] = array('term' => null, 'items' => array_values($allowed_products)); } // --- 数据准备逻辑结束 --- ?>

0

0

0) : ?>

0

$group) : ?>

name); ?>

get_id(); $thumbnail = $item->get_image('woocommerce_thumbnail'); ?>

get_name()); ?>

get_price_html()); ?>