$(document).ready(function () { /*Read querystring parameters. Show step 1 if all is valid.*/ var pfid = parseInt(getUrlParameter('pfid')) || 0; var pq = parseInt(getUrlParameter('pq')) || 0; var productInfo = lookupProduct(pfid, pq); var plansToIndex = [84218, 84217, 96124, 96123]; if (plansToIndex.indexOf(pfid) == -1) { $('head').append('') } $('#PlanNameText').text(productInfo['planOverview']); $('#projectsAATtextbox').text(productInfo['projectsBullet']); if (productInfo['includesUnlimitedUsers'] !== true) $('#UnlimitedUsersBullet').hide(); if (productInfo['includesImplementation'] !== true) $('#ImplementationBullet').hide(); if (productInfo['includesKAM'] !== true) $('#KAMBullet').hide(); if (productInfo['includesBranding'] !== true) $('#BrandingBullet').hide(); if (productInfo['includesSupport'] !== true) $('#SupportBullet').hide(); if (productInfo['includeMbgBadge'] !== true) $('#monybackguarantee').hide(); $('#PlanBullets').show(); if (productInfo['subPlanItem'] === '') { $('#MainProductSubName').hide(); } else { $('#MainProductSubName').text(productInfo['qty'] + ' ' + productInfo['subPlanItem']); } if (productInfo['planName'] === 'Plus Plan' && productInfo['qty'] === 2) { $('#PlanNameText').text('Start your CoConstruct Starter plan now'); } $('#PlanFrequencyId').val(pfid); $('#PlanId').val(productInfo['planId']); $('#DesiredQty').val(productInfo['qty']); $('#MainProductLabel').text(productInfo['planName']); $('#MainProductAmt').text(productInfo['amt'].toLocaleString('en-US', { style: 'currency', currency: 'USD' }) + ' ' + productInfo['frequency']); /*if (pfid == 96123 || pfid == 84217) { var discountAmt = productInfo['amt'] - productInfo['discount']; $('#DiscountAmt').text('-' + discountAmt.toLocaleString('en-US', { style: 'currency', currency: 'USD' })); $('#CartTotalAmt').text(productInfo['discount'].toLocaleString('en-US', { style: 'currency', currency: 'USD' })); $('#DiscountLine').show(); } else {*/ $('#CartTotalAmt').text(productInfo['amt'].toLocaleString('en-US', { style: 'currency', currency: 'USD' })); /*}*/ var pc = getUrlParameter('pc') || ''; if (pc !== '') { $('#promoCodeEntry').val(pc); } //33% Discount Code //Price /*if (productInfo['discount'] === 0 || pc != '') {*/ $('#DiscountDisclaimer').text('').css('display', 'none'); $('#MainProductDiscount').text(productInfo['amt'].toLocaleString('en-US', { style: 'currency', currency: 'USD', maximumSignificantDigits: 4 })); /*} else { $('#ProductAmtFull').text(productInfo['amt'].toLocaleString('en-US', { style: 'currency', currency: 'USD', maximumSignificantDigits: 4 })); $('#MainProductDiscount').text(productInfo['discount'].toLocaleString('en-US', { style: 'currency', currency: 'USD', maximumSignificantDigits: 4 })); // if this is a yearly discount offer, add this disclaimer text. if (pfid === 83535) { $('#DiscountDisclaimer').text('Discount off first 3 months'); } else if (pfid === 96124) { //Specialty Subcontractor $('#DiscountDisclaimer').text(productInfo['amt'].toLocaleString('en-US', { style: 'currency', currency: 'USD', maximumSignificantDigits: 4 }) + ' after 2 months'); } else if (pfid === 84217 || pfid === 96123) { $('#DiscountDisclaimer').text('Normally ' + productInfo['amt'].toLocaleString('en-US', { style: 'currency', currency: 'USD', maximumSignificantDigits: 4 }) + '/yr'); } }*/ //Frequency if (productInfo['frequency'] === '/year') { $('#ProductFrequency').text('/yr'); } else if (productInfo['frequency'] === '/month') { $('#ProductFrequency').text('/mo'); } //Plan Name if (productInfo['planName'] === 'CoConstruct Ramp') { $('#planNameTitle').text(productInfo['planName']); } else if (productInfo['planName'] === 'Standard Unlimited Plan') { $('#planNameTitle').text(productInfo['planName'].slice(0, -5)); } else { $('#planNameTitle').text('plus'); } //Promo Codes /*if (pfid == 83536 || pfid == 83535) { //Legacy Plus 5/10/15 $('#promoCodeEntry').val('33OFF'); } if (pfid == 96124) { //Standard Unlimited $('#promoCodeEntry').val('CCSTANDARD'); } if (pfid == 84218) { //Plus Unlimited $('#promoCodeEntry').val('CCPLUS'); }*/ var promo = $('#promoCodeEntry').val(); if (promo !== '') { fb_addPromoCode(); //apply the code to the cart if (promo == '33OFF') { $("#PromoCodeContainer").hide(); $("#DiscountLabel").text("Discount - First 3 months"); } else if (promo == 'CCSTANDARD' || promo == 'CCPLUS') { $("#PromoCodeContainer").hide(); $("#DiscountLabel").text("Discount - First 2 months"); } } /*// Hidden field for Standard Plan if (pfid === 96124) { //Specialty Subcontractor - show "implementation priority" field $('#StandardPriority').show(); }*/ }); function lookupProduct(pfid, pq) { var valid = false; var amt = 0; var discount = 0; var qty = pq; var planName = null; var subPlanItem = null; var frequency = null; var planOverview = null; var includesUnlimitedUsers = false; var projectsBullet = null; var includesImplementation = false; var includesKAM = false; var includesBranding = false; var includesSupport = false; var includeMbgBadge = true; var planId = null; switch (pfid) { case 86568: //Ramp qty = 1; amt = 99; planName = 'CoConstruct Ramp'; subPlanItem = 'Low introductory CoConstruct pricing for up to 3 months'; frequency = '/month'; planId = 35527; planOverview = 'Start your CoConstruct Ramp plan now'; projectsBullet = 'Unlimited projects during Ramp'; includesUnlimitedUsers = true; includeMbgBadge = false; valid = false; break; case 84218: //Unlim Monthly qty = 1; amt = 599; //full price discount = 399; planName = 'Unlimited Plan'; subPlanItem = ''; frequency = '/month'; planId = 33755; planOverview = 'Start your CoConstruct Unlimited plan now'; projectsBullet = 'Unlimited projects'; includesUnlimitedUsers = true; includesImplementation = true; includesKAM = false; includesBranding = false; includesSupport = true; valid = true; break; case 84217: //Unlim Yearly qty = 1; amt = 6469; //full price //discount = 4999; planName = 'Unlimited Plan'; subPlanItem = ''; frequency = '/year'; planId = 33755; planOverview = 'Start your CoConstruct Unlimited plan now'; projectsBullet = 'Unlimited projects'; includesUnlimitedUsers = true; includesImplementation = true; includesSupport = true; includesKAM = false; includesBranding = false; valid = true; break; case 83536: //Plus Monthly if (qty > 2) { qty = Math.min(Math.ceil(qty / 5) * 5, 70); amt = 199 + Math.ceil(qty / 5) * 100; //full price discount = getDiscount(amt, 0.33); } else { qty = 2; amt = 199; //full price } amt = Math.round(amt * 100) / 100; planName = 'Plus Plan'; subPlanItem = 'Active Projects At A Time'; frequency = '/month'; planId = 33233; if (qty === 2) { planOverview = 'Start your CoConstruct plan now'; projectsBullet = 'Up to 2 active projects at a time'; includesUnlimitedUsers = true; } else { planOverview = 'Start your CoConstruct Plus plan now'; projectsBullet = 'Up to ' + qty + ' active projects at a time'; includesUnlimitedUsers = true; includesImplementation = true; if (qty >= 15) { includesKAM = false; } includesBranding = true; } valid = true; break; case 83535: //Plus Yearly if (qty > 2) { qty = Math.min(Math.ceil(qty / 5) * 5, 70); amt = (199 + Math.ceil(qty / 5) * 100) * 0.9 * 12; //full price discount = getDiscount(amt, 0.0825); } else { qty = 2; amt = 199 * 0.9 * 12; //full price } amt = Math.round(amt * 100) / 100; planName = 'Plus Plan'; subPlanItem = 'Active Projects At A Time'; frequency = '/year'; planId = 33233; if (qty === 2) { planOverview = 'Start your CoConstruct plan now'; projectsBullet = 'Up to 2 active projects at a time'; includesUnlimitedUsers = true; } else { planOverview = 'Start your CoConstruct Plus plan now'; projectsBullet = 'Up to ' + qty + ' active projects at a time'; includesUnlimitedUsers = true; includesImplementation = true; if (qty >= 15) { includesKAM = false; } includesBranding = true; } valid = true; break; case 83538: //Standard Monthly if (qty > 10) { qty = Math.min(Math.ceil(qty / 5) * 5, 40); amt = 399 + 50 * (qty - 15) / 5; //full price discount = getDiscount(amt, 0.33); } else if (qty > 5) { qty = 10; amt = 299; //full price discount = getDiscount(amt, 0.33); } else { qty = 5; amt = 249; //full price discount = getDiscount(amt, 0.33); } amt = Math.round(amt * 100) / 100; planName = 'Standard Plan'; subPlanItem = 'Active Projects At A Time'; frequency = '/month'; planId = 33234; planOverview = 'Start your CoConstruct Standard plan now'; projectsBullet = 'Up to ' + qty + ' active projects at a time'; includesUnlimitedUsers = true; valid = true; break; case 83537: //Standard Yearly if (qty > 10) { qty = Math.min(Math.ceil(qty / 5) * 5, 40); amt = 12 * 0.9 * (399 + 50 * (qty - 15) / 5); //full price discount = getDiscount(amt, 0.0825); } else if (qty > 5) { qty = 10; amt = 299 * 12 * 0.9; //full price discount = getDiscount(amt, 0.0825); } else if (qty > 2) { qty = 5; amt = 249 * 12 * 0.9; //full price discount = getDiscount(amt, 0.0825); } else { qty = 5; amt = 2988 * 0.9; //full price discount = getDiscount(amt, 0.0825); } amt = Math.round(amt * 100) / 100; planName = 'Standard Plan'; subPlanItem = 'Active Projects At A Time'; frequency = '/year'; planId = 33234; planOverview = 'Start your CoConstruct Standard plan now'; projectsBullet = 'Up to ' + qty + ' active projects at a time'; includesUnlimitedUsers = true; valid = true; break; case 83527: //Core Monthly if (qty > 5) { qty = Math.min(Math.ceil(qty / 5) * 5, 40); amt = 199 + 50 * (qty - 5) / 5; //full price discount = getDiscount(amt, 0.33); } else { qty = 5; amt = 199; //full price discount = getDiscount(amt, 0.33); } amt = Math.round(amt * 100) / 100; planName = 'Core Plan'; subPlanItem = 'Active Projects At A Time'; frequency = '/month'; planId = 33226; planOverview = 'Start your CoConstruct Core plan now'; projectsBullet = 'Up to ' + qty + ' active projects at a time'; includesUnlimitedUsers = true; valid = true; break; case 83526: //Core Yearly if (qty > 2) { qty = Math.min(Math.ceil(qty / 5) * 5, 40); amt = 12 * 0.9 * (199 + 50 * (qty - 5) / 5); //full price discount = getDiscount(amt, 0.0825); } else { qty = 5; amt = 2388 * 0.9; //full price discount = getDiscount(amt, 0.0825); } amt = Math.round(amt * 100) / 100; planName = 'Core Plan'; subPlanItem = 'Active Projects At A Time'; frequency = '/year'; planId = 33226; planOverview = 'Start your CoConstruct Core plan now'; projectsBullet = 'Up to ' + qty + ' active projects at a time'; includesUnlimitedUsers = true; valid = true; break; case 83534: //Unlimited Projects Monthly qty = 3; amt = 299; amt = Math.round(amt * 100) / 100; //full price discount = getDiscount(amt, 0.33); planName = 'Unlimited Projects, First'; subPlanItem = 'Builder Users ($39/month each for additional)'; frequency = '/month'; planId = 33232; planOverview = 'Start your CoConstruct Unlimited plan now'; projectsBullet = 'Unlimited active projects at a time'; includesImplementation = true; includesBranding = true; valid = true; break; case 83533: //Unlimited Projects Yearly qty = 3; amt = 299 * 12 * 0.9; amt = Math.round(amt * 100) / 100; //full price discount = getDiscount(amt, 0.0825); planName = 'Unlimited Projects, First'; subPlanItem = 'Builder Users ($421.20/year each for additional)'; frequency = '/year'; planId = 33232; planOverview = 'Start your CoConstruct Unlimited plan now'; projectsBullet = 'Unlimited active projects at a time'; includesImplementation = true; includesBranding = true; valid = true; break; case 96124: //Standard Unlimited Monthly qty = 1; amt = 349; discount = 99; planName = 'Standard Unlimited Plan'; subPlanItem = ''; frequency = '/month'; planId = 42684; planOverview = 'Start your CoConstruct plan now'; projectsBullet = 'Unlimited projects'; includesUnlimitedUsers = true; includesImplementation = true; includesBranding = false; includesSupport = true; valid = true; break; case 96123: //Specialty Subcontractor Yearly qty = 1; amt = 3769; //discount = 2899; planName = 'Standard Unlimited Plan'; subPlanItem = ''; frequency = '/year'; planId = 42684; planOverview = 'Start your CoConstruct plan now'; projectsBullet = 'Unlimited projects'; includesUnlimitedUsers = true; includesImplementation = true; includesBranding = false; includesSupport = true; valid = true; break; } var response = { 'valid': valid, 'planName': planName, 'subPlanItem': subPlanItem, 'planId': planId, 'qty': qty, 'frequency': frequency, 'amt': amt, 'discount': discount, 'planOverview': planOverview, 'projectsBullet': projectsBullet, 'includesUnlimitedUsers': includesUnlimitedUsers, 'includesImplementation': includesImplementation, 'includesKAM': includesKAM, 'includesBranding': includesBranding, 'includesSupport': includesSupport, 'includeMbgBadge': includeMbgBadge }; return response; } function getDiscount(amt, percent) { return Math.round(amt - amt * percent); } function getUrlParameter(name) { name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); var results = regex.exec(location.search); return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); }