Wed Apr 18 2018
Copied to clipboard! Copy reply
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149

// Experience 1

var exp = 2



if (exp === 1)
{   
    // CATALOG STUFF
    var newdata = {
        "06": { dollar: '19', cents: '84', total: '119.94', currentpromo: 'parthenon_', newpromo: 'taxday' },
        "12": { dollar: '14', cents: '92', total: '179.04', currentpromo: 'parthenon_', newpromo: 'taxday' }
    }

     // LP STUFF
     var destination = {
        sitewide: 		'taxday24M749',
        rmsitewide: 	'taxday24M699',
        sale: 			'taxday24M699',
        earthday749: 	'earthday24m749',
        earthday699:	'earthday24m699',
        taxday749: 		'taxday24m749',
        taxday699:		'taxday24m699',
        aprilshowers11: 'aprilshowers24m11',
        aprilshowers749:'aprilshowers24m749',
        aprilshowers699:'aprilshowers24m699',
        earthday599:	'earthday24m599',
        taxday599:		'taxday24m599'   
    }
    
}
else
{
    // CATALOG STUFF
    var newdata = {
        "03": { dollar: '18', cents: '99', total: '56.97', currentpromo: 'parthenon', newpromo: 'mountfuji' },
        "06": { dollar: '16', cents: '99', total: '101.94', currentpromo: 'parthenon', newpromo: 'goldengate' },
        "12": { dollar: '12', cents: '99', total: '155.88', currentpromo: 'parthenon', newpromo: 'goldengate' },
        "24": { dollar: '8', cents: '49', total: '203.76', currentpromo: 'parthenon', newpromo: 'goldengate' }
    }

    // LP STUFF
    var destination = {
        sitewide: 		'taxday3M1899',
        rmsitewide: 	'taxday3M1799',
        sale: 			'taxday3M1799',
        earthday749: 	'earthday3m1899',
        earthday699:	'earthday3m1799',
        taxday749: 		'taxday3m1899',
        taxday699:		'taxday3m1799',
        aprilshowers11: 'aprilshowers3m27',
        aprilshowers749:'aprilshowers3m749',
        aprilshowers699:'aprilshowers3m1799',
        earthday599:	'earthday3M1699',
        taxday599:		'taxday3M1699'   
    }

    // Update best offer
    var bv = $('.oct_2016_best_value').html('Introductory Offer').detach()
    $('a[data-lvl="03"]').parents('.oct_2016_product_square_content').prepend(bv)

    // mobile
    var bvm = $('.labelcontain.topper').css({margin: '11px 0 -13px'}).html('Introductory Offer').detach()
    $('.mobile_msrp[data-lvl="03"]').parents('.monthly_mobilebottom.labelcontain').siblings('label.mobile_product_label').eq(3).before(bvm)
    $('.mobile_product_label').eq(0).css({'border-top-left-radius' : '5px'})
    $('.mobile_product_label').eq(0).css({'border-top-right-radius' : '5px'})
}



/************* CATALOG ****************/

if (!!window.location.href.match(/learn-/)) { 

} 

/***************** LP ****************/
else
{     

}




// Loop through cart buttons on desktop
$.each($('a.oct_2016_addtocart_square.js_oct_2016_addtocart'), function(i, e) {        
    var lvl = $(e).attr('data-lvl')          
    update_cart_buttons(lvl, $(e))
    update_html(lvl)    
})


// Update egift add to cart when radio changes 
$('#giftinglevelselect').on('change', function(e) {
    update_cart_buttons(e.target.value, $('#giftingproduct_cartlink'))
    update_html(e.target.value)
})   

// Update mobile add-to-cart when radio changes
$('.mobile_radio').on('change', function(e) {
    var lvl = e.target.dataset.lvl
    update_cart_buttons(lvl, $('.js_addtocart_mobile'))
    update_html(lvl)
})




/****************************************
 Update Cart Buttons
*********************************************/
function update_cart_buttons (lvl, $cartbtn) 
{
    if ( !(lvl in newdata)) return   

    var href = $cartbtn.attr('href')
    var re = new RegExp(newdata[lvl].currentpromo, "g");
    var newhref = href.replace(re, newdata[lvl].newpromo);    
}



function update_html (lvl)
{   
    if ( !(lvl in newdata)) return

    // Desktop
    $('span.oct_2016_big_price_square[data-lvl="'+lvl+'"] > div > p:first-of-type').html('.'+newdata[lvl].cents)
    var $cents = $('span.oct_2016_big_price_square[data-lvl="'+lvl+'"] > div').detach()
    $('span.oct_2016_big_price_square[data-lvl="'+lvl+'"]').text(newdata[lvl].dollar)
    $('span.oct_2016_big_price_square[data-lvl="'+lvl+'"]').append($cents)

    $('a.oct_2016_addtocart_square.js_oct_2016_addtocart[data-lvl="'+lvl+'"')
        .siblings('.oct_2016_msrp_square').find('strong').html(newdata[lvl].total)


    // Mobile 
    $('.mobile_price.js_oct_2016_price.no_month[data-lvl="'+lvl+'"]').html(newdata[lvl].dollar)
    $('.mobile_price.js_oct_2016_price.no_month[data-lvl="'+lvl+'"] + .productcents > p:first-of-type').html('.'+newdata[lvl].cents)
    $('.mobile_msrp[data-lvl="'+lvl+'"] + strong').html('$' + newdata[lvl].total)

    // Egift
    $('p#giftingproduct_saleprice').html('$' + newdata[lvl].dollar)
    $('.giftingproduct_buysection > div > p:first-of-type').html('.' + newdata[lvl].cents)
}