'skipped', 'fields' => array(), 'message' => __( 'No title was generated.', 'ai-product-tools' ) ); } $product = function_exists( 'wc_get_product' ) ? wc_get_product( $product_id ) : false; if ( $product instanceof \WC_Product && 'empty_only' === $overwrite && '' !== trim( (string) $product->get_name() ) ) { return array( 'status' => 'skipped', 'fields' => array( array( 'field' => 'title', 'outcome' => 'skipped_not_empty' ) ), 'message' => __( 'The title is not empty.', 'ai-product-tools' ), ); } $row = array_merge( array( 'product_id' => $product_id, 'generated_value' => $title, 'apply_context' => wp_json_encode( array( 'update_slug' => false ) ), ), $this->blueprintRowFields( $context ) ); $outcome = $this->callApplier( 'title', $row ); if ( null !== $outcome['refusalMessage'] ) { return array( 'status' => 'skipped', 'fields' => array( array( 'field' => 'title', 'outcome' => 'failed' ) ), 'message' => $outcome['refusalMessage'], 'retryable' => $this->isRetryableRefusal( $outcome ), ); } if ( ! $outcome['ok'] ) { return array( 'status' => 'skipped', 'fields' => array( array( 'field' => 'title', 'outcome' => 'failed' ) ), 'message' => __( 'The write did not complete.', 'ai-product-tools' ) ); } return array( 'status' => 'applied', 'fields' => array( array( 'field' => 'title', 'outcome' => 'written' ) ), 'message' => __( 'Title applied.', 'ai-product-tools' ) ); } }