MOON
Server: Apache
System: Linux server1.studioinfinity.com.br 2.6.32-954.3.5.lve1.4.90.el6.x86_64 #1 SMP Tue Feb 21 12:26:30 UTC 2023 x86_64
User: artinside (517)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //home/artinside/public_html/sabbry/themes/web/cart.php
<?php $v->layout("_theme");
$v->insert("views/page-title", ["pageTitle" => $pageTitle, "breadcrumb" => $breadcrumb]);
?>
<section id="content">

    <div class="content-wrap">
        <?= $v->insert("views/process-steps", ["active" => $active])?>

        <div class="container clearfix">

            <div class="row clearfix topmargin-lg">
                <div class="col-md-12 col-lg-8 table-responsive">
                    <table class="table cart">
                        <thead>
                        <tr>
                            <th class="cart-product-thumbnail hidden-sm">&nbsp;</th>
                            <th class="cart-product-name">Produto</th>
                            <th class="cart-product-price ">Vl. Unitário</th>
                            <th class="cart-product-quantity">Quant.</th>
                            <th class="cart-product-subtotal">Vl. Total</th>
                            <th class="cart-product-remove">&nbsp;</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php
                        $cart = new \Anam\Phpcart\Cart(CARRINHO);
                        if ($cart->count() >= 1):
                            foreach ($cart->getItems() as $products):
                                ?>
                                <tr class="cart_item" id="cart_item_<?= $products->id ?>">

                                    <td class="cart-product-thumbnail hidden-sm">
                                        <a href="#"><img src="<?= image($products->cover, 80,80) ?>" title="<?= $products->name ?>"></a>
                                    </td>

                                    <td class="cart-product-name">
                                        <a href="#"><?= $products->name ?></a>
                                    </td>
                                    <td class="cart-product-price">
                                        <a href="#" class="black-text">R$ <?= preco_real($products->price) ?></a>
                                    </td>

                                    <td class="cart-product-quantity">
                                        <div class="quantity clearfix">
                                            <input type="button" value="-" class="minus" data-minus="minus" data-id="<?= $products->id ?>">
                                            <input type="text" name="quantity" class="qty" data-value="value" value="<?= $products->quantity ?>" id="j_qty_<?= $products->id ?>" data-id="<?= $products->id ?>"/>
                                            <input type="button" value="+" class="plus" data-plus="plus" data-id="<?= $products->id ?>">
                                        </div>
                                    </td>
                                    <td class="cart-product-subtotal">
                                        <a href="#"><b>R$ <span id="j_sub_<?= $products->id ?>"><?= preco_real($products->price*$products->quantity)?></span></b></a>
                                    </td>

                                    <td class="cart-product-remove">
                                        <a href="#" data-qty="0" data-id="<?= $products->id ?>" data-delete="delete" class="remove" title="Remover" data-id="<?= $products->id ?>"><i class="icon-trash2"></i></a>
                                    </td>
                                </tr>

                            <?php
                            endforeach;
                        else:
                            echo "<tr class='cart-item'><td colspan='4' style='text-align:center'>Não existem produtos disponíveis em seu carrinho</td></tr>";
                        endif;
                        ?>

                        <tr class="cart_item">
                            <td colspan="5">
                                <form class="j_calcula_frete" action="<?= url("/calcula-frete")?>">

                                <div class="row clearfix" style="margin-top: 20px">
                                        <div class="col-xs-6">
                                            <input type="text" class="sm-form-control mask-cep" id="cep" name="zipcode" placeholder="CEP" style="border-top-left-radius: 23px !important; border-bottom-left-radius: 23px !important;" value="<?= verifyAddress() ? verifyAddress() : ""?>"/>
                                        </div>

                                        <div class="col-x6-6">
                                            <button type="submit" href="#" class="button nomargin button-black" style="border-top-right-radius: 23px !important; border-bottom-right-radius: 23px !important;"> Frete</button>
                                        </div>
                                </div>
                                </form>
                            </td>
                            <td class="hidden-sm"></td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <div class="col-md-12 col-lg-4">
                <div class="bg-gray padding-30">
                    <h4>Totais</h4>
                    <div class="table-responsive">
                        <table class="table cart">
                            <tbody>
                            <tr class="cart_item">
                                <td class="cart-product-name" width="40%">
                                    <strong>Subtotal</strong>
                                </td>

                                <td class="cart-product-name">
                                    <span class="amount"><b>R$ <span id="j_sub_total"><?= preco_real($cart->getTotal()) ?></span></b></span>
                                </td>
                            </tr>
                            <tr class="cart_item">
                                <td class="cart-product-name" width="40%">
                                    <strong>Valor Frete</strong>
                                </td>

                                <td class="cart-product-name">
                                    <span class="amount" id="j_frete"><?= $frete->pac->price ? "R$ " . preco_real($frete->pac->price) : "Consulte " ?></span>
                                </td>
                            </tr>
                            <tr class="cart_item">
                                <td class="cart-product-name" width="40%">
                                    <strong>Total</strong>
                                </td>
                                <td class="cart-product-name">
                                    <span class="amount color lead"><strong>R$ <span id="j_total"><?= $frete->pac->price ? preco_real($cart->getTotal()+$frete->pac->price) : preco_real($cart->getTotal()) ?></span></strong></span>
                                </td>
                            </tr>
                            <tr class="cart_item">
                                <td colspan="2">
                                    <a <?= $cart->count() < 1 ? "href='#'" : 'href="' . url() . '/fechar/entrar"'; ?> class="button button-circle fright <?= $cart->count() < 1 ? "disabled-btn" : "" ?>">Finalizar Pedido</a>

                                </td>


                            </tr>
                            </tbody>

                        </table>
                    </div>
                </div>
                </div>
            </div>
        </div>
    </div>

</section><!-- #content end -->



<?php $v->start("scripts"); ?>
    <script type="text/javascript">
        $(function () {

            var ajaxResponseBaseTime = 3;

            function ajaxMessage(message, time) {
                var ajaxMessage = $(message);

                ajaxMessage.append("<div class='message_time'></div>");
                ajaxMessage.find(".message_time").animate({"width": "100%"}, time * 1000, function () {
                    $(this).parents(".message").fadeOut(200);
                });

                $(".ajax_response").append(ajaxMessage);
                ajaxMessage.effect("bounce");
            }
            // AJAX RESPONSE MONITOR

            function dataChange(element){
                var flashClass = "ajax_response";
                var flash = $("." + flashClass);
                var clicked = $(element);
                var dataset = clicked.data();
                dataset.quantity = $("#j_qty_"+dataset.id).val();

                var load = $(".ajax_load");
                load.fadeIn(200).css("display", "flex");
                $.post('<?= url("/main-cart");?>', dataset, function (response) {
//message
                    if (response.message) {

                        if(response.quantity == 0){
                            $("#cart_item_"+dataset.id).fadeOut("slow");
                            $("#j_sub_total").html(response.subtotal);
                            $("#j_total").html(response.total);
                            if(response.frete == 0){
                                $("#j_frete").html("Consulte");
                            }else{
                                $("#j_frete").html("R$ " + response.frete);
                            }
                            $(response.target).load(response.path);

                            if(response.count == 0){
                                window.location.reload();
                                load.fadeOut(200);
                            }
                            load.fadeOut(200);

                        }else{
                            $("#j_sub_"+dataset.id).html(response.value);
                            $("#j_qty_"+dataset.id).val(response.quantity);
                            $("#j_sub_total").html(response.subtotal);
                            if(response.frete == 0){
                                $("#j_frete").html("Consulte");
                            }else{
                                $("#j_frete").html("R$ " + response.frete);
                            }
                            $("#j_total").html(response.total);
                            $(response.target).load(response.path);
                            load.fadeOut(200);

                        }
                        ajaxMessage(response.message, ajaxResponseBaseTime);

                    } else {
                        flash.fadeOut(100);
                    }

                }, "json");

            }


            $("[data-plus]").click(function (e) {
                dataChange($(this));
            });
            $("[data-minus]").click(function (e) {
                dataChange($(this));
            });
            $("[data-delete]").click(function (e) {
                dataChange($(this));
            });
            $("[data-value]").on("blur", function (e) {
                dataChange($(this));
            });

        });



    </script>
<?php $v->end(); ?>