get_meta('_yoone_bundle_id'); if (!$bundle_id) { return; } global $wpdb; // 获取混装详情 $bundle = $wpdb->get_row($wpdb->prepare( "SELECT * FROM {$wpdb->prefix}yoone_bundles WHERE id = %d AND status = 'active'", $bundle_id )); if (!$bundle) { return; } // 获取混装商品 $bundle_items = $wpdb->get_results($wpdb->prepare( "SELECT bi.*, p.post_title as product_name, p.post_excerpt as product_excerpt FROM {$wpdb->prefix}yoone_bundle_items bi LEFT JOIN {$wpdb->posts} p ON bi.product_id = p.ID WHERE bi.bundle_id = %d AND p.post_status = 'publish' ORDER BY bi.sort_order ASC", $bundle->id )); if (empty($bundle_items)) { return; } // 计算总价和折扣 $original_total = 0; $bundle_total = 0; foreach ($bundle_items as $item) { $item_product = wc_get_product($item->product_id); if ($item_product) { $item_price = $item_product->get_price(); $original_total += $item_price * $item->quantity; } } // 计算折扣后价格 if ($bundle->discount_type === 'percentage') { $bundle_total = $original_total * (1 - $bundle->discount_value / 100); } else { $bundle_total = max(0, $original_total - $bundle->discount_value); } $savings = $original_total - $bundle_total; $savings_percentage = $original_total > 0 ? ($savings / $original_total) * 100 : 0; ?>
0): ?>
description): ?>

description); ?>

product_id); if (!$item_product) continue; $item_price = $item_product->get_price(); $item_total = $item_price * $item->quantity; ?>
get_image('thumbnail'); ?>
product_name); ?>
product_excerpt): ?>

product_excerpt); ?>

quantity); ?> quantity > 1): ?> ()
0): ?>
()