jeudi 23 avril 2015

How does If statement works in Javascript

When a user makes a purchase, I want the site to look for this cookie on my Receipt page and if it's present, then the tag should have 'FIREuni' : 'TRUE'. If the cookie is not present, the tag should have 'FIREuni' : 'FALSE'. But I don't know weather I am using the if statements in the right way. I am fairly new to javascript this is probably my first code, can anybody help me telling where I am making a mistake?

function checkCookie() {
    var src=getCookie("src");
    if (src!="") {
        FIREuni:'TRUE'
        var TrackObject = {

            'CJ' : {

                'CID': '12346',
                'TYPE': '7865',
                'OID': 'ORDERNUMBER',
                'CURRENCY':'USD',
                'DISCOUNT': '',
                'COUPON': '',

                PRODUCTLIST : [

                    {   'ITEM': 'item.variant.sku',
                        'AMT': 'OTOTAL',
                        'QTY': 'OTY'
                    },
                    {   'ITEM': 'item.variant.sku',
                        'AMT': 'OTOTAL',
                        'QTY': 'OTY'
                    }
                ]
            }};

    }
    else
    {
        FIREuni:'FALSE'
        var TrackObject ={


            'UNI' : {

                'CID': '',
                'TYPE': '',
                'OID': '',
                'CURRENCY': '',
                'DISCOUNT': '',
                'COUPON': '',

                PRODUCTLIST : [

                    {   'ITEM': '',
                        'AMT': '',
                        'QTY': ''
                    }
                ]
            }
        };
    }
} 

Aucun commentaire:

Enregistrer un commentaire