<?php
/**
 * Meta box markup for related product.
 *
 * @package SAAI
 */

defined( 'ABSPATH' ) || exit;

/**
 * Available variables:
 *
 * @var WP_Post $post The post object.
 */
$product_id = (int) get_post_meta( $post->ID, '_product_id', true );
$product    = wc_get_product( $product_id );
?>
<p>
    <select id="related-product" name="related_product" class="product-question-related-product" style="width: 100%;">
        <?php if ( ! empty( $product ) ) : ?>
            <option value="<?php echo absint( $product_id ); ?>"><?php echo esc_html( $product->get_name() ); ?></option>
        <?php endif; ?>
    </select>
</p>
<p class="description"><?php esc_html_e( 'Select the product this question is related to.', 'storeagent-ai-for-woocommerce' ); ?></p>
<?php wp_nonce_field( 'product-question-related-product', 'saai_nonce' ); ?>
