title: How to get product & price when clicked on category using ajax in laravel?
body: <p>I want to get category-wise products when clicked on a specific category usnig ajax.  In this method I get product names &amp; images and successfully load them into view with ajax.</p>
  <pre><code>public function getProductByCategory($id) {
      $category = FoodItemCategory::find($id);
      $products = $category-&gt;foods;
  
      return response()-&gt;json($products);
  }
  </code></pre>
  <p>By this foreach loop, I get product price but I couldn't pass them into view as ajax response</p>
  <pre><code> foreach ($products as $product) {
          foreach ($product-&gt;price as $price) {
              $original_price = $price-&gt;original_price ;
  
          }
      }
  </code></pre>
  <p>here is my ajax success response</p>
  <pre><code>       success: function(response) {
                  $('.products').empty();
  
                  var href = &quot;{{ route('home') }}/&quot;;
  
                  $.each(response, function(key, value) {
                      var url = &quot;{{ route('shop.view', ':id') }}&quot;;
                      url = url.replace(':id', value.id);
  
                      $('.products').append(&quot;&lt;div class='col-md-6 col-lg-4'&gt;&quot; +
                          &quot;&lt;div class='item'&gt;&lt;div class='thumb'&gt;&quot; +
                          &quot;&lt;a href='&quot; + url +
                          &quot;' class='woocommerce-LoopProduct-link woocommerce-loop-product__link'&gt;&quot; +
                          &quot;&lt;img src='&quot; + href + &quot;images/&quot; + value.image +
                          &quot;' height='280px' width='320px'&gt;&lt;/a&gt;&lt;a href='#' data-id='&quot; + value.id +
                          &quot;' class='button product_type_simple add_to_cart_button ajax_add_to_cart'&gt;Add to cart&lt;/a&gt;&quot; +
                          &quot;&lt;/div&gt;&lt;div class='info'&gt;&lt;h5 class='woocommerce-loop-product__title'&gt;&lt;a href='&quot; +
                          url + &quot;'&gt;&quot; +
                          value.name + &quot;&lt;/a&gt;&lt;/h5&gt;&quot; +
                          &quot;&lt;span class='price'&gt;&lt;span class='woocommerce-Price-amount amount'&gt;&lt;span class='woocommerce-Price-currencySymbol'&gt; &lt;/span&gt;65&quot; +
                          &quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&quot;);
                  });
              }
  </code></pre>
  <p>Now, How can I load prices into this success function?</p>