Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/Integrations/OpenAi/DevHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Automattic\WooCommerce\ProductFeedForOpenAI\Integrations\OpenAi;

use Automattic\WooCommerce\Enums\ProductType;
use WP_Post;

if ( ! defined( 'ABSPATH' ) ) {
Expand Down Expand Up @@ -108,7 +109,11 @@ public function render_meta_box( WP_Post $post ) {
}

// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$product = wc_get_product( $post->ID );
$product = wc_get_product( $post->ID );
if ( $product->is_type( ProductType::VARIABLE ) ) {
$variations = $product->get_available_variations( 'object' );
$product = $variations[0];
}
$mapped_data = $this->mapper->map_product( $product );
$errors = $this->validator->validate_entry( $mapped_data, $product );

Expand Down Expand Up @@ -146,8 +151,13 @@ public function render_custom_product_column( $column, $post_id ) {
if ( self::COLUMN_ID !== $column ) {
return;
}
$product = wc_get_product( $post_id );
if ( $product->is_type( ProductType::VARIABLE ) ) {
// Get the first product variation to server the metabox.
$variations = $product->get_available_variations();
$product = $variations[0];
}

$product = wc_get_product( $post_id );
$mapped_data = $this->mapper->map_product( $product );
$errors = $this->validator->validate_entry( $mapped_data, $product );

Expand Down