<?php
    $hasDiscount = !is_null($product->discount_price) && $product->discount_price > 0;
    $basePrice   = $product->price ?: 0;
    $finalPrice  = $hasDiscount ? $product->discount_price : $basePrice;

    $imageUrl = $product->thumbnail_url
        ?? (!empty($product->thumbnail) ? asset('storage/'.$product->thumbnail) : asset('assets/img/default-product.jpg'));

    $brandName = 'SEF Card';
    $itemGroup = $product->product_code ?? $product->id;
    $description = Str::limit(strip_tags($product->short_description ?? $product->description ?? ''), 160);
?>


<meta property="og:type" content="product">
<meta property="og:title" content="<?php echo e($product->name); ?> | SEF NFC Digital Card">
<meta property="og:description" content="<?php echo e($description); ?>">
<meta property="og:url" content="<?php echo e(url()->current()); ?>">
<meta property="og:image" content="<?php echo e($imageUrl); ?>">

<meta property="product:brand" content="<?php echo e($brandName); ?>">
<meta property="product:availability" content="<?php echo e($product->stock > 0 ? 'in stock' : 'out of stock'); ?>">
<meta property="product:condition" content="new">
<meta property="product:price:amount" content="<?php echo e(number_format($finalPrice, 2, '.', '')); ?>">
<meta property="product:price:currency" content="BDT">
<meta property="product:retailer_item_id" content="<?php echo e($product->id); ?>">
<meta property="product:item_group_id" content="<?php echo e($itemGroup); ?>">


<?php
    $productJsonLd = [
        '@context'   => 'https://schema.org',
        '@type'      => 'Product',
        'productID'  => (string) $product->id,
        'name'       => $product->name,
        'description'=> $description,
        'url'        => url()->current(),
        'image'      => $imageUrl,
        'brand'      => $brandName,
        'offers'     => [[
            '@type'         => 'Offer',
            'price'         => number_format($finalPrice, 2, '.', ''),
            'priceCurrency' => 'BDT',
            'itemCondition' => 'https://schema.org/NewCondition',
            'availability'  => $product->stock > 0
                ? 'https://schema.org/InStock'
                : 'https://schema.org/OutOfStock',
        ]],
        'additionalProperty' => [[
            '@type'      => 'PropertyValue',
            'propertyID' => 'item_group_id',
            'value'      => $itemGroup,
        ]],
    ];
?>

<script type="application/ld+json">
<?php echo json_encode($productJsonLd, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>

</script>
<?php /**PATH /home/brainbo1/sefcard.com/resources/views/frontend/partials/product-seo.blade.php ENDPATH**/ ?>