@php $name = ''; $price = 0; $oldPrice = 0; $thumbnail = ''; $url = ''; $hasPromo = false; $category_name = ''; $downPercent = 0; $reviews = null; $product_id = $data->product_id; $style = isset($style) ? $style : 'grid'; $params = ['id' => $data->product_id]; $hasProduct = false; $hasOption = false; if($style == 'slides'){ $params = array_merge($params, [ '@with' => ['promoAvailable'], '@withReviews' => true, '@withCategory' => true ]); } $allowOrder = false; if($data->product_id && $product = $helper->getProduct($params)){ $name = $product->name; $price = $product->getFinalPrice(); $thumbnail = $product->getThumbnail(); $url = $product->getViewUrl(); $hasPromo = $product->hasPromo(); $downPercent = $product->getDownPercent(); $category_name = $product->category->name; $reviews = $product->getReviewData(); $oldPrice = $product->priceFormat('list'); $allowOrder = $ecommerce->allow_place_order && $product->price_status > 0 && $product->status > 0; $hasOption = $product->hasOption(); $hasProduct = true; $url = $product->getViewUrl(); }else{ $allowOrder = $data->allow_order; } $name = $data->name($name); $price = $data->price($price); $hasPromo = $data->has_promo($hasPromo); $oldPrice = $data->old_price($oldPrice); $down_percent = $data->down_percent($downPercent); $thumbnail = $data->thumbnail($thumbnail); $category_name = $data->category_name($category_name); $url = $data->url($url); if($data->price_format == 'k'){ $price = number_format($price/1000, 0, ',', '.') . 'k'; }else{ $price = $helper->getCurrencyFormat($price); } $show_info == isset($show_info) && $show_info ? true : false; @endphp
@if ($hasPromo && $downPercent)
-{{$downPercent}}%
@endif
@if (!$url) {{$name}} @else {{$name}} @endif @if (isset($show_info) && $show_info)
{{(!$hasOption && $hasProduct && $allowOrder)?'Đặt hàng':'Chi tiết'}}
@endif
@if (isset($show_info) && $show_info)
    @if ($category_name)
  • {{$category_name}}
  • @endif @if ($reviews&&$reviews->total) @php $rateAvgInt = $reviews->rating_int; $rateAvgFlloat = $reviews->rating_avg; // Danh gia trung binh @endphp {{-- lặp qua từ 0 den so sao --}} @for ($i = 0; $i < $rateAvgInt; $i++)
  • @endfor {{-- nếu rate_avg > rate_int thì cộng thêm nữa sao --}} @if ($rateAvgFlloat > $rateAvgInt)
  • @endif @endif

{{$name}}

Giá: {{$price}} @if ($hasPromo) {{$oldPrice}} @endif

@endif