How can I fix this error? I started calling products through the Query, but I encountered this I think the problem is with open and closed PHP tags, but I can not fix it
Fatal error : Uncaught Error: Call to undefined method WC_Product_Simple::have_posts() in C:\xampp\htdocs\gptec\fa\wp-content\themes\gptec_wptheme\index.php:102 Stack trace: #0 C:\xampp\htdocs\gptec\fa\wp-includes\template-loader.php(74): include() #1 C:\xampp\htdocs\gptec\fa\wp-blog-header.php(19): require_once('C:\xampp\htdocs...') #2 C:\xampp\htdocs\gptec\fa\index.php(17): require('C:\xampp\htdocs...') #3 {main} thrown in C:\xampp\htdocs\gptec\fa\wp-content\themes\gptec_wptheme\index.php on line 102
My codes :
<div class="row">
<?php
$product=new WP_Query(
array(
'post_type'=>'product',
'post_per_page'=>6
)
);
?>
<?php
if ($product->have_posts())
{
while ($product->have_posts())
$product->the_post();
{ ?>
<div class="col-lg-3 p-2 m-2" >
<div class="card card-4 text-center cls">
<?php the_post_thumbnail(); ?>
<div class="clearfix"></div>
<span class="description-text pb-1 mb-1"><?php the_title()?></span>
<div class="clearfix"></div>
<a href="<?php the_permalink() ?>">
<button type="button" class="btn btn-outline-success slideright p-2 m-2">مشاهده محصول</button>
</a>
</div>
</div>
<?php }}?> <!--Card-->
</div>