@if(request()->ajax() && isset($products)) @if($products->isNotEmpty()) @php $cartContent = Cart::instance('cart')->content(); $cartProductIds = $cartContent->pluck('id')->filter()->unique()->toArray(); $parentProductInCart = false; if (!empty($cartProductIds)) { $cartProducts = \Botble\Ecommerce\Models\Product::query() ->whereIn('id', $cartProductIds) ->with('variationInfo.configurableProduct') ->get(); $parentProductInCart = $cartProducts->contains(function ($product) use ($parentProduct) { if ($product->id == $parentProduct->id) { return true; } if ($product->is_variation && $product->variationInfo && $product->variationInfo->configurable_product_id) { return $product->variationInfo->configurable_product_id == $parentProduct->id; } return false; }); } $currency = get_application_currency(); $currencyConfig = [ 'symbol' => $currency->symbol, 'is_prefix' => $currency->is_prefix_symbol, 'decimals' => $currency->decimals, 'thousands_separator' => $currency->thousands_separator, 'decimal_separator' => $currency->decimal_separator, ]; @endphp

{{ trans('plugins/ecommerce::products.up_sale.title') }}

{{ trans('plugins/ecommerce::products.up_sale.description') }}

@foreach ($products as $product) @php $productVariation = $product; $selectedAttrs = collect(); $productImage = $product->image; if ($product->variations->isNotEmpty()) { [$productImages, $productVariation, $selectedAttrs] = \Botble\Ecommerce\Facades\EcommerceHelper::getProductVariationInfo($product); if ($productImages && count($productImages) > 0) { $productImage = $productImages[0]; } } $originalPrice = $productVariation->price()->getPriceOriginal(); $salePrice = $productVariation->price()->getPrice(); $bundleDiscountPrice = $product->pivot->price ?? 0; $bundleDiscountType = $product->pivot->price_type ?? 'fixed'; $isPercentDiscount = $bundleDiscountType === 'percent' || $bundleDiscountType === \Botble\Ecommerce\Enums\UpSellPriceType::PERCENT; $bundlePrice = $salePrice; if ($bundleDiscountPrice > 0) { if ($isPercentDiscount) { $bundlePrice = $salePrice - ($salePrice * $bundleDiscountPrice / 100); } else { $bundlePrice = max(0, $salePrice - $bundleDiscountPrice); } } $hasDiscount = $bundlePrice < $salePrice || $salePrice < $originalPrice; $showOriginalPrice = $bundlePrice < $salePrice ? $salePrice : ($salePrice < $originalPrice ? $originalPrice : null); $displayPrice = $bundlePrice; if (!$currency->is_default && $currency->exchange_rate > 0) { $displayPrice = $bundlePrice * $currency->exchange_rate; } $cartId = $productVariation->is_variation ? $productVariation->id : $product->id; @endphp
$product->variations->isNotEmpty(), 'is-locked' => ! $parentProductInCart, ]) data-product-id="{{ $product->id }}" data-upsale-bundle-item @unless($parentProductInCart) title="{{ trans('plugins/ecommerce::products.up_sale.unlock_discount', ['product' => $parentProduct->name]) }}" @endunless >
@unless($parentProductInCart) @endunless
{{ Str::limit($product->name, 50) }}
@if($showOriginalPrice) {{ format_price($showOriginalPrice) }} @endif {{ format_price($bundlePrice) }} @if($bundleDiscountPrice > 0) {{-- Badge sits inline next to the sale price (was absolute on the thumb and clipped product images). --}} @if($isPercentDiscount) -{{ (int) $bundleDiscountPrice }}% @else -{{ format_price($bundleDiscountPrice) }} @endif @endif
@if($product->variations->isNotEmpty())
{!! render_product_swatches($product, [ 'selected' => $selectedAttrs, 'view' => 'plugins/ecommerce::themes.attributes.swatches-renderer-upsale', ]) !!}
@endif
@endforeach
@if(EcommerceHelper::isCartEnabled()) @endif
@endif @else
@for ($i = 0; $i < 2; $i++)
@endfor
@endif