Automattic\WooCommerce\Admin\API\AI
Product::update_product()
Update product with the content and images powered by AI.
Метод класса: Product{}
Хуков нет.
Возвращает
WP_REST_Response
.
Использование
$Product = new Product(); $Product->update_product( $request );
- $request(WP_REST_Request) (обязательный)
- Request object.
Код Product::update_product() Product::update product WC 9.7.1
public function update_product( WP_REST_Request $request ) { $product_information = $request['products_information'] ?? array(); if ( empty( $product_information ) ) { return rest_ensure_response( array( self::AI_CONTENT_GENERATED => true, ) ); } try { $product_updater = new UpdateProducts(); $product_updater->update_product_content( $product_information ); } catch ( \Exception $e ) { return rest_ensure_response( array( 'ai_content_generated' => false ) ); } $last_product_to_update = $request['last_product'] ?? false; if ( $last_product_to_update ) { flush_rewrite_rules(); } return rest_ensure_response( array( self::AI_CONTENT_GENERATED => true, ) ); }