# fluent-cart/1.3.19/app/Hooks/Handlers/ShortCodes/MiniCartShortcode.php

FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler, version 1.3.19. 57 lines.

- Page: https://pluginprobe.com/plugins/fluent-cart/1.3.19/code/app/Hooks/Handlers/ShortCodes/MiniCartShortcode.php
- Raw: https://pluginprobe.com/plugins/fluent-cart/1.3.19/raw/app/Hooks/Handlers/ShortCodes/MiniCartShortcode.php
- Modified: 2026-04-07T13:41:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-cart/1.3.19/code/app/Hooks/Handlers/ShortCodes/MiniCartShortcode.php#L10-L20`.

```php
<?php

namespace FluentCart\App\Hooks\Handlers\ShortCodes;

use FluentCart\Api\Resource\FrontendResource\CartResource;
use FluentCart\App\Helpers\CartHelper;
use FluentCart\App\Hooks\Cart\CartLoader;
use FluentCart\App\Hooks\Handlers\ShortCodes\ShortCode;
use FluentCart\App\Helpers\Helper;
use FluentCart\App\Models\Product;
use FluentCart\App\Models\ProductVariation;
use FluentCart\App\Modules\Templating\AssetLoader;
use FluentCart\App\Services\Renderer\CartDrawerRenderer;
use FluentCart\App\Services\Renderer\MiniCartRenderer;
use FluentCart\App\Services\Renderer\ProductRenderer;
use FluentCart\Framework\Support\Arr;

class MiniCartShortcode extends ShortCode
{
    protected static string $shortCodeName = 'fluent_cart_mini_cart';

    public function getStyles(): array
    {
        return [
            'public/cart-drawer/mini-cart.scss',
        ];
    }


    public function render(?array $viewData = null)
    {
        $data = $viewData ?? $this->shortCodeAttributes ?? [];

        (new CartLoader())->registerDependency();
        $itemCount = 0;
        $cartData = [];

        // Hide mini cart count during instant checkout to avoid confusion
        if (!CartHelper::doingInstantCheckout()) {
            $cart = CartHelper::getCart(null, false);
            if ($cart) {
                $cartData = $cart->cart_data ?? [];
                $itemCount = count($cartData);
            }
        }

        $miniCartRenderer = new MiniCartRenderer($cartData, [
            'item_count' => $itemCount
        ]);

        $data['is_shortcode'] = true;

        $miniCartRenderer->renderMiniCart($data);
    }
}


```
