
    //--------------------------------------------    
    // Get the cart contents
    function getProducts() {
        // Read JSON from a file
        fetch("products.json")
        .then(function(resp)
            {
                return resp.json();
            }        
        )
        .then(
            function(jsonData) {
                let result = jsonData.products;

                gblProducts = result;

                //console.log(gblProducts);   

                getSettings();
            }
        )
        .catch(err=>{
            errorMessage(err.message);
        });
    }
    
    //--------------------------------------------
    // Display any error message to the console
    function errorMessage(err){
        console.error(err);
    }

    //-------------------------------
    function showProducts(){
        
        // merge the two arrays
        for(let i = 0, len = gblProducts.length; i < len; i++) {
            gblProducts[i]["currency"] = gblSetUp[0]["currency"];
            gblProducts[i]["paypalemail"] = gblSetUp[0]["paypalemail"];
        }

        $.each(gblProducts, function(index, obj) {

            $('.result').append (
                `<div class="col-sm-6 col-md-4 col-lg-3">

                    <h2>${obj.item_name}</h2>

                    <img src="${obj.item_image}"
                        class="img-fluid img-thumbnail border rounded"
                        style="max-width:100%; height:auto"
                        alt="${obj.item_title}"
                        width="150" />

                    <p class="cost">${obj.currency}${obj.mc_gross}</p>

                    <p><input id='${obj.id}' name="add" data-id='add' 
                    value="Add to Cart" class="btn btn-info" /></p>

                    <p>${obj.item_description}</p>
                </div>`
            );

        });

        // on evemt to activate button
        $('input').on('click', function (e) {
            //alert(e.target.id);
            //console.log(e.target.id);
            //console.log(e.target.name);
            //console.log(e);

            addtocart(e.target.id);
        });

    }

