<input type="hidden" class="total_cart" value="<?= count($data) ?>">
<input type="hidden" class="total_inp" value="<?= $this -> app -> total_keranjang() ?>">

<?php if($data) : ?>
    <?php if(isset($data['Digital'])) : ?>
        <?php foreach($data['Digital'] as $item) : ?>
            <article class="card">
                <div class="container d-flex justify-content-between align-items-start pt-4">
                    <div class="img" onclick="window.location.href='<?= slug($item -> id_produk, 'produk') ?>'">
                        <img src="<?= $this -> app -> get_img_produk($item -> id_produk) ?>" >
                    </div>
                    <div class="text">
                        <div class="d-flex justify-content-between align-items-start">
                            <p class="truncate-2 mb-1">
                                <?= $item -> nama_produk ?>
                            </p>
                            <div class="ps-2">
                                <div class="d-flex">                                        
                                    <button class="btn btn-light btn-sm border fa fa-pencil add-note" 
                                        data-trx="<?= $item -> id ?>"
                                        data-id="<?= $item -> id_produk ?>"
                                        data-varian="<?= $item -> varian ?>"
                                        data-sub="<?= $item -> varian_sub ?>"
                                    ></button>
                                    <button class="fa fa-trash ms-2 hps-cart btn btn-danger btn-sm py-2" data-id="<?= $item -> id ?>"></button>
                                </div>
                            </div>
                        </div>
                        <p class="text-danger mb-2">
                            <strong><?= format_uang($item -> harga) ?></strong>
                        </p>
                        <?php if($item -> nama_varian) : ?>
                            <div class="d-flex align-items-center mt-1">
                                <span class="badge text-dark border me-1 bg-light btn_change_varian" 
                                        data-trx="<?= $item -> id ?>"
                                        data-id="<?= $item -> id_produk ?>"
                                        data-varian="<?= $item -> varian ?>"
                                        data-sub="<?= $item -> varian_sub ?>"
                                >
                                    <?= $item -> nama_varian ?> 
                                    <i class="fa fa-chevron-down ms-1"></i>
                                </span>
                            </div>
                        <?php endif ?>
                       
                        <?php if($item -> catatan) : ?>
                            <div class="mt-2 text-truncate">
                                <small class="text-muted">
                                    Catatan: <?= $item -> catatan ?>
                                </small>
                            </div>
                        <?php endif ?>
                    </div>
                </div>
            </article>  
        <?php endforeach ?>                                     
    <?php endif ?>   

    <?php if(isset($data['Fisik'])) : ?>
        <?php foreach($data['Fisik'] as $item) : ?>
            <article class="card">
                <div class="container d-flex justify-content-between align-items-start pt-4">
                    <div class="img" onclick="window.location.href='<?= slug($item -> id_produk, 'produk') ?>'">
                        <img src="<?= $this -> app -> get_img_produk($item -> id_produk) ?>" >
                    </div>
                    <div class="text">
                        <p class="truncate-2 mb-1">
                            <?= $item -> nama_produk ?>
                        </p>
                        <p class="text-danger mb-2">
                            <strong><?= format_uang($item -> harga) ?></strong>
                        </p>
                        <?php if($item -> nama_varian) : ?>
                            <div class="d-flex align-items-center mt-1">
                                <span class="badge text-dark border me-1 bg-light btn_change_varian" 
                                        data-trx="<?= $item -> id ?>"
                                        data-id="<?= $item -> id_produk ?>"
                                        data-varian="<?= $item -> varian ?>"
                                        data-sub="<?= $item -> varian_sub ?>"
                                >
                                    <?= $item -> nama_varian ?> 
                                    <i class="fa fa-chevron-down ms-1"></i>
                                </span>
                            </div>
                        <?php endif ?>
                        <div class="qty-prd mt-3">
                            <div class="d-flex">
                                <button class="fa fa-minus qty-min" disabled></button>
                                <input type="text" class="qty-inp text-center" value="1">
                                <button class="fa fa-plus qty-plus"></button>
                                
                                <button class="fa fa-pencil add-note" 
                                    data-id="<?= $item -> id ?>"
                                    data-varian="<?= $item -> varian ?>"
                                    data-sub="<?= $item -> varian_sub ?>"
                                ></button>
                                <button class="fa fa-trash hps-cart ms-2 bg-danger text-white border-danger" data-id="<?= $item -> id ?>"></button>
                            </div>
                            <p class="mb-0 mt-2 text-danger">Tersisa: 10</p>
                        </div>
                        <div class="mt-2 text-truncate">
                            <small class="text-muted">
                                Catatan: Lorem ipsum, dolor sit amet consectetur adipisicing elit. Sed, ad.
                            </small>
                        </div>
                    </div>
                </div>
            </article>  
        <?php endforeach ?>                                     
    <?php endif ?>     
        
<?php else: ?>
    <article class="card">
        <div class="container pt-5 text-center">
            <a href="" class="d-block">
                <img src="<?= base_url('assets/img/empty-cart.png') ?>" class="w-px-120">
            </a>
            <p class="mb-0 mt-4">
                Keranjang Kosong
            </p>
        </div>
    </article>
<?php endif ?>