





function AddToCart(PID, QTY)
{
    var data = new FormData();
    data.append("request", "add_to_cart");
    data.append("quantity", QTY);
    data.append("pid", PID);
    $.ajax
    ({
        type: "POST",
        enctype: 'multipart/form-data',
        url: base_url + "controllers/add_to_cart.php",
        data: data,
        processData: false,
        contentType: false,
        cache: false,
        timeout: 600000,
        async: false,
        success: function (response) 
        {
            response    =   JSON.parse(response);
            if((response["error"] == false))
            {
                alert(response["message"]);
            }
            else
            {
                alert(response["error_msg"]);
            }
        },
        error: function (e) 
        {
            console.log("ERROR : ", e);
        }
    });
}
















function getProductInfo(URL)
{
    var data = new FormData();
    data.append("request", "get_product_info");
    data.append("url", URL);
    $.ajax
    ({
        type: "POST",
        enctype: 'multipart/form-data',
        url: "../controllers/product_shop.php",
        data: data,
        processData: false,
        contentType: false,
        cache: false,
        timeout: 600000,
        async: false,
        success: function (response) 
        {
            response    =   JSON.parse(response);
            if((response["html"]))
            {
                $("#ProductInfoWrapper").html('');
                $("#ProductInfoWrapper").html(response["html"]);
                $(".owl-carousel").owlCarousel
                ({
                    loop: true,
                    items: 1,
                    margin: 0,
                    stagePadding: 0,
                    autoplay: false
                });

                dotcount = 1;

                jQuery('.owl-dot').each(function () 
                {
                    jQuery(this).addClass('dotnumber' + dotcount);
                    jQuery(this).attr('data-info', dotcount);
                    dotcount = dotcount + 1;
                });

                slidecount = 1;

                jQuery('.owl-item').not('.cloned').each(function () 
                {
                    jQuery(this).addClass('slidenumber' + slidecount);
                    slidecount = slidecount + 1;
                });

                jQuery('.owl-dot').each(function () 
                {
                    grab = jQuery(this).data('info');
                    slidegrab = jQuery('.slidenumber' + grab + ' img').attr('src');
                    jQuery(this).css("background-image", "url(" + slidegrab + ")");
                });

                amount = $('.owl-dot').length;
                gotowidth = 100 / amount;
                jQuery('.owl-dot').css("height", gotowidth + "%");


                $("#ATCB").on("click", function()
                {
                    var PID     =   $("#pid").val();
                    var QTY     =   $("#orderquantity").val();
                    AddToCart(QTY);

                });
            }
        },
        error: function (e) 
        {
            console.log("ERROR : ", e);
        }
    });
}






$(document).ready(function()
{
    var URL     =   window.location.href;
    getProductInfo(URL);






});