JSFiddle - React, Tailwind, and code Playground

by AshThakur

HTML

<pre class="theCode" >function flatbike_get_product_detail() {
	$product_id = $_POST['product_id'];
	$args = array(
		'post_type' =&amp;gt; 'product',
		'p'  =&amp;gt; $product_id,
	);
	$query = new WP_Query( $args );
	if ($query-&amp;gt;have_posts()) :
        while ($query-&amp;gt;have_posts()) : $query-&amp;gt;the_post();
            wc_get_template_part( 'content', 'single-product' );
        endwhile;
     else :
        echo &quot;There were no posts found&quot;;
    endif;
    wp_reset_query();
	wp_die();
}
add_action('wp_ajax_get_product_detail', 'flatbike_get_product_detail');
add_action('wp_ajax_nopriv_get_product_detail', 'flatbike_get_product_detail');</pre>