Fix variable product variations retrieval

Changed from get_available_variations() to get_children() for more reliable
variation ID retrieval. The previous method returned variation data arrays
which may not have worked correctly in all contexts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-31 22:56:07 +01:00
parent 755108a7d3
commit ba28ae174f

View File

@@ -170,9 +170,10 @@ class Product_Type extends \WC_Product {
// Handle variable products by including their variations // Handle variable products by including their variations
if ($product->is_type('variable')) { if ($product->is_type('variable')) {
$variations = $product->get_available_variations(); // Get variation IDs directly from the product
foreach ($variations as $variation_data) { $variation_ids = $product->get_children();
$variation = wc_get_product($variation_data['variation_id']); foreach ($variation_ids as $variation_id) {
$variation = wc_get_product($variation_id);
if ($variation && $variation->is_in_stock() && $variation->is_purchasable()) { if ($variation && $variation->is_in_stock() && $variation->is_purchasable()) {
$products[] = $variation; $products[] = $variation;
} }