1var cartSummary; 2 3var backorders = []; 4 5let autopayselected = '', 6 discountapplied = 0, 7 skusincart = [], 8 removeAutoship = false, 9 hasAutoship = false; 10 11const discountTiers = { 12 1: { 13 "price": 0, 14 "showprice": 0.00, 15 "discount": 0, 16 "freeship": false, 17 "test": "Buy any 2 supplements | get FREE shipping* + 5% off!" 18 }, 19 2: { 20 "price": 72.20, 21 "promptprice": 64.40, 22 "showprice": 34.00, 23 "discount": 5, 24 "freeship": false, 25 "text": "Add 1 more supplement | get FREE shipping* + 5% off!" 26 }, 27 3: { 28 "price": 134, 29 "showprice": 73.50, 30 "promptprice": 125.00, 31 "discount": 12, 32 "freeship": true, 33 "text": "Add this item to your order and save 12%!" 34 }, 35 4: { 36 "price": 302, 37 "showprice": 205.00, 38 "promptprice": 302.00, 39 "discount": 15, 40 "hidetext": 155, 41 "freeship": true, 42 "text": "Add this item to your order and save 15%!" 43 } 44}; 45 46const bonusOptions = [ 47 'NXT-18', 48 'NXT-15', 49 // 'ATX-BANE', 50 'ATX-AAMUSCLE-B', 51 'ATX-IRON-B', 52 'ATX-IRONC', 53 'ATX-DRAGON', 54 'ATX-ULT-ABS', 55 'ATX-ARMOR-ABS', 56 'ATX-XT2ABS', 57 'ATX-MASS', 58 'ATX-MAX-FX' 59]; 60 61const programSkus = [ 62 'ATX-DP2', 63 'ATX-DP2-120', 64 'AX2-DP2', 65 'ATX-2KX', 66 'AX2-2KX', 67 'ATXX-DIG', 68 'ATX-XERO', 69 'ATX-SHRED', 70 'ATX-SIZE', 71 'ATX-BREAKOUT', 72 'ATX-SHRED-120', 73 'ATX-SIZE-120', 74 'ATX-BREAKOUT-120', 75 'ATX-BEAXST', 76 'ATX-B-PPL', 77 'ATX-MONSTER', 78 'ATX-CORE4', 79 'ATX-XERO2', 80 'ATX-IRON', 81 'ATX-JACKED', 82 'ATX-ELASTX', 83 'ATX-AAMUSCLE', 84 'ATX-ULT-ARM', 85 'ATX-AX1-AX2', 86 'ATX-XERO-XERO2', 87 'ATX-HOMECOMING', 88 'ATX-INFERNO', 89 'ATX-BEAXST-BEAXST2' 90]; 91 92// Grab embeded rx product data json and order the sku's from longest to shortest for 93// later comparisons. 94// 95// TODO: Update to add support for any other product types. Programs / equipment / etc. 96// var rxProductsJson = JSON.parse(jQuery('#rx_products_json').html()); 97// var rxProductSkus = Object.keys(rxProductsJson).sort(function(a, b) { 98// return b.length - a.length; 99// }); 100 101// // Base path for supplement product view pages. 102// const supplementLinkBase = 'athleanrx'; 103 104function axupdateSnapshotItems(cart) { 105 // Store currently focused element info before updating 106 const $focusedElement = $(document.activeElement); 107 let focusInfo = null; 108 109 if ($focusedElement.length && $focusedElement.closest('.ax-cart').length) { 110 // Store focus info based on element type 111 if ($focusedElement.hasClass('qtyminus') || $focusedElement.hasClass('qtyplus')) { 112 const $cartItem = $focusedElement.closest('.ax-cart-item'); 113 const itemId = $cartItem.attr('class').match(/([A-Z0-9-]+)\s/)?.[1]; 114 focusInfo = { 115 type: $focusedElement.hasClass('qtyminus') ? 'decrease' : 'increase', 116 itemId: itemId 117 }; 118 } else if ($focusedElement.hasClass('ax-item-remove-btn')) { 119 focusInfo = { 120 type: 'remove', 121 itemId: $focusedElement.data('itemid') 122 }; 123 } 124 } 125 126 jQuery('.js-snapshot-item-list').siblings('.js-snapshot-item').remove(); 127 axupdatelogic(cart); 128 jQuery(document).trigger('items.ax.cart', cart); 129 130 // Restore focus after update 131 if (focusInfo) { 132 setTimeout(function() { 133 let $newFocus; 134 if (focusInfo.type === 'decrease') { 135 $newFocus = $(`.ax-cart-item.${focusInfo.itemId} .qtyminus`); 136 } else if (focusInfo.type === 'increase') { 137 $newFocus = $(`.ax-cart-item.${focusInfo.itemId} .qtyplus`); 138 } else if (focusInfo.type === 'remove') { 139 $newFocus = $(`.ax-item-remove-btn[data-itemid="${focusInfo.itemId}"]`); 140 } 141 142 if ($newFocus && $newFocus.length) { 143 $newFocus.focus(); 144 } 145 }, 50); 146 } 147} 148 149function cartdisplay(cart) { 150 // USD currency formatter. 151 var currency = new Intl.NumberFormat('en-US', { 152 style: 'currency', 153 currency: 'USD', 154 }); 155 156 var showFreeShipping = false; 157 if (jQuery('#viewcart').attr('data-sales') == "TRUE") { 158 //showFreeShipping = true; 159 } 160 161 var powerUp; 162 var powerUpText; 163 164 if (cart.items.length > 0) { 165 cart.checkout.custom_field7 = ''; 166 var msrp = 0; 167 var salesprice = 0; 168 var totalitems = 0; 169 var tempmsrp = 0; 170 var discounts = 0; 171 var recommended = ""; 172 var splitSku; 173 var backorderText; 174 var powerUpDate = "1/01/2000"; 175 var hassupplements = false; 176 let supplementtotal = 0, 177 discountsupptotal = 0; 178 let autoship = false, 179 suppsincart = [], 180 autoshipArray = [], 181 normalitem = []; 182 183 skusincart = []; 184 185 var snapshotItems = ''; 186 187 188 // YELLOW BANNER START 189 // snapshotItems += ` 190 // <style>
191 // .cart-banner { 192 // background: #ffd206; 193 // background: -webkit-gradient(linear, left top, left bottom, from(rgba(235, 200, 8, 1)), to(rgba(255, 220, 29, 1))); 194 // background: -o-linear-gradient(top, rgba(235, 200, 8, 1) 0%, rgba(255, 220, 29, 1) 100%); 195 // background: linear-gradient(to bottom, rgba(235, 200, 8, 1) 0%, rgba(255, 220, 29, 1) 100%); 196 // color: #2a2a2a; 197 // font-size: 16px; 198 // text-align: center; 199 // border-bottom: 1px solid #cacaca !important; 200 // font-weight: 700 !important; 201 // font-size: 15px !important; 202 // box-shadow: 4px 1px .35rem .1rem rgba(0,0,0,.1); 203 // } 204 // .cart-banner a { 205 // padding: 0.5rem 0.75rem !important; 206 // text-decoration: none; 207 // color: #2a2a2a; 208 // display: block; 209 // width: 100%; 210 // height: 100%; 211 // text-align: center; 212 // max-width: 375px; 213 // margin: auto; 214 // outline: 0; 215 // font-size: 15px; 216 // line-height: 120%; 217 // } 218 // </style> 219 // <div class="cart-banner">
220 // <a href="https://athleanx.com/athleanrx" target="bonus"> 221 // MEMORIAL DAY SALE!<br/>SAVE UP TO 35% OFF ON SUPPLEMENTS! 222 // </a> 223 // </div> 224 // `; 225 // YELLOW BANNER END 226 227 snapshotItems += '<div id="axcart">'; 228 229 snapshotItems += '<ul class="ax-cart-item-list">'; 230 231 if (document.getElementById("recommended-cart-div") !== null) { 232 recommended = jQuery('#recommended-cart-div').html(); 233 } 234 235 let backorders = []; 236 237 for (var i = 0; i < cart.items.length; i++) { 238 autoship = false; 239 backorderText = ""; 240 if (cart.items[i].item_id.startsWith("RX") && jQuery('#viewcart').attr('data-sales') == "TRUE") { 241 showFreeShipping = true; 242 } 243 244 //The following lines are checking for backorders 245 splitSku = ((cart.items[i].item_id).split("-")); 246 247 if (cart.items[i].item_id.endsWith("-R") && cart.items[i].auto_order_schedule != undefined && cart.items[i].auto_order_schedule != "Every 28 Days") { 248 cart.items[i].auto_order_schedule = "Every 28 Days"; 249 UC.postCart(cart, function (updatedCart, errors) { 250 if (errors.length > 0) { 251 if (errors[0].includes("backorder")) { 252 axupdateSnapshotItems(updatedCart); 253 } else { 254 jQuery('.' + itemid).removeClass("disabledsupplement"); 255 console.error('[AX CART]', errors); 256 AX.modal.show('#axModal', { 257 content: '<div class="ax-modal-error">' + errors[0] + '</div>' 258 }); 259 axupdateSnapshotItems(updatedCart); 260 } 261 } else { 262 axupdateSnapshotItems(updatedCart); 263 } 264 }); 265 return false; 266 } 267 268 if (cart.items[i].item_id.startsWith("RX") || cart.items[i].item_id.startsWith("PRX")) { 269 //if the item is a supplement 270 if (cart.items[i].item_id.startsWith("RX-") || cart.items[i].item_id.startsWith("RXPU")) { 271 if (cart.checkout.custom_field7 != '' && backorders[cart.items[i].item_id]) { 272 if (Date.parse(powerUpDate) < Date.parse(backorders[cart.items[i].item_id]["*"])) { 273 powerUpDate = backorders[cart.items[i].item_id]["*"]; 274 } 275 if (Date.parse(cart.checkout.custom_field7) < Date.parse(backorders[cart.items[i].item_id]["*"])) { 276 cart.checkout.custom_field7 = backorders[cart.items[i].item_id]["*"]; 277 } 278 } else { 279 if (backorders[cart.items[i].item_id]) { 280 powerUpDate = backorders[cart.items[i].item_id]["*"]; 281 cart.checkout.custom_field7 = backorders[cart.items[i].item_id]["*"]; 282 } 283 } 284 } 285 if (cart.items[i].item_id.startsWith("RXB") || cart.items[i].item_id.startsWith("RX3MO") || cart.items[i].item_id.startsWith("RXX")) { 286 if (backorders[splitSku[0]] && backorders[splitSku[0]]["*"]) { 287 if (cart.checkout.custom_field7 != '' && backorders[splitSku[0]]) { 288 if (Date.parse(cart.checkout.custom_field7) < Date.parse(backorders[splitSku[0]]["*"])) { 289 cart.checkout.custom_field7 = backorders[splitSku[0]]["*"]; 290 } 291 } else { 292 cart.checkout.custom_field7 = backorders[splitSku[0]]["*"]; 293 } 294 } 295 for (var s = 1; s <= 4; s++) { 296 if (backorders[splitSku[0]] && backorders[splitSku[0]][splitSku[s]]) { 297 if (cart.checkout.custom_field7 != '') { 298 if (Date.parse(cart.checkout.custom_field7) < Date.parse(backorders[splitSku[0]][splitSku[s]])) { 299 cart.checkout.custom_field7 = backorders[splitSku[0]][splitSku[s]]; 300 } 301 } else { 302 cart.checkout.custom_field7 = backorders[splitSku[0]][splitSku[s]]; 303 } 304 } 305 } 306 } else if (backorders[splitSku[0]] && backorders[splitSku[0]][cart.items[i].item_id]) { 307 if (cart.checkout.custom_field7 != '' && backorders[splitSku[0]][cart.items[i].item_id]) { 308 if (Date.parse(cart.checkout.custom_field7) < Date.parse(backorders[splitSku[0]][cart.items[i].item_id])) { 309 cart.checkout.custom_field7 = backorders[splitSku[0]][cart.items[i].item_id]; 310 } 311 } else { 312 cart.checkout.custom_field7 = backorders[splitSku[0]][cart.items[i].item_id]; 313 } 314 } 315 if (cart.checkout.custom_field7 != '') { 316 317 if (backorders[splitSku[0]] && backorders[splitSku[0]][cart.items[i].item_id]) { 318 backorderText = "<div class='ax-cart-backorder-label'>Backordered: Expected - " + backorders[splitSku[0]][cart.items[i].item_id] + "</div>"; 319 } else if (backorders[splitSku[0]] && backorders[splitSku[0]]["*"]) { 320 backorderText = "<div class='ax-cart-backorder-label'>Backordered: Expected - " + backorders[splitSku[0]]["*"] + "</div>"; 321 } else if (backorders[cart.items[i].item_id]) { 322 backorderText = "<div class='ax-cart-backorder-label'>Backordered: Expected - " + backorders[cart.items[i].item_id]["*"] + "</div>"; 323 if (cart.items[i].item_id.startsWith("RXPU")) {
324 powerUpText = "<div class='ax-cart-backorder-label'>Backordered: Expected - " + powerUpDate + "</div>"; 325 powerUp = true; 326 } 327 } else { 328 if (backorders[splitSku[0]]) { 329 for (var z = 1; z < 4; z++) { 330 if (backorders[splitSku[0]][splitSku[z]]) { 331 backorderText = "<div class='ax-cart-backorder-label'>Backordered: Expected - " + backorders[splitSku[0]][splitSku[z]] + "</div>"; 332 } 333 } 334 } else { 335 backorderText = ""; 336 } 337 } 338 339 UC.postCart(cart, function (updatedCart, errors) { 340 if (errors.length > 0) { 341 console.error('[AX CART]', errors); 342 } 343 }); 344 } 345 //Calculate the total for supplements 346 supplementtotal = (supplementtotal + (cart.items[i].unit_cost.localized * cart.items[i].quantity)); 347 discountsupptotal = (discountsupptotal + cart.items[i].unit_cost_with_discount.localized); 348 suppsincart.push(cart.items[i].item_id); 349 } 350 skusincart.push(cart.items[i].item_id); 351 352 totalitems = totalitems + cart.items[i].quantity; 353 354 salesprice = cart.items[i].total_cost.localized; 355 356 if (cart.items[i].manufacturer_suggested_retail_price) { 357 tempmsrp = cart.items[i].manufacturer_suggested_retail_price.localized; 358 msrp = msrp + (tempmsrp * cart.items[i].quantity); 359 } else { 360 msrp = msrp + salesprice; 361 } 362 discounts = discounts + cart.items[i].discount.localized; 363 if (cart.items[i].item_id.split("-")[0] == 'RXPU') { 364 isPowerup = true; 365 } else { 366 isPowerup = false; 367 } 368 if (cart.items[i].auto_order_schedule != undefined && cart.items[i].auto_order_schedule != 'None' && cart.items[i].auto_order_schedule != 'none' && cart.items[i].auto_order_schedule != '') { 369 autoshipArray.push(cart.items[i]); 370 } else { 371 normalitem.push(cart.items[i]); 372 } 373 } 374 375 autoshipArray.sort(function sortFunction(a, b) { 376 if (a["item_id"] === b["item_id"]) { 377 return 0; 378 } 379 else { 380 return (a["item_id"] < b["item_id"]) ? -1 : 1; 381 } 382 }); 383 normalitem.sort(function sortFunction(a, b) { 384 if (a["item_id"] === b["item_id"]) { 385 return 0; 386 } 387 else { 388 return (a["item_id"] < b["item_id"]) ? -1 : 1; 389 } 390 }); 391 if (autoshipArray.length > 0) { 392 snapshotItems += '<section class="autoshipsection ax-cart-item item js-snapshot-item" style="display:block;" aria-labelledby="autoship-heading"><h3 id="autoship-heading" class="ax-cart__header">Autoship Items</h3>'; 393 394 autoshipArray.map(function (item) { 395 isDisabled = item.maximum_quantity === 1; 396 isPowerup = item.item_id.split('-')[0] == 'RXPU'; 397 snapshotItems += makeitemhtml(item, isDisabled, isPowerup, backorderText); 398 }); 399 snapshotItems += '</section>'; 400 } 401 if (normalitem.length > 0) { 402 if (autoshipArray.length > 0) { 403 snapshotItems += '<section aria-labelledby="regular-heading"><h3 id="regular-heading" class="ax-cart-item item js-snapshot-item ax-cart__header">Regular Items</h3>'; 404 } 405 normalitem.map(function (item) { 406 isDisabled = item.maximum_quantity === 1; 407 isPowerup = item.item_id.split('-')[0] == 'RXPU'; 408 snapshotItems += makeitemhtml(item, isDisabled, isPowerup, backorderText); 409 }); 410 if (autoshipArray.length > 0) { 411 snapshotItems += '</section>'; // Close regular items section 412 } 413 } 414 415 416 snapshotItems += '</ul>'; // END OF CART ITEMS LIST 417 418 // CHECK FOR MONTHLY SKUS FOR PROMOS 419 calculatediscount(supplementtotal, discountsupptotal, skusincart, suppsincart, cart.summary.subtotal.localized, cart.summary.subtotal_with_discount.localized); 420 421 // RECOMMENDED ITEMS / POWERUPS 422 snapshotItems += '<ul class="recommended-wrapper"><li id="recommended-cart-div">' + recommended + '</li></ul>'; 423 424 snapshotItems += '</div>'; // END OF #AXCART DIV 425 426 var msrpSavings = parseFloat(parseFloat(msrp) - parseFloat(cart.summary.subtotal.localized)).toFixed(2); 427 var itemCount = totalitems + ' Item' + (totalitems > 1 || totalitems === 0 ? 's' : ''); 428 429 // CART FOOTER 430 snapshotItems += '<ul class="ax-cart-footer">' + 431 '<li class="clearfix total totalsavings">' + 432 433 // FREE SHIPPING ALERT 434 '<div class="js-snapshot-free-shipping" style="' + (showFreeShipping == true ? '' : 'display: none !important;') + '">'; 435 436 var itemTotal = cart.summary.subtotal.localized; 437 if (itemTotal >= 75) { 438 snapshotItems += '<p style="color: #000;">Your order qualifies for <strong>FREE</strong> UPS Ground shipping!</p>' + 439 '<small>* International orders receive discounted shipping.</small>'; 440 } else { 441 var remaining = 75 - itemTotal; 442 snapshotItems += '<div style="padding-top: 2px;">Only <strong>' + currency.format(remaining) + '</strong> until your order qualifies for FREE shipping!</div>'; 443 } 444 445 snapshotItems += '</div>'; 446 447 snapshotItems += discountProgressHtml(cart); 448 449 snapshotItems += 450 '<div class="savesection" id="cartListPriceLineItem"><div class="item-total">List Price <small class="js-snapshot-item-count" style="font-size:13px;position:relative;top: -1px;letter-spacing: -.125pt;color: #2a2a2a;">(' + itemCount + ')</small></div>' + 451 '<div class="item-price js-snapshot-total js-snapshot-savings"><s>' + currency.format(msrp) + '</s></div></div>'; 452 453 // DISCOUNTS (USING THE DERIVED ORIGINAL PRICE) 454 var originalPriceDiscount = 0; 455 originalPriceDiscount = parseFloat(parseFloat(cart.summary.subtotal_discount.value) + parseFloat(msrpSavings)); 456 snapshotItems += ` 457 <div class="savesection" style="${(originalPriceDiscount <= 0 ? 'dis
457play: none;' : '')}"> 458 <div class="item-total">Discounts</div> 459 <div class="item-price js-snapshot-total js-snapshot-savings"> 460 <strong style="color: #c40000;">-${currency.format(originalPriceDiscount)}</strong> 461 </div> 462 </div> 463 `; 464 465 // FREE SHIPPING 466 if (AX.discounts.hasFreeShipping(cart)) { 467 snapshotItems += ` 468 <div class="savesection" id="cartShippingLineItem"> 469 <div class="item-total">Shipping & Handling</div> 470 <div class="item-price js-snapshot-total js-snapshot-savings"> 471 <strong>FREE</strong> 472 </div> 473 </div> 474 `; 475 } 476 477 // TOTAL 478 snapshotItems += '</li>' + 479 '<li class="total finaltotal">' + 480 '<div class="item-total">Subtotal</div>' + 481 '<div id="cart-total" class="item-price js-snapshot-total">' + currency.format(cart.summary.subtotal_with_discount.localized) + '</div>' + 482 '</li>' + 483 '</ul>'; 484 485 jQuery('.js-snapshot-items').html(snapshotItems); 486 487 // Insert back order alert if any items are on back order. 488 if (cart.checkout.custom_field7) { 489 var backorderAlert = '<div class="backordered">One or more items in your cart are currently on backorder. Your order will ship when all items are available. The estimated shipping date is <strong>' + cart.checkout.custom_field7 + '</strong>.</div>'; 490 jQuery(backorderAlert).insertBefore('.ax-cart-item-list'); 491 } 492 493 jQuery('.js-cart-snapshot-options').html( 494 '<div class="ax-checkout-btn-wrapper">' + 495 (typeof document.documentMode !== 'undefined' 496 // Send IE users to single page checkout. 497 ? '<a href="https://secure.ultracart.com/cgi-bin/UCEditor?merchantId=' + cart.merchant_id + '" class="ax-btn btn-large btn-fluid btn-red cart-snapshot-button cart-snapshot-button-checkout js-view-checkout" role="button" aria-describedby="cart-total">Proceed to Checkout</a>' 498 // Send all other users to the updated checkout. 499 : '<a href="/checkout" class="ax-btn btn-large btn-fluid btn-red cart-snapshot-button cart-snapshot-button-checkout" role="button" aria-describedby="cart-total">Proceed to Checkout</a>') + 500 '</div>' + 501 '<div class="js-view-cart-snapshot" style="margin-top: 7px">' + 502 '<button class="ax-btn btn-black btn-large btn-fluid cart-snapshot-button cart-snapshot-button-continue close-cart-snapshot js-view-cart-snapshot">Continue Shopping</button>' + 503 '</div>' 504 ); 505
506 jQuery('.cart-snapshot-header').addClass('noselect').html('<img loading="lazy" alt="Shopping cart icon" class="ax-cart-header-icon" src="/images/view-cart.png" height="32" width="32"><h3>My Cart</h3><button class="close js-view-cart-snapshot close-cart-snapshot" aria-label="Close cart"></button>'); 507 508 jQuery('#cartItems').html(totalitems); 509 510 jQuery('#cartItems').fadeIn(200); 511 512 if (!(jQuery(".close.js-view-cart-snapshot").hasClass("close-cart-snapshot"))) { 513 jQuery(".close.js-view-cart-snapshot").addClass("close-cart-snapshot"); 514 } 515 516 promoPercent(supplementtotal, cart.summary.subtotal.localized); 517 } else { 518 519 var emptyCartPlaceholder = 520 '<div class="ax-cart-empty">' + 521 '<img loading="lazy" src="/images/branding/logo.png" alt="ATHLEAN-X" title="ATHLEAN-X" width="112" height="51" />' + 522 '<h3>YOUR CART IS EMPTY</h3>' + 523 '<div class="divider"></div>' + 524 '<nav aria-label="Shop by category">' + 525 '<ul class="ax-shopping-categories">' + 526 '<li><a href="/the-training?sort=all" title="Shop Programs">Shop Programs</a></li>' + 527 '<li><a href="/athleanrx" title="Shop Supplements">Shop Supplements</a></li>' + 528 '<li><a href="/elast-x-resistance-bands" title="Shop Elast-X Bands">Shop Elast-X Bands</a></li>' + 529 '<li><a href="/fitness-apparel" title="Shop AX Apparel">Shop AX Apparel</a></li>' + 530 '<li><a href="/athlean-x-live" title="Shop Live Events">Shop Live Events</a></li>' + 531 '</ul>' + 532 '</nav>' + 533 '</div>'; 534
535 jQuery('.cart-snapshot-items.js-snapshot-items').html(emptyCartPlaceholder); 536 537 jQuery('.cart-snapshot-header').addClass('noselect').html('<img loading="lazy" alt="Shopping cart icon" class="ax-cart-header-icon" src="/images/view-cart.png" height="32" width="32"><h3>My Cart</h3><button class="close js-view-cart-snapshot close-cart-snapshot" aria-label="Close cart"></button>'); 538 539 jQuery('#cartItems').hide(); 540 541 jQuery('.js-cart-snapshot-options').html('<div class="js-view-cart-snapshot">' + 542 '<button class="ax-btn btn-black btn-large btn-fluid cart-snapshot-button cart-snapshot-button-continue close-cart-snapshot js-view-cart-snapshot">Continue Shopping</button>' + 543 '</div>'); 544 545 if (!(jQuery(".close.js-view-cart-snapshot").hasClass("close-cart-snapshot"))) { 546 jQuery(".close.js-view-cart-snapshot").addClass("close-cart-snapshot"); 547 } 548 } 549 550 551 jQuery(function ($) { 552 var $recommended = $('#recommended-cart-div') 553 , $slideout = $('.cart-snapshot'); 554 555 $.ajax({ 556 url: "/athleanrx/recommended", 557 type: "POST", 558 data: { items: cart.items ?? [] }, 559 success: function (response) { 560 if (!response) { 561 $recommended.slideUp(function () { 562 $recommended.empty(); 563 $slideout.addClass('recommended-closed'); 564 checkFooterShadow(); 565 }); 566 } else { 567 if ($recommended.is(':empty')) { 568 $recommended.hide() 569 .html(response) 570 .slideDown(200, function () { 571 checkFooterShadow(); 572 }); 573 if ($slideout.hasClass('recommended-open')) { 574 $('.powerups-open').show(); 575 $('.powerups-closed').hide(); 576 } else if ($slideout.hasClass('recommended-closed')) { 577 $('.powerups-closed').show(); 578 $('.powerups-open').hide(); 579 } else { 580 $('.powerups-closed').fadeIn(200); 581 $slideout.addClass('recommended-closed'); 582 $recommended.show(); 583 } 584 } else { 585 if ($slideout.hasClass('recommended-open')) { 586 $recommended.html(response); 587 $('.powerups-open').show(); 588 $('.powerups-closed').hide(); 589 } else if ($slideout.hasClass('recommended-closed')) { 590 $('.powerups-closed').show(); 591 $('.powerups-open').hide(); 592 $recommended.html(response); 593 } else { 594 $slideout.addClass('recommended-closed'); 595 $recommended.hide().html(response); 596 $('.powerups-closed').fadeIn(200); 597 $recommended.show(); 598 } 599 } 600 601 if ($slideout.find('.ax-cart-item-list li.flyout_powerup').length) { 602 $slideout.removeClass('recommended-closed'); 603 $('.powerups-closed').hide(); 604 $recommended.fadeIn(); 605 $('.powerups-open').slideDown(200, function () { 606 $slideout.addClass('recommended-open'); 607 }); 608 checkFooterShadow(); 609 } 610 611 // Div currently hidden during dev until a home is found for it. 612 if (powerUp) { 613 $slideout.find(".rec_power_price").append(powerUpText); 614 } 615 616 typeof AX.discounts.updateHandler === 'function' && AX.discounts.updateHandler(cart); 617 // typeof AX.bonus.updateHandler === 'function' && AX.bonus.updateHandler(cart); 618 619 checkFooterShadow(); 620 } 621 } 622 }); 623 624 // Open Power Ups. 625 $(document) 626 .off('click.ax.powerups.open', '.open-powerups-button') 627 .on('click.ax.powerups.open', '.open-powerups-button', function (event) { 628 var cart = $('.cart-snapshot-items #axcart').get(0); 629 $slideout.addClass('recommended-opening'); 630 $slideout.removeClass('recommended-closed recommended-closing'); 631 $('.powerups-open').hide().slideDown({ 632 duration: 300, 633 progress: function () { 634 cart.scrollTop = cart.scrollHeight - cart.clientHeight; 635 }, 636 complete: function () { 637 $('.powerups-closed').hide(); 638 $slideout.addClass('recommended-open'); 639 $slideout.removeClass('recommended-opening'); 640 $('.ax-cart-footer').removeClass('shadow'); 641 } 642 }); 643 }); 644 645 // Close Power Ups. 646 $(document) 647 .off('click.ax.powerups.close', '.close-powerups-button') 648 .on('click.ax.powerups.close', '.close-powerups-button', function (event) { 649 $slideout.removeClass('recommended-opening'); 650 $slideout.addClass('recommended-closing');
651 $('.powerups-open').slideUp({ 652 duration: 300, 653 complete: function () { 654 $('.powerups-closed').show(); 655 $slideout.removeClass('recommended-open recommended-closing') 656 .addClass('recommended-closed'); 657 $('.ax-cart-footer').removeClass('shadow'); 658 } 659 }); 660 }); 661 662 // Close slideout cart if escape key is pressed while it's active. 663 $(document) 664 .off('keyup.ax.slideout') 665 .on('keyup.ax.slideout', function (event) { 666 if ($('body').hasClass('cart-snapshot-active') && event.keyCode == 27) { 667 axhideSnapshot(); 668 } 669 }); 670 671 // Fade out removed items. 672 $(document) 673 .off('click.ax.cart.remove-item', '.ax-item-remove-btn') 674 .on('click.ax.cart.remove-item', '.ax-item-remove-btn', function (event) { 675 $(this).closest('li').addClass("disabledsupplement"); 676 sessionStorage['poppedOnce'] = ""; 677 }); 678 679 // Add box shadow to cart footer if lists overflow under the slideout footer. 680 $(window) 681 .on('resize.ax.cart.shadow load.ax.cart.shadow') 682 .on('resize.ax.cart.shadow load.ax.cart.shadow', function (event) { 683 checkFooterShadow(); 684 }); 685 686 // Check if scrolled to bottom of the cart list, remove shadow temporarily while there. 687 $('.cart-snapshot-items #axcart') 688 .off('scroll.ax.cart.shadow-scroll wheel.ax.cart.shadow-scroll') 689 .on('scroll.ax.cart.shadow-scroll wheel.ax.cart.shadow-scroll', function (event) { 690 var $this = $(this); 691 if ($this.scrollTop() + $this.innerHeight() >= $this.get(0).scrollHeight) { 692 $('.ax-cart-footer').removeClass('shadow'); 693 } else { 694 checkFooterShadow(); 695 } 696 }); 697 }); 698 699 typeof AX.discounts.updateHandler === 'function' && AX.discounts.updateHandler(cart); 700 // typeof AX.bonus.updateHandler === 'function' && AX.bonus.updateHandler(cart); 701} 702 703function makeitemhtml(item, isDisabled, isPowerup, getBackorderHtml, reviewpage = false) { 704 var currency = new Intl.NumberFormat('en-US', { 705 style: 'currency', 706 currency: 'USD', 707 }); 708 709 let autoship = false; 710 if (item.auto_order_schedule != undefined && item.auto_order_schedule != '' && item.auto_order_schedule != 'None' && item.auto_order_schedule != 'none') { 711 autoship = true; 712 } 713 let itemsHtml = ''; 714 715 var msrpPrice = typeof item?.manufacturer_suggested_retail_price !== 'undefined' ? item.manufacturer_suggested_retail_price.value : item.unit_cost.value; 716 717 if (item.default_thumbnail_url == undefined && item.default_image_url != undefined) { 718 defaultImage = item.default_image_url; 719 } else if (item.default_thumbnail_url != undefined && item.default_image_url == undefined) { 720 defaultImage = item.default_thumbnail_url; 721 } else if (item.default_thumbnail_url != undefined && item.default_image_url != undefined) { 722 defaultImage = item.default_thumbnail_url; 723 } else if (item.default_thumbnail_url == undefined && item.default_image_url == undefined && item.multimedia[0] != undefined) { 724 defaultImage = item.multimedia[0].url; 725 } else { 726 defaultImage = '/images/branding/logo.png'; 727 } 728 729 itemsHtml += ` 730 <li class="ax-cart-item item js-snapshot-item ${item.item_id} ${isPowerup ? 'flyout_powerup' : ''}" 731 ${isPowerup ? 'data-sku="' + item.item_id + '" data-qty="' + item.quantity + '"' : ''}>`; 732 733 // itemsHtml += `<button class="ax-item-remove-btn remove-options-remove js-snapshot-confirm-remove" 734 // data-itemid="${item.item_id}" 735 // data-position="${item.position}" 736 // aria-label="Remove ${item.description.replace(/(<([^>]+)>)/gi, "")} from cart"> 737 // <span>REMOVE</span> <i class="ax-remove-item-icon fa fa-times" aria-hidden="true"></i> 738 // </button>`; 739 740 itemsHtml += `<div class="item-picture"> 741 <img loading="lazy" width="80" height="80" src="${defaultImage}" alt="${item.description.replace(/(<([^>]+)>)/gi, "")}" title="${item.description.replace(/(<([^>]+)>)/gi, "")}">`; 742 743 // DISCOUNT BADGE 744 var currentDiscount = 0; 745 if (AX.discounts.isEligible(item.item_id)) { 746 currentDiscount = AX.discounts.currentDiscountByMsrp(item.unit_cost_with_discount.value, msrpPrice); 747 } 748 749 if (currentDiscount > 0) { 750 if (autoship) { 751 // currentDiscount += 5; 752 } 753 754 itemsHtml += ` 755 <div class="item-discount breakpoint-met ${currentDiscount >= AX.discounts.discountBreakpoint() ? 'breakpoint-met' : ''}"> 756 <span>${currentDiscount}%</span> 757 <span>
757off</span> 758 </div>`; 759 } 760 761 itemsHtml += `</div>`; 762 763 itemsHtml += `<div class="rightsidecart"> 764 <div class="item-name"> 765 ${item.description} 766 </div>`; 767 768 if (reviewpage) { 769 itemsHtml += `<div class="autoshipoption"> 770 <label class="autoshiplabel" for="autoshipcheckbox"> <input type="checkbox" id="autoship`+ item.item_id + `" name="autoshipcheckbox" ${autoship ? 'checked' : ''} data-itemsku="` + item.item_id + `" data-itemposition="` + item.position + `" data-itemquantity="` + item.quantity + `"> 771<span class="autoshiptext" style="margin:0 6px 0 0;">${autoship ? '<img loading="lazy" class="autoshiptextlogo" alt="Auto Ship" src="/images/autoship/ax-cycle.svg"><span style="color:var(--price);">AUTOSHIP</span><span class="savedfive">YOU SAVED 5%</span>' : '<span>AUTOSHIP</span>'}</span><span class="customcheckbox"></span><br> 772</label> 773</div>`; 774 } 775 else if (autoship) { 776 itemsHtml += `<img loading="lazy" class="updateRecurring fa fa-refresh" style="color: #c40000; margin-right: 3px; float:right; width: 17px; position: absolute; right: 0; background: #ffffff; border-radius: 4px; padding: 1px; overflow: hidden;" title="Recurring Order" data-itemsku="${item.item_id}" data-itemquantity="${item.quantity}" data-itemposition="${item.position}" data-recurring="true" alt="Auto Ship" src="/images/autoship/ax-cycle.svg" width="" height="">`; 777 } else if (item.auto_order_schedule != undefined && (item.auto_order_schedule == 'None' || item.auto_order_schedule == 'none')) { 778 } 779 autoshipnotice = ''; 780 if (removeAutoship == true && reviewpage && item.auto_order_schedule != undefined && (item.auto_order_schedule != 'None' || item.auto_order_schedule != 'none')) { 781 autoshipnotice = `<i title="This item can not be set to autoship to the listed address" class="autoshipnotice fa fa-exclamation-triangle" style="color: #c40000;font-size: 26px;position: absolute;right: 0;top: 32px;"></i>`; 782 } 783 784 var itemDescription = item.extended_description; 785 786 // display the autoship schedule dynamically instead of hardcoding in item descriptions. 787 var autoshipSchedule = ''; 788 if (item.auto_order_schedule != undefined && item.auto_order_schedule != 'None' && item.auto_order_schedule != 'none') { 789 autoshipSchedule = '<br />Ships ' + item.auto_order_schedule 790 } 791 792 if (typeof item.options !== 'undefined') { 793 var optionValues = []; 794 item.options.map(function (opt) { 795 optionValues.push(opt.selected_value ?? '') 796 }) 797 itemDescription = optionValues.join('<br/>') 798 } 799 800 801 itemsHtml += `<div class="extended_descrip"> 802 ${itemDescription} 803 ${getBackorderHtml} 804 ${autoshipSchedule} 805 ${autoshipnotice} 806 </div> 807 <div class="ax-item-footer"> 808 <div class="ax-qty-input-wrapper noselect"> 809 <span class="qty-label" id="qty-label-${item.item_id}">Qty:</span> 810 <div class="ax-qty-input ax-qty-input-sm" role="group" aria-labelledby="qty-label-${item.item_id}"> 811 <div class="item-qty"> 812 <button class="qtyminus sgldwn" 813 field="quantity" 814 aria-label="Decrease quantity for ${item.description.replace(/(<([^>]+)>)/gi, "")}" 815 onclick="decreaseamount('${item.item_id}', '${item.quantity}', '${autoship}', '${item.position}')"> 816 <span class="arrow-down2" aria-hidden="true">--</span> 817 </button> 818 <div class="acutalqty ${isDisabled ? 'disabled' : ''}" role="status" aria-live="polite"> 819 ${item.quantity} 820 </div> 821 <button class="qtyplus sglup ${item.maximum_quantity === 1 ? 'disabled' : ''}" 822 field="quantity" 823 aria-label="Increase quantity for ${item.description.replace(/(<([^>]+)>)/gi, "")}" 824 ${isDisabled ? 'data-tippy-content="Maximum Quantity Reached" disabled' : ''} 825 ${!isDisabled ? 'onclick="increaseamount(\'' + item.item_id + '\', \'' + item.quantity + '\', \'' + autoship + '\', ' + item.position + ')"' : ''}> 826 <span class="arrow-up2" aria-hidden="true">+</span> 827 </button> 828 </div> 829 </div> 830 </div>`; 831 832 if (msrpPrice != item.unit_cost_with_discount.value && item.unit_cost_with_discount.localized_formatted !== '$0.00') { 833 itemsHtml += `<div class="item-price msrp-price" title="List Price"> 834 ${currency.format(msrpPrice)} 835 </div>`; 836 } 837 838 itemsHtml += `<div class="item-price" title="Today's Price">` 839 840 if (autoship) { 841 // itemsHtml += `$${setAutoshipOffset(item)}<small class="item-each">/ ea.</small>` 842 itemsHtml += `${item.unit_cost_with_discount.localized_formatted}<small class="item-each">/ ea.</small>` 843 } else { 844 845 if (item.unit_cost_with_discount.localized_formatted === '$0.00') { 846 itemsHtml += `<span style="color: #c40000 !important">FREE!</span>`;
847 } else { 848 itemsHtml += `${item.unit_cost_with_discount.localized_formatted}<small class="item-each">/ ea.</small>` 849 } 850 } 851 852 itemsHtml += `</div> 853 </div> 854 </div> 855 </li>`; 856 return itemsHtml; 857} 858 859function setAutoshipOffset(item) { 860 var price = item.unit_cost_with_discount.value; 861 var sku = item.item_id.toUpperCase(); 862 863 if (sku.startsWith('RX1-')) { 864 price = price - 2.25; 865 } else if (sku.startsWith('RX3-')) { 866 price = price - 3; 867 } else if (sku.startsWith('RXP-') || sku.startsWith('RXVP-') || sku.startsWith('RXCP-')) { 868 price = price - 3.25; 869 } else if (sku.startsWith('RX4-')) { 870 // price = price - 2.75; 871 price = price - 2.95; 872 } else if (sku.startsWith('PRX-')) { 873 price = price - 2.75; 874 } else if (sku === 'RXPU-APH-R' || sku === 'RXPU-MCX-R' || sku === 'RXPU-OM3-R' || sku === 'RX-MECH-R' || sku === 'RX-OMEGA-R' || sku === 'RX-AALPHA-R') { 875 price = price - 2.75; 876 } else if (sku === 'RX-MONO-30-R') { 877 // price = price - 1.20; 878 price = price - 1.10; 879 } else if (sku === 'RX-MONO-90-R' || sku === 'RX-MONO-90K-R') { 880 price = price - 2.15; 881 } else if (sku.startsWith('RXG')) { 882 price = price - 3; 883 } else if (sku === 'RX-MECH-L-R' || sku === 'RX-OMEGA-L-R') { 884 price = price - 2.08 885 } 886 887 return price.toFixed(2); 888} 889 890// Close the recommended "add to cart" inner slideout panel. 891function closeRecommendedInnerSlide() { 892 jQuery(".flyout-rec-flavors").slideUp(250); 893 jQuery(".recommended-add-to-cart").removeClass("buy_rec_item"); 894} 895 896function checkFooterShadow() {
897 var $cart = jQuery('.cart-snapshot-items #axcart') 898 , $footer = jQuery('.ax-cart-footer') 899 , $list = jQuery('.ax-cart-item-list') 900 , $recommended = jQuery('.recommended-wrapper'); 901 902 if (!$cart.length) return; 903 904 var atBottom = $cart.scrollTop() + $cart.innerHeight() >= $cart.get(0).scrollHeight; 905 906 if (!atBottom && ($cart.innerHeight() < ($list.outerHeight() + $recommended.outerHeight()))) { 907 $footer.addClass('shadow'); 908 } else { 909 $footer.removeClass('shadow'); 910 } 911} 912 913jQuery(document).on('click', '#viewcart', function (e) { 914 e.preventDefault(); 915 // e.stopPropagation(); 916 917 $('.ax-cart').toggleClass('ax-cart--open'); 918 919 // Update ARIA attributes for accessibility 920 if ($('.ax-cart').hasClass('ax-cart--open')) { 921 $('.ax-cart').attr('aria-hidden', 'false'); 922 } else { 923 // Delay hiding from screen readers to allow slide animation to complete 924 setTimeout(function() { 925 if (!$('.ax-cart').hasClass('ax-cart--open')) { 926 $('.ax-cart').attr('aria-hidden', 'true'); 927 } 928 }, 300); 929 } 930 931 UC.getCart(function (cart) { 932 axupdateSnapshotItems(cart); 933 934 jQuery(document).trigger('view.ax.cart', cart); 935 936 UCWP.cartSnapShot.showSnapshot(function () { 937 checkFooterShadow(); 938 939 // Focus first focusable element in cart when opened 940 if ($('.ax-cart').hasClass('ax-cart--open')) { 941 setTimeout(function() { 942 const $firstFocusable = $('.ax-cart').find('a, button, input, select, [tabindex="0"]').filter(':visible').first(); 943 if ($firstFocusable.length) { 944 $firstFocusable.focus(); 945 } 946 }, 100); 947 } 948 }); 949 }); 950}); 951 952function loadaxcart() { 953 UC.getCart(function (cart) { 954 axupdateSnapshotItems(cart); 955 jQuery(document).trigger('view.ax.cart', cart); 956 checkFooterShadow(); 957 }, false); 958} 959 960function increaseamount(itemid, quantity, autoship = false, position) { 961 var itemId1 = itemid; 962 var quantity1 = (parseInt(quantity, 10) + 1); 963 var eventData = { 964 contents: [], 965 event_id: '', 966 event_source_url: '', 967 event_time: 0, 968 user_data: { 969 client_ip_address: '', 970 client_user_agent: '' 971 } 972 }; 973 974 jQuery(document).trigger('increase.ax.cart'); 975 976 if (itemId1.split("-")[0] == 'RXPU') { 977 if (backorders[itemId1] && backorders[itemId1]["*"] && jQuery('#axcart .sku-' + itemId1).val() < 1) { 978 var success = confirm("Due to high volume during Black Friday, " + itemId1 + " is on backorder and is expected to ship on " + backorders[itemId1]["*"] + " Your order will not ship until this flavor is restocked. Would you still like to add to cart?"); 979 if (!success) { 980 return false; 981 } 982 } 983 } else { 984 jQuery('.' + itemid).addClass("disabledsupplement"); 985 } 986 let rxprice = 0; 987 let rxImg = ""; 988 let rxName = ""; 989 990 // let priceElement = document.querySelector("[data-position='"+position+"']"); 991 let priceElement = document.querySelector(".ax-cart-item." + itemid); 992 993 if (priceElement) { 994 rxprice = parseFloat(priceElement.querySelector(".item-price").innerText.split("$")[1]) 995 rxImg = priceElement.querySelector(".item-picture img").src 996 rxName = priceElement.querySelector(".item-name").innerText 997 998 // Need exact match on casing for title. 999 let $item = $(priceElement); 1000 rxName = $item.find('.item-name').html().trim(); 1001 } 1002 1003 1004 // if (priceElement && priceElement.parentElement) { 1005 // rxprice = parseFloat(priceElement.parentElement.querySelector(".item-price").innerText.split("$")[1]) 1006 // rxImg = priceElement.parentElement.querySelector(".item-picture img").src 1007 // rxName = priceElement.parentElement.querySelector(".item-name").innerText 1008 1009 // // Need exact match on casing for title. 1010 // let $item = $(priceElement.parentElement); 1011 // rxName = $item.find('.item-name').html().trim(); 1012 // } 1013 1014 let cartTotal = parseFloat( jQuery(".finaltotal .item-price")[0].innerText.split("$")[1] ); 1015 // try { 1016 // ccLayer.push({ 1017 // ccEvent: 'miniCartViewed', 1018 // src: 'custom', 1019 // items: [{ 1020 // id: itemid, //id of prouct 1021 // name: rxName, //name of product present in cart 1022 // price: rxprice, //price of product 1023 // currency: 'USD', //currency 1024 // quantity: quantity1, //quantity of product present in cart 1025 // url: jQuery(location).attr('href'), //url of product page 1026 // image: rxImg, //image url of the product 1027 // }], 1028 // currency: 'USD', //currency 1029 // total: cartTotal, //cart total including shipping, taxes 1030 // }); 1031 // }catch(e) {} 1032 let kItem = { 1033 "AddedItemProductName": rxName, 1034 "AddedItemProductID": itemid, 1035 "AddedItemSKU": itemid, 1036 "AddedItemURL": jQuery(location).attr('href'), 1037 "AddedItemPrice": rxprice, 1038 "AddedItemQuantity": 1, 1039 "$value": rxprice 1040 } 1041 if (typeof fbq == 'function') { 1042 fbq('track', 'AddToCart', {
1043 content_type: 'product', 1044 content_ids: [itemid], 1045 content_name: rxName, 1046 content_category: 'Physical', 1047 value: rxprice, 1048 currency: 'USD' 1049 }); 1050 } 1051 1052 if (typeof klaviyo !== 'undefined') { 1053 klaviyo.push(['track', 'Added to Cart', kItem]); 1054 } 1055 1056 if (typeof gtag === 'function') { 1057 gtag('event', 'add_to_cart', { 1058 "items": [{ 1059 "item_id": itemid, 1060 "item_name": rxName, 1061 "list_name": "AX Supplement", 1062 "item_brand": "AX", 1063 "item_category": "Physical", 1064 "list_position": 1, 1065 "quantity": quantity1, 1066 "price": rxprice 1067 }], 1068 "external_id": getCookie('external_id') 1069 }); 1070 } 1071 1072 1073 UC.getCart(function (cart) { 1074 if (cart.items) { 1075 if (cart.items[position - 1].item_id == itemid) { 1076 cart.items[position - 1].quantity++; 1077 } 1078 } 1079 1080 UC.postCart(cart, function (updatedCart, errors) { 1081 if (errors.length > 0) { 1082 if (errors[0].includes("backorder")) { 1083 axupdateSnapshotItems(updatedCart); 1084 } else { 1085 jQuery('.' + itemid).removeClass("disabledsupplement"); 1086 console.error('[AX CART]', errors); 1087 1088 // AX.modal.show('#axModal', { 1089 // content: '<div class="ax-modal-error">' + errors[0] + '</div>' 1090 // }); 1091 1092 1093 if (Array.isArray(errors) && 1094 errors.length === 1 && 1095 typeof errors[0] === 'string' && 1096 errors[0].indexOf("We're sorry, the maximum quantity that can be ordered at once") === 0) { 1097 console.debug('Promotional item max quantity is 1.'); 1098 } else { 1099 AX.modal.show('#axModal', { 1100 content: '<div class="ax-modal-error">' + errors[0] + '</div>' 1101 }); 1102 } 1103 1104 1105 axupdateSnapshotItems(updatedCart); 1106 } 1107 } else { 1108 axupdateSnapshotItems(updatedCart); 1109 } 1110 for (var i = 0; i < cart.items.length; i++) { 1111 var item = cart.items[i]; // Get the current item 1112 // Add the item's name and price to the eventData.contents array 1113 eventData.contents.push({ 1114 id: item.item_id, 1115 item_price: item?.unit_cost?.value, 1116 quantity: item.quantity 1117 }); 1118 } 1119 var fbc = getCookie('_fbc'); 1120 var fbp = getCookie('_fbp'); 1121 var fbuser = getCookie('c_user'); 1122 var external_id = getCookie('external_id'); 1123 eventData.currency = 'USD'; 1124 eventData.content_type = "product"; 1125 eventData.content_name = itemid; 1126 eventData.content_ids = rxName; 1127 eventData.content_category = "Physical"; 1128 eventData.event_id = 'UpdateCart_' + Math.random().toString(36).slice(2, 9); 1129 eventData.event_source_url = window.location.href; 1130 eventData.event_time = Math.floor(new Date().getTime() / 1000); 1131 eventData.user_data.client_ip_address = cart.checkout.ip_address; 1132 eventData.user_data.client_user_agent = navigator.userAgent;; 1133 eventData.user_data.fbc = fbc; 1134 eventData.user_data.fbp = fbp; 1135 eventData.user_data.fb_login_id = fbuser; 1136 eventData.user_data.external_id = external_id; 1137 sendTrackingData("Update Cart", JSON.stringify(eventData) ); 1138 }); 1139 }); 1140 1141 1142 sessionStorage['poppedOnce'] = ""; 1143} 1144 1145function decreaseamount(itemid, quantity, autoship = false, position) { 1146 var itemId1 = itemid; 1147 var quantity1 = (parseInt(quantity, 10) - 1); 1148 var eventData = { 1149 contents: [], 1150 event_id: '', 1151 event_source_url: '', 1152 event_time: 0, 1153 user_data: { 1154 client_ip_address: '', 1155 client_user_agent: '' 1156 } 1157 }; 1158 1159 jQuery(document).trigger('decrease.ax.cart'); 1160 1161 if (itemId1.split("-")[0] == 'RXPU') { 1162 // jQuery("#recommended-cart-div").addClass("disabledsupplement"); 1163 } else { 1164 jQuery('.' + itemid).addClass("disabledsupplement"); 1165 } 1166 1167 let rxprice = 0; 1168 let rxImg = ""; 1169 let rxName = ""; 1170 let priceElement = document.querySelector("[data-position='"+position+"']"); 1171 if (priceElement && priceElement.parentElement) { 1172 rxprice = parseFloat(priceElement.parentElement.querySelector(".item-price").innerText.split("$")[1]) 1173 rxImg = priceElement.parentElement.querySelector(".item-picture img").src 1174 rxName = priceElement.parentElement.querySelector(".item-name").innerText 1175 } 1176 let cartTotal = parseFloat( jQuery(".finaltotal .item-price")[0].innerText.split("$")[1] ); 1177 // try { 1178 // ccLayer.push({ 1179 // ccEvent: 'miniCartViewed', 1180 // src: 'custom', 1181 // items: [{ 1182 // id: itemid, //id of prouct 1183 // name: rxName, //name of product present in cart 1184 // price: rxprice, //price of product 1185 // currency: 'USD', //currency 1186 // quantity: quantity1, //quantity of product present in cart 1187 // url: jQuery(location).attr('href'), //url of product page 1188 // image: rxImg, //image url of the product 1189 // }], 1190 // currency: 'USD', //currency 1191 // total: cartTotal, //cart total including shipping, taxes 1192 // }); 1193 // }catch(e) {} 1194 let kItem = { 1195 "ProductID": rxName, 1196 "SKU": itemid, 1197 "URL": jQuery(location).attr('href'), 1198 "Price": rxprice 1199 } 1200 if (typeof fbq == 'function') { 1201 // fbq('track', 'AddToCart', { 1202 // content_type: 'product',
1203 // content_ids: [itemid], 1204 // content_name: rxName, 1205 // content_category: 'Physical', 1206 // value: rxprice, 1207 // currency: 'USD' 1208 // }); 1209 } 1210 1211 if (typeof klaviyo !== 'undefined') { 1212 // klaviyo.push(['track', 'Added to Cart', kItem]); 1213 } 1214 1215 if (typeof gtag === 'function') { 1216 // gtag('event', 'add_to_cart', { 1217 // "items": [{ 1218 // "item_id": itemid, 1219 // "item_name": rxName, 1220 // "list_name": "AX Supplement", 1221 // "item_brand": "AX", 1222 // "item_category": "Physical", 1223 // "list_position": 1, 1224 // "quantity": quantity1, 1225 // "price": rxprice 1226 // }], 1227 // "external_id": getCookie('external_id') 1228 // }); 1229 } 1230 1231 UC.getCart(function (cart) { 1232 if (cart.items && itemid) { 1233 if (cart.items[position - 1].item_id == itemid) { 1234 cart.items[position - 1].quantity--; 1235 } 1236 } 1237 1238 UC.postCart(cart, function (updatedCart, errors) { 1239 if (errors.length > 0) { 1240 if (errors[0].includes("backorder")) { 1241 axupdateSnapshotItems(updatedCart); 1242 } else { 1243 if (itemid) { 1244 jQuery('.' + itemid).removeClass("disabledsupplement"); 1245 } 1246 console.error('[AX CART]', errors); 1247 1248 if (Array.isArray(errors) && 1249 errors.length === 1 && 1250 typeof errors[0] === 'string' && 1251 errors[0].indexOf("We're sorry, the maximum quantity that can be ordered at once") === 0) { 1252 console.debug('Promotional item max quantity is 1.'); 1253 } else { 1254 AX.modal.show('#axModal', { 1255 content: '<div class="ax-modal-error">' + errors[0] + '</div>' 1256 }); 1257 } 1258 1259 axupdateSnapshotItems(updatedCart); 1260 } 1261 } else { 1262 axupdateSnapshotItems(updatedCart); 1263 } 1264 1265 for (var i = 0; i < cart.items.length; i++) { 1266 var item = cart.items[i]; // Get the current item 1267 // Add the item's name and price to the eventData.contents array 1268 eventData.contents.push({ 1269 id: item.item_id, 1270 item_price: item?.unit_cost?.value, 1271 quantity: item.quantity 1272 }); 1273 } 1274 var fbc = getCookie('_fbc'); 1275 var fbp = getCookie('_fbp'); 1276 var fbuser = getCookie('c_user'); 1277 eventData.value = rxprice; 1278 eventData.currency = 'USD'; 1279 eventData.content_type = "product"; 1280 eventData.content_name = itemid; 1281 eventData.content_ids = rxName; 1282 eventData.content_category = "Physical"; 1283 eventData.event_id = 'UpdateCart_' + Math.random().toString(36).slice(2, 9); 1284 eventData.event_source_url = window.location.href; 1285 eventData.event_time = Math.floor(new Date().getTime() / 1000); 1286 eventData.user_data.client_ip_address = cart.checkout.ip_address; 1287 eventData.user_data.client_user_agent = navigator.userAgent;; 1288 eventData.user_data.fbc = fbc; 1289 eventData.user_data.fbp = fbp; 1290 eventData.user_data.fb_login_id = fbuser; 1291 eventData.user_data.external_id = getCookie('external_id'); 1292 sendTrackingData("Update Cart", JSON.stringify(eventData)); 1293 }); 1294 }); 1295 1296 sessionStorage['poppedOnce'] = ""; 1297} 1298 1299jQuery(document).on('click', '.close-cart-snapshot', function (e) { 1300 e.preventDefault(); 1301 e.stopPropagation(); 1302 axhideSnapshot(); 1303}); 1304 1305jQuery(document).on('click', '.dark-overlay.js-view-cart-snapshot', function (e) { 1306 e.preventDefault(); 1307 e.stopPropagation(); 1308 axhideSnapshot(); 1309}); 1310 1311function axhideSnapshot() { 1312 delay = 0; 1313 1314 setTimeout(function () { 1315 if (UCWP.elems.$body.hasClass('cart-snapshot-active')) { 1316 UCWP.elems.$body.removeClass('cart-snapshot-active'); 1317 } 1318 1319 closeRecommendedInnerSlide(); 1320
1321 var $slideout = jQuery('.cart-snapshot'); 1322 if ($slideout.find('.ax-cart-empty').length) { 1323 $slideout.removeClass('recommended-open recommended-opening recommended-closed recommended-closing'); 1324 jQuery('#recommended-cart-div').empty(); 1325 } 1326 1327 jQuery(".cart-snapshot").transition({ x: 0 }, 500, "linear", function () { 1328 jQuery(".cart-snapshot").css({ "display": "none" }); 1329 }); 1330 }, delay || 0); 1331} 1332 1333jQuery('body').on('click', '#axModal .close', function () { 1334 AX.modal.hide('#axModal'); 1335}); 1336 1337jQuery('body').on('click', '#myModal .close', function () { 1338 jQuery('#myModal').hide(); 1339}); 1340 1341jQuery('body').on('click', '.add-program-cart', function (e) { 1342 var eventData = { 1343 contents: [], 1344 event_id: '', 1345 event_source_url: '', 1346 event_time: 0, 1347 user_data: { 1348 client_ip_address: '', 1349 client_user_agent: '' 1350 } 1351 }; 1352 e.preventDefault(); 1353 let programsku = this.dataset.sku ?? null; 1354 let programPrice = this.dataset.price ?? null; 1355 let programName = this.dataset.name ?? null; 1356 var coupon = this.dataset.coupon ? this.dataset.coupon : false; 1357 UC.getCart(function (cart) { 1358 var itemInfo = { 1359 'item_id': programsku, 1360 'quantity': 1 1361 }; 1362 1363 if (coupon) { 1364 var coupons = { 1365 coupon_code: coupon 1366 }; 1367 cart.coupons.push(coupons); 1368 } 1369 1370 if (jQuery("#viewcart").data("bfspecial") == "TRUE") { 1371 var BANEB = { 1372 coupon_code: 'BANEBONUS' 1373 }; 1374 cart.coupons.push(BANEB); 1375 } 1376 1377 UC.updateCartItems(cart, itemInfo); 1378 UC.postCart(cart, function (updatedCart, errors) { 1379 if (errors.length > 0) { 1380 if (errors[0].includes("coupon")) { 1381 AX.modal.hide('#axModal'); 1382 axupdateSnapshotItems(updatedCart); 1383 } else if (errors[0].includes("backorder")) { 1384 axupdateSnapshotItems(updatedCart); 1385 } else { 1386 AX.modal.show('#axModal', { 1387 content: '<div class="ax-modal-error">' + errors[0] + '</div>' 1388 }); 1389 1390 console.error('[AX CART]', errors); 1391 } 1392 } else { 1393 AX.modal.hide('#axModal'); 1394 jQuery('.ult-overlay.content-xx2.supp-pop-modal').removeClass(" ult-open"); 1395 axupdateSnapshotItems(updatedCart); 1396 UCWP.cartSnapShot.showSnapshot(); 1397 1398 for (var i = 0; i < cart.items.length; i++) { 1399 var item = cart.items[i]; // Get the current item 1400 // Add the item's name and price to the eventData.contents array 1401 eventData.contents.push({ 1402 id: item.item_id, 1403 item_price: item?.unit_cost?.value, 1404 quantity: item.quantity 1405 }); 1406 } 1407 1408 var myEventId = 'AddToCart_' + Math.random().toString(36).slice(2, 9); 1409 var url = jQuery(location).attr('href'); 1410 var kItem = { 1411 "ProductID": programPrice, 1412 "SKU": programsku, 1413 "URL": url, 1414 "Price": programPrice 1415 }; 1416 ccLayer = window.ccLayer || {}; 1417 cartvalue = cart.summary.subtotal.value + parseInt(programPrice); 1418 // try { 1419 // ccLayer.push({ 1420 // ccEvent: 'miniCartViewed', 1421 // src: 'custom', 1422 // items: [ // all the items present in the cart 1423 // { 1424 // id: programsku, //id of prouct 1425 // name: programName, //name of product present in cart 1426 // price: programPrice, //price of product 1427 // currency: 'USD', //currency 1428 // quantity: 1, //quantity of product present in cart 1429 // url: jQuery(location).attr('href'), //url of product page 1430 // } 1431 // ], 1432 // currency: 'USD', //currency 1433 // total: cartvalue, //cart total including shipping, taxes 1434 // }); 1435 // }catch(e) {} 1436 if (typeof fbq == 'function') { 1437 fbq('track', 'AddToCart', { 1438 content_type: 'product', 1439 content_ids: [programsku], 1440 content_name: programName, 1441 content_category: 'Digital', 1442 value: programPrice, 1443 currency: 'USD' 1444 }, 1445 {eventID: myEventId}); 1446 } 1447 if (typeof klaviyo !== 'undefined') { 1448 klaviyo.push(['track', 'Added to Cart', kItem]); 1449 } 1450 if (typeof gtag === 'function') { 1451 gtag('event', 'add_to_cart', { 1452 "items": [ 1453 { 1454 "item_id": programsku, 1455 "item_name": programName, 1456 "list_name": "AX Program", 1457 "item_brand": "AX", 1458 "item_category": "Digital", 1459 "list_position": 1, 1460 "quantity": 1, 1461 "price": programPrice 1462 } 1463 ], 1464 "external_id": getCookie('external_id') 1465 }); 1466 } 1467 1468 1469 var fbc = getCookie('_fbc'); 1470 var fbp = getCookie('_fbp'); 1471 var fbuser = getCookie('c_user'); 1472 eventData.value = programPrice; 1473 eventData.currency = 'USD'; 1474 eventData.content_type = "product"; 1475 eventData.content_name = programName; 1476 eventData.content_ids = programsku; 1477 eventData.content_category = "Digital"; 1478 eventData.event_id = myEventId; 1479 eventData.event_source_url = window.location.href; 1480 eventData.event_time = Math.floor(new Date().getTime() / 1000); 1481 eventData.user_data.client_ip_address = cart.checkout.ip_address; 1482 eventData.user_data.client_user_agent = navigator.userAgent;; 1483 eventData.user_data.fbc = fbc; 1484 eventData.user_data.fbp = fbp; 1485 eventData.user_data.fb_login_id = fbuser; 1486 eventData.user_data.external_id = getCookie('external_id') 1487 sendTrackingData("AddToCart", JSON.stringify(eventData)); 1488 } 1489 }); 1490 }); 1491 1492 sessionStorage['poppedOnce'] = ""; 1493}); 1494 1495function axupdatelogic(cart) { 1496 cartSummary = { 1497 RX1: false, 1498 RX2: false, 1499 RXP: false, 1500 RXVP: false, 1501 RXCP: false, 1502 RX3: false, 1503 RX4: false, 1504 RXB: false, 1505 RXBA: false, 1506 RXX: false, 1507 RXA: false, 1508 RXO: false, 1509 RXM: false, 1510 RXAA: false, 1511 RXOR: false, 1512 RXMR: false, 1513 RXAAR: false,
1514 AX1: false, 1515 AX2: false, 1516 PRX: false, 1517 PRXS: false, 1518 PRXcnt: 0, 1519 PRXScnt: 0, 1520 suptotal: 0, 1521 hasprogram: false, 1522 programnum: 0, 1523 currentpowerups: 0, 1524 hasbonus: false, 1525 qualbonusnum: 0, 1526 bonusnum: 0, 1527 suppsubtotal: 0, 1528 rxputotal: 0, 1529 powerupskus: { 1530 'RX-OMEGA': 0, 1531 'RX-AALPHA': 0, 1532 'RX-MECH': 0, 1533 'RXPU-MCX': 0, 1534 'RXPU-APH': 0, 1535 'RXPU-OM3': 0 1536 }, 1537 rcurrentpowerups: 0, 1538 rpowerupskus: { 1539 'RX-OMEGA-R': 0, 1540 'RX-AALPHA-R': 0, 1541 'RX-MECH-R': 0, 1542 'RXPU-MCX-R': 0, 1543 'RXPU-APH-R': 0, 1544 'RXPU-OM3-R': 0 1545 }, 1546 elastx: false, 1547 jacked: false, 1548 bonuses: { 1549 'ATX-ULT-ABS': false, 1550 'ATX-ARMOR-ABS': false, 1551 // 'ATX-BANE': false, 1552 'ATX-DRAGON': false, 1553 'ATX-IRON-B': false, 1554 'ATX-WARWEEK': false, 1555 'ATX-HOLLYWOOD': false, 1556 'ATX-XT2': false, 1557 'ATX-STINGER': false, 1558 'ATX-SWEAT16': false, 1559 'AX-WOLV': false, 1560 'AX-TACTX': false, 1561 'NXT-18': false, 1562 'NXT-15': false, 1563 'ATX-NXT-18': false, 1564 'ATX-NXT-15': false, 1565 'ATX-AAMUSCLE-B': false, 1566 'ATX-IRONC': false, 1567 'ATX-XT2ABS': false, 1568 'ATX-MASS': false, 1569 'ATX-MAX-FX': false 1570 } 1571 }; 1572 1573 const powerupskus = [ 1574 'RXPU-MCX', 'RXPU-APH', 'RXPU-OM3', 'RX-MECH', 'RX-AALPHA', 'RX-OMEGA' 1575 ]; 1576 1577 const recurringskus = [ 1578 'RX-MECH-R', 'RX-AALPHA-R', 'RX-OMEGA-R', 'RXPU-MCX-R', 'RXPU-APH-R', 'RXPU-OM3-R' 1579 ]; 1580 1581 for (var i = 0; i < cart.items.length; i++) { 1582 if ((cart.items[i].item_id).includes('RX1')) { 1583 cartSummary.RX1 = true; 1584 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1585 } 1586 1587 if ((cart.items[i].item_id).includes('PRX')) { 1588 cartSummary.PRX = true; 1589 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1590 cartSummary.PRXcnt += cart.items[i].quantity; 1591 } 1592 1593 if ((cart.items[i].item_id).includes('PRX') && (cart.items[i].item_id).includes('-S')) { 1594 cartSummary.PRXS = true; 1595 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1596 cartSummary.PRXScnt += cart.items[i].quantity; 1597 } 1598 1599 if ((cart.items[i].item_id).includes('RXP-')) { 1600 cartSummary.RXP = true; 1601 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1602 } 1603 1604 if ((cart.items[i].item_id).includes('RXCP-')) { 1605 cartSummary.RXCP = true; 1606 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1607 } 1608 1609 if ((cart.items[i].item_id).includes('RXVP-')) { 1610 cartSummary.RVXP = true; 1611 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1612 } 1613 1614 if ((cart.items[i].item_id).includes('RX2')) { 1615 cartSummary.RX2 = true; 1616 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1617 } 1618 1619 if ((cart.items[i].item_id).includes('RX3')) { 1620 cartSummary.RX3 = true; 1621 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1622 } else if ((cart.items[i].item_id).includes('RX4')) { 1623 cartSummary.RX4 = true; 1624 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1625 } else if ((cart.items[i].item_id).includes('RXB-')) { 1626 cartSummary.RXB = true; 1627 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1628 } else if ((cart.items[i].item_id).includes('RXBA')) { 1629 cartSummary.RXBA = true; 1630 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1631 } else if ((cart.items[i].item_id).includes('RXX')) { 1632 cartSummary.RXX = true; 1633 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1634 } 1635 else if ((cart.items[i].item_id).includes('RXA')) { 1636 cartSummary.RXA = true; 1637 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1638 } 1639 else if (cart.items[i].item_id == 'RX-OMEGA' || cart.items[i].item_id == 'RXPU-OM3') { 1640 cartSummary.RXO = true; 1641 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1642 if (jQuery(".inCartOmega").length > 0) { 1643 jQuery(".inCartOmega").find(".incartnum").html("1"); 1644 jQuery(".inCartOmega").show(); 1645 } 1646 } 1647 else if (cart.items[i].item_id == "RX-AALPHA" || cart.items[i].item_id == "RXPU-APH") { 1648 cartSummary.RXAA = true; 1649 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1650 if (jQuery(".inCartAalpha").length > 0) { 1651 jQuery(".inCartAalpha").find(".incartnum").html("1"); 1652 jQuery(".inCartAalpha").show(); 1653 } 1654 } 1655 else if (cart.items[i].item_id == "RX-MECH" || cart.items[i].item_id == "RXPU-MCX") { 1656 cartSummary.RXM = true; 1657 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1658 if (jQuery(".inCartMech").length > 0) { 1659 jQuery(".inCartMech").find(".incartnum").html("1"); 1660 jQuery(".inCartMech").show(); 1661 } 1662 } 1663 else if (cart.items[i].item_id == 'RX-OMEGA-R' || cart.items[i].item_id == 'RXPU-OM3-R') { 1664 cartSummary.RXOR = true; 1665 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1666 if (jQuery(".inCartOmega").length > 0) { 1667 jQuery(".inCartOmega").find(".incartnum").html("1"); 1668 jQuery(".inCartOmega").show(); 1669 } 1670 } 1671 else if (cart.items[i].item_id == "RX-AALPHA-R" || cart.items[i].item_id == "RXPU-APH-R") { 1672 cartSummary.RXAAR = true; 1673 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1674 if (jQuery(".inCartAalpha").length > 0) { 1675 jQuery(".inCartAalpha").find(".incartnum").html("1"); 1676 jQuery(".inCartAalpha").show(); 1677 } 1678 } 1679 else if (cart.items[i].item_id == "RX-MECH-R" || cart.items[i].item_id == "RXPU-MCX-R") { 1680 cartSummary.RXMR = true; 1681 cartSummary.suptotal += cart.items[i].total_cost_with_discount.value; 1682 if (jQuery(".inCartMech").length > 0) { 1683 jQuery(".inCartMech").find(".incartnum").html("1"); 1684 jQuery(".inCartMech").show(); 1685 } 1686 } 1687 // We caught all the single power up skus, now catch the Power up bundles 1688 else if (cart.items[i].item_id.startsWith("RXPU-")) { 1689 cartSummary.rxputotal += cart.items[i].total_cost_with_discount.value; 1690 } 1691 // RXPU-OM3: NaN, RXPU-OM3-R 1692 else if ((cart.items[i].item_id).includes("ATX-DP2") || (cart.items[i].item_id).includes("ATX-DP2-120")) { 1693 cartSummary.AX1 = true; 1694 } 1695 else if ((cart.items[i].item_id).includes("AX2-DP2") || (cart.items[i].item_id).includes("AX2-DP2-120")) { 1696 cartSummary.AX2 = true; 1697 } 1698 1699 if (recurringskus.includes(cart.items[i].item_id)) { 1700 tempid = cart.items[i].item_id; 1701 cartSummary.rcurrentpowerups += cart.items[i].quantity; 1702 cartSummary.rpowerupskus[tempid] += cart.items[i].quantity; 1703 } else if (powerupskus.includes(cart.items[i].item_id)) { 1704 tempid = cart.items[i].item_id; 1705 cartSummary.currentpowerups += cart.items[i].quantity; 1706 cartSummary.powerupskus[tempid] += cart.items[i].quantity; 1707 } 1708 1709 if (programSkus.includes(cart.items[i].item_id)) { 1710 cartSummary.hasprogram = true; 1711 cartSummary.programnum += cart.items[i].quantity; 1712 1713 if (cart.items[i].item_id == "ATX-ELASTX") { 1714 cartSummary.elastx = true; 1715 } else if (cart.items[i].item_id == "ATX-JACKED") { 1716 cartSummary.jacked = true; 1717 } 1718 } 1719 1720 if (bonusOptions.includes(cart.items[i].item_id)) { 1721 cartSummary.hasbonus = true; 1722 cartSummary.bonusnum += cart.items[i].quantity; 1723 } 1724 1725 if (cartSummary.hasbonus) {
1726 Object.keys(cartSummary.bonuses).forEach((bonus) => { 1727 if (bonus == cart.items[i].item_id) { 1728 cartSummary.bonuses[bonus] = true; 1729 } 1730 }); 1731 } 1732 } 1733 1734 if (cartSummary.suptotal + cartSummary.rxputotal >= 75) { 1735 cartSummary.qualbonusnum += 1; 1736 } 1737 1738 if (cartSummary.suptotal + cartSummary.rxputotal >= 200) { 1739 cartSummary.qualbonusnum += 2; 1740 } 1741 1742 if (cartSummary.hasprogram == true) { 1743 cartSummary.qualbonusnum += 1; 1744 } 1745 1746 if (cartSummary.programnum >= 2) { 1747 cartSummary.qualbonusnum += 2; 1748 } 1749 1750 cartSummary.qualbonusnum = Math.min(cartSummary.qualbonusnum, 3); 1751 1752 if (cartSummary.qualbonusnum == 1 && cartSummary.bonusnum < 1) { 1753 // bonuspopup() 1754 } 1755 1756 if (cartSummary.qualbonusnum >= 2 && (cartSummary.bonusnum < 3)) { 1757 // bonuspopup(true); 1758 } 1759 1760 // if (cartSummary.programnum == 1 && (cartSummary.bonusnum > 1)) { 1761 // let bonusnum = cartSummary.bonusnum; 1762 // for (var i = 0; i < cart.items.length; i++) { 1763 // if (cartSummary.bonusnum != 1 && bonusOptions.includes(cart.items[i].item_id) && (cart.items[i].item_id != 'AX-WOLV' || cart.items[i].item_id == 'AX-TACTX')) { 1764 // cart.items[i].quantity = 0; 1765 // itemInfo = { 1766 // 'item_id': cart.items[i].item_id, 1767 // 'quantity': 0 1768 // }; 1769 // } 1770 // bonusnum--; 1771 // } 1772 // UC.updateCartItems(cart, itemInfo); 1773 // UC.postCart(cart, function (updatedCart, errors) { 1774 // if (errors.length > 0) { 1775 // if (errors[0].includes("backorder")) { 1776 // axupdateSnapshotItems(updatedCart); 1777 // } else { 1778 // console.log(errors); 1779 // AX.modal.show('#axModal', { 1780 // content: '<div class="ax-modal-error">' + errors[0] + '</div>' 1781 // }); 1782 // } 1783 // } else { 1784 // axupdateSnapshotItems(updatedCart); 1785 // } 1786 // console.log(updatedCart); 1787 1788 // // jQuery(document).trigger('updated.ax.cart', updatedCart); 1789 // }); 1790 // return; 1791 // } 1792 1793 // if ((cartSummary.suptotal < 2 && cartSummary.hasprogram == false) && cartSummary.hasbonus == true) { 1794 // for (var i = 0; i < cart.items.length; i++) { 1795 // if (bonusOptions.includes(cart.items[i].item_id) && (cart.items[i].item_id != 'AX-WOLV' || cart.items[i].item_id == 'AX-TACTX')) { 1796 // cart.items[i].quantity = 0; 1797 // itemInfo = { 1798 // 'item_id': cart.items[i].item_id, 1799 // 'quantity': 0 1800 // }; 1801 // } 1802 // } 1803 // UC.updateCartItems(cart, itemInfo); 1804 // UC.postCart(cart, function (updatedCart, errors) { 1805 // if (errors.length > 0) { 1806 // if (errors[0].includes("backorder")) { 1807 // axupdateSnapshotItems(updatedCart); 1808 // } else { 1809 // console.log(errors); 1810 // AX.modal.show('#axModal', { 1811 // content: '<div class="ax-modal-error">' + errors[0] + '</div>' 1812 // }); 1813 // } 1814 // } else { 1815 // axupdateSnapshotItems(updatedCart); 1816 // } 1817 // console.log(updatedCart); 1818 1819 // // jQuery(document).trigger('updated.ax.cart', updatedCart); 1820 // }); 1821 // return; 1822 // } 1823 1824 var changed = 0, 1825 htmltouse = ''; 1826 if (cartSummary.currentpowerups >= 2 || cartSummary.rcurrentpowerups >= 2) { 1827 let upgradestodo = 0, 1828 recurringpowerup = false; 1829 if (cartSummary.rcurrentpowerups >= 2) { 1830 recurringpowerup = true; 1831 upgradestodo = Math.floor(cartSummary.rcurrentpowerups / 2); 1832 } else { 1833 upgradestodo = Math.floor(cartSummary.currentpowerups / 2); 1834 } 1835 1836 whatupgrades = []; 1837 if (cartSummary.RXAA == true || cartSummary.RXAAR == true) { 1838 if (cartSummary.powerupskus["RX-AALPHA"] >= 2 || cartSummary.powerupskus["RXPU-APH"] >= 2 || cartSummary.rpowerupskus["RXPU-APH-R"] >= 2 || cartSummary.rpowerupskus["RX-AALPHA-R"] >= 2) { 1839 whatupgrades.push("APH2"); 1840 } else { 1841 whatupgrades.push("APH"); 1842 } 1843 } 1844 1845 if (cartSummary.RXM == true || cartSummary.RXMR == true) { 1846 if (cartSummary.powerupskus["RX-MECH"] >= 2 || cartSummary.powerupskus["RXPU-MCX"] >= 2 || cartSummary.rpowerupskus["RXPU-MCX-R"] >= 2 || cartSummary.rpowerupskus["RX-MECH-R"] >= 2) { 1847 whatupgrades.push("MCX2"); 1848 } else { 1849 whatupgrades.push("MCX"); 1850 } 1851 } 1852 1853 if (cartSummary.RXO == true || cartSummary.RXOR == true) { 1854 if (cartSummary.powerupskus["RX-OMEGA"] >= 2 || cartSummary.powerupskus["RXPU-OM3"] >= 2 || cartSummary.rpowerupskus["RXPU-OM3-R"] >= 2 || cartSummary.rpowerupskus["RX-OMEGA-R"] >= 2) { 1855 whatupgrades.push("OM32"); 1856 } else { 1857 whatupgrades.push("OM3"); 1858 } 1859 } 1860 1861 // Build the sku to use 1862 // TEMPORARILY OFF due to new discount tiers. 1863 if (upgradestodo >= 1 && false) { 1864 htmltouse += "<style>#myModal .powerup_sel_right { max-height: unset;display:flex;}#myModal .sglplusimg {width: 150px;}#myModal .popup_powerup_title {color: #4a4a4a;font-weight: 900;font-size: 18px;line-height: 1.1em;}#myModal .powerup_bottle_label {color: #4a4a4a;font-size: 13px;font-weight: 100;}#myModal .powerup {max-width: unset;width: 100%;float: none;}button.selectpowerup {background: #000;color: #fff;padding: 5px 15px; min-width: 105px; text-transform: uppercase; border: none;border-radius: 3px;margin: 10px 0;cursor:pointer;}#myModal .powerupsubhead {margin: 0; text-transform: uppercase;font-size: 23px;}#myModal .powerupmainhead { margin: 0; line-height: 1;font-weight: 600;font-size: 18px;text-transform: uppercase;}#myModal .modal-content {max-width: 490px;}#myModal .powerup_content {padding: 13px 0 0;}@media(max-width:768px){#myModal .powerupsubhead {font-size: 18px;margin: 0 0 10px;}#myModal .powerupmainhead {font-size: 16px;}#myModal .sglplusimg {width: 80px;}}</style>"; 1865 htmltouse += "<div class='popuppowerup'>"; 1866 htmltouse += "<h3 class='powerupmainhead' style='color: #000'>You are eligible to get 3 for 2!</h3><h3 class='powerupsubhead' style='color: var(--brand-red)'>Select your FREE supplement below</h3>"; 1867 htmltouse += `<div class="powerups"> 1868 <div class="powerup_header primary-color-bg"> 1869 1870 <div class="clearfix"></div>
1871 </div> 1872 <div class="powerup_sel_right"> 1873 <div class="powerup "> 1874 <div class="power_mech_content powerup_content"><img loading="lazy" class="sglplusimg" src="/images/supplements/RX-MECH.jpg" alt="MECHAN-X Joint Recovery Formula supplement" width="80"> 1875 <div class="popup_powerup_title">MECHAN-X</div> 1876 <div class="powerup_bottle_label">JOINT RECOVERY</div> 1877 </div> 1878 <div class="powerup_sel_wrap power_mech_qty"> 1879 <button class="selectpowerup" data-powersku="MCX" data-existingpower="`+ whatupgrades.toString() + `" onclick="changepowerup('MCX','` + whatupgrades.toString() + `', ` + recurringpowerup + `)">SELECT</button> 1880 </div> 1881 1882 </div> 1883 <div class="powerup "> 1884 <div class="power_omega_content powerup_content"><img loading="lazy" class="sglplusimg" src="/images/supplements/RX-OMEGA.jpg" alt="Doctor C's Omega-3 Fish Oil supplement" width="80"> 1885<div class="popup_powerup_title">DR. C'S</div> 1886 <div class="powerup_bottle_label">MUSCLE RECOVERY</div> 1887 </div> 1888 <div class="powerup_sel_wrap power_mech_qty"> 1889 <button class="selectpowerup" data-powersku="OM3" data-existingpower="`+ whatupgrades.toString() + `" onclick="changepowerup('OM3','` + whatupgrades.toString() + `', ` + recurringpowerup + `)">SELECT</button> 1890 </div> 1891 1892 </div> 1893 <div class="powerup"> 1894 <div class="power_aalpha_content powerup_content"><img loading="lazy" class="sglplusimg" src="/images/supplements/RX-AALPHA.jpg" alt="AALPHA BCAA's muscle building supplement" width="80"> 1895 <div class="popup_powerup_title">AALPHA</div> 1896 <div class="powerup_bottle_label">MUSCLE GROWTH</div> 1897 </div> 1898 <div class="powerup_sel_wrap power_mech_qty"> 1899 <button class="selectpowerup" data-powersku="APH" data-existingpower="`+ whatupgrades.toString() + `" onclick="changepowerup('APH','` + whatupgrades.toString() + `', ` + recurringpowerup + `)">SELECT</button> 1900 </div> 1901 1902 </div> 1903 1904 </div> 1905 </div>`; 1906 htmltouse += "</div>"; 1907 jQuery("#myModal").find(".modal-content").html(htmltouse); 1908 jQuery("#myModal").show(); 1909 1910 } 1911 } 1912 1913 cartdisplay(cart); 1914 1915 jQuery(document).trigger('updated.ax.cart', cart); 1916} 1917 1918 1919/* --------------- */ 1920/* SYNC CART */ 1921/* --------------- */ 1922 1923// Set the name of the hidden property and the change event for visibility 1924var tabHiddenEventName, tabVisibilityChangeEvent; 1925if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support 1926 tabHiddenEventName = "hidden"; 1927 tabVisibilityChangeEvent = "visibilitychange"; 1928} else if (typeof document.msHidden !== "undefined") { 1929 tabHiddenEventName = "msHidden"; 1930 tabVisibilityChangeEvent = "msvisibilitychange"; 1931} else if (typeof document.webkitHidden !== "undefined") { 1932 tabHiddenEventName = "webkitHidden"; 1933 tabVisibilityChangeEvent = "webkitvisibilitychange"; 1934} 1935 1936// If the tab/page is visible after being hidden, ping UC and sync with fresh cart data. 1937function syncCart() { 1938 if (!document[tabHiddenEventName]) { 1939 try { 1940 UC.getCart(function (cart) { 1941 axupdateSnapshotItems(cart); 1942 }, false); 1943 } catch (err) { 1944 console.error('[AX Cart] Error sync\'ing cart data.', err); 1945 } 1946 } 1947} 1948 1949if (typeof document.addEventListener !== "undefined" && tabHiddenEventName !== undefined) { 1950 document.addEventListener(tabVisibilityChangeEvent, syncCart, false); 1951} 1952 1953function checkCurrentPromo() { 1954 try { 1955 UC.getCart(function (cart) { 1956 if (cart.items.length > 0) { 1957 cart.checkout.custom_field7 = ''; 1958 1959 var msrp = 0; 1960 var salesprice = 0; 1961 var totalitems = 0; 1962 var tempmsrp = 0; 1963 var discounts = 0; 1964 var recommended = ""; 1965 var splitSku; 1966 var backorderText; 1967 var powerUpDate = "1/01/2000"; 1968 var hassupplements = false; 1969 1970 let supplementtotal = 0, 1971 discountsupptotal = 0; 1972 1973 let skusincart = [], 1974 suppsincart = []; 1975 1976 // Calculate the total for supplements 1977 for (var i = 0; i < cart.items.length; i++) { 1978 supplementtotal = supplementtotal + cart.items[i].unit_cost.localized; 1979 discountsupptotal = discountsupptotal + cart.items[i].unit_cost_with_discount.localized; 1980 suppsincart.push(cart.items[i].item_id); 1981 skusincart.push(cart.items[i].item_id); 1982 } 1983 calculatediscount(supplementtotal, discountsupptotal, skusincart, suppsincart, cart.summary.subtotal.localized, cart.summary.subtotal_with_discount.localized); 1984 } 1985 }); 1986 } catch (err) { 1987 console.error('[AX Cart] Error sync\'ing cart data.', err); 1988 } 1989} 1990 1991function calculatediscount(supplementtotal, discountsupptotal, skusincart, suppsincart, subtotalnodiscount, subtotaldiscount) { 1992 let currentsup;
1993 if (jQuery(".payprice").length > 0) { 1994 currentsup = jQuery(".payprice").attr("data-suppsku").toUpperCase(); 1995 } 1996 1997 // If any supplements are found do logic to figure out the discount to be applied 1998 if (suppsincart.length > 0) { 1999 var temptotal = subtotalnodiscount; 2000 2001 // Figure out the discount to apply 2002 discountapplied = 0; 2003 nextDiscount = 0; 2004 nexttext = ""; 2005 freeship = false; 2006 2007 if (discountTiers[Object.keys(discountTiers).length].price < supplementtotal) { 2008 nextDiscount = 999; 2009 discountapplied = discountTiers[Object.keys(discountTiers).length].discount; 2010 } else { 2011 for (i = 1; i <= Object.keys(discountTiers).length; i++) { 2012 if (discountTiers[i].price <= supplementtotal && discountapplied <= discountTiers[i].discount) { 2013 discountapplied = discountTiers[i].discount; 2014 } 2015 if (supplementtotal < discountTiers[i].price) { 2016 nextDiscount = discountTiers[i].price; 2017 nexttext = discountTiers[i].text; 2018 freeship = discountTiers[i].freeship; 2019 break; 2020 } 2021 } 2022 } 2023 updatediscounttext(nextDiscount, temptotal, nexttext, freeship); 2024 } 2025} 2026 2027function updatediscounttext(nextDiscount, supplementtotal, nexttext, freeship) { 2028 if (jQuery(".payprice").length > 0) { 2029 let amountmissing = nextDiscount - supplementtotal, 2030 fixednum = amountmissing.toString(10).substr(0, 2), 2031 currentsup = jQuery(".payprice").attr("data-suppsku").toLowerCase(), 2032 returnhtml = ''; 2033 const rxArray = JSON.parse(jQuery("#rx_products_json").text()); 2034 2035 if (nextDiscount == 999) { 2036 returnhtml = "You are saving 15% on supplements today!"; 2037 } else if (rxArray[currentsup].price >= amountmissing) { 2038 returnhtml = nexttext; 2039 } else { 2040 returnhtml = "You are saving " + discountapplied + "% on supplements today!"; 2041 } 2042 2043 if (freeship) { 2044 jQuery(".free-shipping-banner-wrapper2").show(); 2045 } 2046 else { 2047 jQuery(".free-shipping-banner-wrapper2").hide(); 2048 } 2049 2050 } 2051} 2052 2053function updatesupplementPrice(discountapplied, popup = false) { 2054 let str = '', 2055 matches, 2056 selector = ''; 2057 2058 // If there are more than one price mainly for athleanrx page 2059 if (jQuery(".payprice").length == 1 || popup == true) { 2060 if (popup == true) { 2061 selector = jQuery(".popup-payprice"); 2062 2063 } else { 2064 selector = jQuery(".payprice"); 2065 } 2066 supsku = jQuery(".payprice").attr("data-suppsku"); 2067 2068 str = selector.text(); 2069 2070 matches = str.match(/(\d+)/), 2071 tempdiscount = 0; 2072 if (matches) { 2073 if (autopayselected) { 2074 tempdiscount = 5; 2075 if (jQuery(".plussh").length > 0) { 2076 jQuery(".plussh").html("<span style='margin-right: -20px;font-size:0.93em;'>Free Shipping</span>"); 2077 } 2078 } else { 2079 jQuery(".plussh").html("PLUS S&H"); 2080 } 2081 selector.attr("data-discount", tempdiscount); 2082 if (rxPrices != undefined && rxPrices[supsku] != undefined && rxPrices[supsku + "-R"] != undefined && autopayselected) { 2083 baseprice = rxPrices[supsku + "-R"]; 2084 tempdiscount = 0; 2085 } else { 2086 baseprice = Number(selector.attr("data-baseprice")); 2087 } 2088 2089 if (tempdiscount == 0) { 2090 number = baseprice; 2091 } else { 2092 number = baseprice - (baseprice * (tempdiscount / 100)); 2093 } 2094 2095 decimal = (number.toString(10)).split(".")[1]; 2096 number = Math.trunc(number); 2097 newdisplayprice = "<sup>$</sup>" + number.toString(10) + ".<sup>" + decimal.substr(0, 2) + "</sup>"; 2098 } 2099 } 2100} 2101 2102jQuery(document).on("click", "input[name='autoshipcheckbox']", function (e) { 2103 let itemsku = $(e.currentTarget).attr("data-itemsku"), 2104 itemquantity = $(e.currentTarget).attr("data-itemquantity"), 2105 recurring = !$(e.currentTarget).is(":checked"), 2106 position = $(e.currentTarget).attr("data-itemposition"); 2107 if (recurring) { 2108 $(e.currentTarget).siblings(".autoshiptext").html("<span>AUTOSHIP</span>"); 2109 } else { 2110 $(e.currentTarget).siblings(".autoshiptext").html('<img loading="lazy" class="autoshiptextlogo" alt="Auto Ship" src="/wp-content/themes/engage-ax/checkout/images/autoship-logo.png"><span style="color:var(--price);">AUTOSHIP</span><span class="savedfive">YOU SAVED 5%</span>'); 2111 } 2112 jQuery(e.currentTarget).parents(".ax-cart-item.item.js-snapshot-item").addClass("loadingitem"); 2113 changetorecurring(itemsku, recurring, position, itemquantity); 2114}); 2115 2116function changetorecurring(itemvalue, recurring = false, position, quantity) { 2117 UC.getCart(function (cart) { 2118 let itemInfo = {}; 2119 if (cart.items) { 2120 tempitem = cart.items[position - 1].item_id; 2121 if (tempitem.startsWith(itemvalue)) { 2122 if (recurring == 'false' || recurring == false) { 2123 if (cart.items[position - 1].item_id.endsWith("-R") || cart.items[position - 1].item_id.endsWith("-r")) { 2124 tempstring = cart.items[position - 1].item_id; 2125 } else { 2126 tempstring = cart.items[position - 1].item_id + "-R"; 2127 } 2128 itemInfo = { 2129 'item_id': tempstring, 2130 'quantity': cart.items[position - 1].quantity, 2131 'auto_order_schedule': 'Every 28 Days' 2132 }; 2133 cart.items[position - 1].quantity = 0; 2134 } else { 2135 if (cart.items[position - 1].item_id.endsWith("-R") || cart.items[position - 1].item_id.endsWith("-r")) { 2136 tempstring = cart.items[position - 1].item_id.substring(0, cart.items[position - 1].item_id.length - 2); 2137 } else { 2138 tempstring = cart.items[position - 1].item_id; 2139 } 2140 2141 itemInfo = { 2142 'item_id': tempstring, 2143 'quantity': cart.items[position - 1].quantity, 2144 'auto_order_schedule': 'None' 2145 }; 2146 cart.items[position - 1].quantity = 0; 2147 cart.items[position - 1].auto_order_schedule = 'None'; 2148 } 2149 UC.updateCartItems(cart, itemInfo); 2150 } 2151 2152 UC.postCart(cart, function (updatedCart, errors) { 2153 if (errors.length > 0) { 2154 if (errors[0].includes("backorder")) { 2155 axupdateSnapshotItems(updatedCart); 2156 } else { 2157 console.error('[AX CART]', errors); 2158 AX.modal.show('#axModal', { 2159 content: '<div class="ax-modal-error">' + errors[0] + '</div>' 2160 }); 2161 } 2162 } else { 2163 axupdateSnapshotItems(updatedCart); 2164 } 2165 }); 2166 } 2167 }); 2168} 2169 2170jQuery(document).on("click", ".autoshipinfo", function (e) { 2171 if (jQuery("#myModal").is(":visible")) { 2172 jQuery("#myModal").fadeOut(); 2173 } else {
2174 jQuery(".modal-content").html("<style>.autoshippopupout {color: #fff;background-image: url('/images/autoship/autoship-bg.png');background-position: bottom;background-size: auto;background-repeat: no-repeat;}#myModal .modal-content { padding: 0 !important; max-width: 740px !important; background: #000; border: none !important;}.autoshipinner { padding-bottom: 100px; max-width: 470px; margin: 0 auto;}.autoshipinner ul { text-align: left; font-size: 22px; line-height: 1.1; font-weight: 100;}.autoshipinner li { padding: 0 0 20px;}h3.autoshipsubhead { font-size: 38px; line-height: 1; font-weight: 900; text-transform: uppercase;}h4.autoshipsub { background: #cc0000; padding: 4px 0; text-transform: uppercase; font-size: 27px; margin: 0 0 25px; }#myModal .autoshipinner .close { background: #fff !important; color: #000; padding: 1px 5px; border-radius: 50%;font-size: 16px;}.deeperinfo a {color: #fff;}@media(max-width:768px){h3.autoshipsubhead {font-size: 28px;}h4.autoshipsub { font-size: 21px;}.autoshipinner ul { font-size: 16px;}}</style><div class='autoshippopupout'><div class='autoshipinner'>\ 2175 <h2 class='autoshiphead'><img loading='lazy' class='autoshiplogo' alt='Auto Ship' src='/images/autoship/autoship-logo-white.png' style='width: 26px;'>AX AUTOSHIP</h2><div class='close'>X</div>\ 2176 <h3 class='autoshipsubhead'>YOUR GAINS NEVER CAME THIS EASY!</h3>\ 2177 <h4 class='autoshipsub'>GET EVEN BIGGER DISCOUNTS</h4>\ 2178 <ul>\ 2179 <li>Save an additional 5% each month on autoshipped items</li>\ 2180 <li>Receive FREE shipping on your entire order</li>\ 2181 <li>Change or cancel at any time</li>\ 2182 <li>Easy RX refills to keep the gains coming</li>\ 2183 </ul><div class='deeperinfo'><a href='/ax-autoship-terms'>Click here for AX AUTOSHIP terms of use</a></div></div></div>"); 2184 jQuery("#myModal").fadeIn(); 2185 } 2186}); 2187 2188function ifhasAutoship() { 2189 if (skusincart != undefined) { 2190 for (i = 0; i < skusincart.length; i++) { 2191 if (skusincart[i].endsWith("-R")) { 2192 hasAutoship = true; 2193 return; 2194 } else { 2195 hasAutoship = false; 2196 } 2197 } 2198 } 2199} 2200 2201function changepowerup(powerupsku, existingsku, recurringpowerup, itemsincart = true) { 2202 2203 let existingpowerups = existingsku.split(","), 2204 removeskus = [], 2205 sku = 'RXPU-'; 2206 if (powerupsku == 'APH' && existingpowerups[0] == 'APH2') { 2207 sku += "APH3"; 2208 removeskus['RX-AALPHA'] = 2; 2209 } else if (powerupsku == 'OM3' && existingpowerups[0] == 'OM32') { 2210 sku += "OM33"; 2211 removeskus['RX-OMEGA'] = 2; 2212 } else if (powerupsku == 'MCX' && existingpowerups[0] == 'MCX2') { 2213 sku += "MCX3"; 2214 removeskus['RX-MECH'] = 2; 2215 } else if (existingpowerups[0] == 'APH2') { 2216 sku += "APH2-" + powerupsku; 2217 removeskus['RX-AALPHA'] = 2; 2218 } else if (powerupsku == 'APH' && (existingpowerups.includes("MCX2") || existingpowerups.includes("OM32"))) { 2219 sku += powerupsku + '-' + existingpowerups[0]; 2220 if (existingpowerups[0] == "OM32") { 2221 removeskus['RX-OMEGA'] = 2; 2222 } else { 2223 removeskus['RX-MECH'] = 2; 2224 } 2225 } else if (existingpowerups[0] == "MCX2") { 2226 removeskus['RX-MECH'] = 2; 2227 sku += existingpowerups[0] + '-' + powerupsku; 2228 } else if (powerupsku == 'MCX' && existingpowerups[0] == "OM32") { 2229 removeskus['RX-OMEGA'] = 2; 2230 sku += powerupsku + '-' + existingpowerups[0]; 2231 } else if (existingpowerups.length >= 2) { 2232 if (existingpowerups[0] == 'APH' || existingpowerups[1] == 'APH' || powerupsku == 'APH') { 2233 if ((existingpowerups[0] == 'APH' || existingpowerups[1] == 'APH') && powerupsku == 'APH') { 2234 sku += 'APH2'; 2235 } else { 2236 sku += 'APH'; 2237 } 2238 } 2239 if ((sku.length == 8 || sku.length == 9) && sku.slice(-1) != '-') { 2240 sku += '-'; 2241 } 2242 if (existingpowerups[0] == 'MCX' || existingpowerups[1] == 'MCX' || powerupsku == 'MCX') { 2243 if ((existingpowerups[0] == 'MCX' || existingpowerups[1] == 'MCX') && powerupsku == 'MCX') { 2244 sku += 'MCX2'; 2245 } else { 2246 sku += 'MCX'; 2247 } 2248 } 2249 if ((sku.length == 8 || sku.length == 12 || sku.length == 9) && sku.length != 13 && sku.slice(-1) != '-') { 2250 sku += '-'; 2251 } 2252 if (existingpowerups[0] == 'OM3' || existingpowerups[1] == 'OM3' || powerupsku == 'OM3') { 2253 if ((existingpowerups[0] == 'OM3' || existingpowerups[1] == 'OM3') && powerupsku == 'OM3') { 2254 sku += 'OM32'; 2255 } else { 2256 sku += 'OM3'; 2257 } 2258 } 2259 if (existingpowerups[0] == 'APH' || existingpowerups[1] == 'APH') { 2260 removeskus['RX-AALPHA'] = 1; 2261 } 2262 if (existingpowerups[0] == 'MCX' || existingpowerups[1] == 'MCX') { 2263 removeskus['RX-MECH'] = 1; 2264 } 2265 if (existingpowerups[0] == 'OM3' || existingpowerups[1] == 'OM3') { 2266 removeskus['RX-OMEGA'] = 1; 2267 } 2268 2269 } 2270 jQuery("#myModal .modal-content").html(""); 2271 jQuery("#myModal").hide(); 2272 UC.getCart(function (cart) { 2273 if (itemsincart == true) { 2274 if (Object.keys(removeskus).length > 1) { 2275 for (i = 0; i < Object.keys(removeskus).length; i++) { 2276 for (l = 0; l < cart.items.length; l++) { 2277 recurringName = Object.keys(removeskus)[i] + "-R"; 2278 if ((recurringpowerup == true && cart.items[l].item_id == recurringName) || (cart.items[l].item_id == Object.keys(removeskus)[i])) { 2279 cart.items[l].quantity = cart.items[l].quantity - 1; 2280 }; 2281 } 2282 } 2283 } else { 2284 for (i = 0; i < cart.items.length; i++) { 2285 recurringName = Object.keys(removeskus)[0] + "-R"; 2286 if (recurringpowerup == true && cart.items[i].item_id == recurringName) { 2287 cart.items[i].quantity = cart.items[i].quantity - 2; 2288 } else if (cart.items[i].item_id == Object.keys(removeskus)[0]) { 2289 cart.items[i].quantity = cart.items[i].quantity - 2; 2290 }; 2291 } 2292 } 2293 } 2294 if (recurringpowerup == true) { 2295 itemInfo = { 2296 'item_id': sku + "-R", 2297 'quantity': 1, 2298 'auto_order_schedule': 'Every 28 Days' 2299 }; 2300 } else { 2301 itemInfo = { 2302 'item_id': sku, 2303 'quantity': 1, 2304 'auto_order_schedule': 'None' 2305 }; 2306 } 2307 cartvalue = cart.summary.subtotal.value + parseInt(98.98); 2308 url = jQuery(location).attr('href') 2309 gname = ''; 2310 if(sku === 'RXPU-APH-OM32'){ 2311 gname = "RX Power Pack - AALPHA | 2 OMEGA-3'S" 2312 }else if(sku === 'RXPU-APH2-OM3'){ 2313 gname = "RX Power Pack - 2 AALPHA'S | OMEGA-3'S" 2314 }else if(sku === 'RXPU-APH-MCX-OM3'){ 2315 gname = "RX Power Pack - AALPHA | MECHAN-X | OMEGA-3'S" 2316 }else if(sku === 'RXPU-APH3'){ 2317 gname = "RX Power Pack - 3 AALPHA BCAA's" 2318 }else if(sku === 'RXPU-OM33'){ 2319 gname = "RX Power Pack - 3 DR C'S OMEGA-3'S" 2320 }else if(sku === 'RXPU-APH2-MCX'){ 2321 gname = "RX Power Pack - MECHAN-X | 2 OMEGA-3'S" 2322 }else if(sku === 'RXPU-MCX2-OM3'){ 2323 gname = "RX Power Pack - 2 MECHAN-X | OMEGA-3'S" 2324 }else if(sku === 'RXPU-MCX3'){ 2325 gname = "RX Power Pack - 3 MECHAN-X Joint Formula" 2326 } 2327 ccLayer = window.ccLayer || {}; 2328 // try { 2329 // ccLayer.push({ 2330 // ccEvent: 'miniCartViewed', 2331 // src: 'custom', 2332 // items: [ // all the items present in the cart 2333 // { 2334 // id: sku, //id of prouct 2335 // name: gname, //name of product present in cart 2336 // price: 99.98, //price of product 2337 // currency: 'USD', //currency 2338 // quantity: 1, //quantity of product present in cart 2339 // url: url //url of product page 2340 // } 2341 // ], 2342 // currency: 'USD', //currency 2343 // total: cartvalue, //cart total including shipping, taxes 2344 // }); 2345 // } catch(e) { } 2346 let kItem = { 2347 "ProductID": sku, 2348 "SKU": sku, 2349 "URL": url, 2350 "Price": 99.98 2351 } 2352 2353 if (typeof _learnq !== 'undefined') { 2354 _learnq.push(['track', 'Added to Cart', kItem]); 2355 } 2356 2357 if (typeof gtag !== 'undefined') { 2358 gtag('event', 'add_to_cart', { 2359 "items": [ 2360 { 2361 "item_id": sku, 2362 "item_name": gname, 2363 "list_name": "AX Supplement", 2364 "item_brand": "AX", 2365 "item_category": "Physical", 2366 "list_position": 1, 2367 "quantity": 1, 2368 "price": 99.98 2369 } 2370 ] 2371 }); 2372 } 2373 2374 2375 UC.updateCartItems(cart, itemInfo); 2376 UC.postCart(cart, function (updatedCart, errors) { 2377 if (itemsincart == true) { 2378 if (errors.length > 0) { 2379 if (errors[0].includes("coupon")) { 2380 AX.modal.hide('#axModal'); 2381 axupdateSnapshotItems(updatedCart); 2382 } else if (errors[0].includes("backorder")) { 2383 axupdateSnapshotItems(updatedCart); 2384 } else { 2385 AX.modal.show('#axModal', { 2386 content: '<div class="ax-modal-error">' + errors[0] + '</div>' 2387 }); 2388 2389 console.error('[AX CART]', errors); 2390 } 2391 } else { 2392 AX.modal.hide('#axModal'); 2393 jQuery('.ult-overlay.content-xx2.supp-pop-modal').removeClass(" ult-open"); 2394 axupdateSnapshotItems(updatedCart); 2395 UCWP.cartSnapShot.showSnapshot(); 2396 } 2397 } 2398 }); 2399 }); 2400} 2401 2402function promoPercent(supptotal, cartSubTotal) { 2403 if (0 == 0) { 2404 let currentprice = 0, 2405 htmltext = '', 2406 nextpromo = ''; 2407 for (let i = 2; i <= Object.keys(discountTiers).length; i++) { 2408 if (i == Object.keys(discountTiers).length && supptotal > discountTiers[i].promptprice) { 2409 currentprice = discountTiers[i].promptprice; 2410 htmltext = 'You are saving 15% off all your supplements!'; 2411 nextpromo = 100; 2412 break; 2413 } 2414 else if (supptotal > discountTiers[i].promptprice && supptotal <= discountTiers[i + 1].showprice) { 2415 currentprice = discountTiers[i].promptprice; 2416 htmltext = 'You are saving ' + discountTiers[i].discount + '% on supplements today!'; 2417 nextpromo = Math.round((supptotal / discountTiers[i].promptprice) * 100); 2418 break; 2419 } else if (supptotal > discountTiers[i].promptprice && supptotal < discountTiers[i + 1].promptprice && discountTiers[i + 1].showprice <= supptotal) { 2420 currentprice = discountTiers[i].promptprice; 2421 missingvalue = Math.round(discountTiers[i + 1].promptprice - supptotal); 2422 htmltext = 'You are only $' + missingvalue + ' from ' + discountTiers[i + 1].discount + '% off supplements.'; 2423 nextpromo = Math.round((supptotal / discountTiers[i + 1].promptprice) * 100); 2424 break; 2425 } else if (supptotal < discountTiers[i].promptprice && i == 2 && discountTiers[i].showprice <= supptotal) { 2426 freeShip = ''; 2427 if (cartSubTotal < 75) { 2428 freeShip = 'FREE shipping* + '; 2429 } 2430 currentprice = discountTiers[i].promptprice; 2431 missingvalue = Math.round(discountTiers[i].promptprice - supptotal); 2432 htmltext = 'You are only $' + missingvalue + ' from ' + freeShip + discountTiers[i].discount + '% off supplements.'; 2433 nextpromo = Math.round((supptotal / discountTiers[i].promptprice) * 100); 2434 break; 2435 } 2436 } 2437 if (currentprice == 0) { 2438 jQuery(".checkout__summary-free-shipping-widget").hide(); 2439 } else { 2440 jQuery(".not-qualified-label").html(htmltext); 2441 jQuery(".free-shipping-progress-bar").css("width", nextpromo + "%"); 2442 jQuery(".checkout__summary-free-shipping-widget").show(); 2443 } 2444 } 2445} 2446 2447function bonuspopup(twobonuses = false) { 2448 let returnhtml = ""; 2449 var poppedOnce = sessionStorage['bonusPoppedOnce']; 2450 2451 if (poppedOnce != "") { 2452 return; 2453 } 2454 2455 const bonusOptions = { 2456 armoredabs: { 2457 sku: 'ATX-ARMOR-ABS', 2458 title: 'Armored Abs', 2459 description: 'This complete AB Training program will get you that ripped 6-Pack the ATHLEAN-X way. One of our newer ab bonuses featuring unique exercises, strategies, and tactics designed for one purpose, build a rock solid set of 6-Pack abs!', 2460 image: '/wp-content/themes/engage-ax/images/bonuses/ARMORED-ABS-COVER.png', 2461 focus: 'Abs', 2462 equipment: 'None', 2463 duration: '6-weeks', 2464 frequency: '3x/week', 2465 experience: 'Beg-Adv', 2466 condition: 'N/A' 2467 }, 2468 ultabs: { 2469 sku: 'ATX-ULT-ABS', 2470 title: 'Ultimate Abs', 2471 description: 'Take your ab definition, strength and core stability to another level with this 6-Week specialized ab training program. ',
2472 image: '/wp-content/themes/engage-ax/images/bonuses/Ultimate-Abs-Cover.png', 2473 focus: 'Abs', 2474 equipment: 'Weights (Dumbbells and Plates), Physioball, Pullup Bar, adjustable bench, resistance band, medicine ball.', 2475 duration: '6-weeks', 2476 frequency: '4-5x/week', 2477 experience: 'Beg-Adv', 2478 condition: 'N/A' 2479 }, 2480 bane: { 2481 sku: 'ATX-BANE', 2482 title: 'Train Like Bane', 2483 description: 'This complete 4 week workout program will help you develop that Bane look... powerful, intimidating, functional pure mass built the ATHLEAN-X way.', 2484 image: '/wp-content/themes/engage-ax/images/bonuses/BANE.png', 2485 focus: 'Mass Building', 2486 equipment: 'Barbell, pullup bar, bench, dumbbells, resistance band.', 2487 duration: '4-weeks', 2488 frequency: '5 Days Split', 2489 experience: 'Int-Adv', 2490 condition: 'No' 2491 }, 2492 dragon: { 2493 sku: 'ATX-DRAGON', 2494 title: 'Bruce Lee\'s Dragon', 2495 description: 'A complete 4 week training program inspired by the legendary martial arts master Bruce Lee. Turn your attention to speed, performance and explosivity. The look of a legend combined with the moves of a master!', 2496 image: '/wp-content/themes/engage-ax/images/bonuses/DRAGON-COVER.png', 2497 focus: 'Muscle building, Athleticism', 2498 equipment: 'Barbell, pullup bar, bench, dumbbells, resistance band or cable machine.', 2499 duration: '4-weeks', 2500 frequency: '5 Days Split', 2501 experience: 'Int-Adv', 2502 condition: 'Yes' 2503 }, 2504 oldschool: { 2505 sku: 'ATX-IRON-B', 2506 title: 'Old School Iron', 2507 description: 'With Old School Iron you\'ll train using the tried and true methods, techniques and protocols of the men who defined what it meant to be strong, jacked and absolutely shredded. This is the 30-day bonus that launched the full 90-day program.', 2508 image: '/wp-content/themes/engage-ax/images/bonuses/OSIB-cover.png', 2509 focus: 'Mass building, Strength', 2510 equipment: ' Barbell, pullup bar, bench, dumbbells, resistance band or cable machine', 2511 duration: '4-weeks', 2512 frequency: '5 Days split', 2513 experience: 'Int-Adv', 2514 condition: 'No' 2515 }, 2516 ironc: { 2517 sku: 'ATX-IRONC', 2518 title: 'Iron Curtain', 2519 description: 'Unlock the secret size and strength protocols of Eastern Bloc training to reach new limits of raw strength and size. ', 2520 image: '/wp-content/themes/engage-ax/images/bonuses/IRON-CURTAIN-COVER.png', 2521 focus: 'Progressive Strength', 2522 equipment: 'Weights (Dumbbells and Plates), Bench, Pullup Bar.', 2523 duration: '4-weeks', 2524 frequency: '4 days/week', 2525 experience: 'Int-Adv', 2526 condition: 'N/A' 2527 }, 2528 xt2: { 2529 sku: 'ATX-XT2ABS', 2530 title: 'X-Tinction Abs', 2531 description: 'Featuring a completely unique approach to core training X-Tinction abs has remained one of our most popular bonuses to date. Not just for effectiveness but for it\'s non stop fun (if you like pain) and bare bones approach to ab training.', 2532 image: '/wp-content/themes/engage-ax/images/bonuses/Xtinction.png', 2533 focus: 'Abs', 2534 equipment: 'None', 2535 duration: '6-weeks', 2536 frequency: '5x/week', 2537 experience: 'Beg-Adv', 2538 condition: 'N/A' 2539 }, 2540 slashandburn: { 2541 sku: 'NXT-15', 2542 title: 'Slash and Burn', 2543 description: 'Muscle building at its most brutal, simple and effective. No pretense here, just the best muscle building exercises and a goal.', 2544 image: '/wp-content/themes/engage-ax/images/bonuses/Slash-and-Burn.png', 2545 focus: 'Hypertrophy', 2546 equipment: 'Barbell, pullup bar, bench, dumbbells, resistance bands.', 2547 duration: '4-weeks', 2548 frequency: '5 Days Split', 2549 experience: 'Int-Adv', 2550 condition: 'No' 2551 }, 2552 killswitch: { 2553 sku: 'NXT-18', 2554 title: 'Killswitch', 2555 description: 'Hypertrophy training that pairs protagonist and antagonist muscle groups for quick, effective hypertrophy workouts.', 2556 image: '/wp-content/themes/engage-ax/images/bonuses/Killswitch.png', 2557 focus: 'Hypertrophy', 2558 equipment: 'Barbell, pullup bar, bench, dumbbells, resistance bands.', 2559 duration: '4-weeks', 2560 frequency: '5 Days Split', 2561 experience: 'Int-Adv', 2562 condition: 'Yes' 2563 }, 2564 aamuscle: { 2565 sku: 'ATX-AAMUSCLE-B', 2566 title: 'All American Muscle Bonus', 2567 description: 'Train like an All American Athlete to become the ultimate athlete without sacrificing strength and muscle mass.', 2568 image: '/wp-content/themes/engage-ax/images/bonuses/aamuscle.png', 2569 focus: 'Strength, Size, Athleticism', 2570 equipment: 'Weights (Dumbbells and Plates), Physioball, Resistance Band, Bench, Pullup Bar.', 2571 duration: '4-weeks', 2572 frequency: '6 days/week', 2573 experience: 'Beg-Adv', 2574 condition: 'Yes' 2575 }, 2576 criticalmass: { 2577 sku: 'ATX-MASS', 2578 title: 'Critical Mass', 2579 description: 'Build all new muscle mass with low volume, high intensity workouts with this 4-Week muscle building program.', 2580 image: '/wp-content/themes/engage-ax/images/bonuses/critical-mass.png', 2581 focus: 'Hypertrophy', 2582 equipment: 'Weights (Dumbbells and Plates), Cables, Bench, Pullup Bar.', 2583 duration: '4-weeks', 2584 frequency: '4 days/week', 2585 experience: 'Int-Adv', 2586 condition: 'N/A' 2587 }, 2588 maxfx: { 2589 sku: 'ATX-MAX-FX', 2590 title: 'Max F/X', 2591 description: 'Build muscle utilizing the minimal effective dose required to create new hypertrophy. ', 2592 image: '/wp-content/themes/engage-ax/images/bonuses/max-fx.jpg', 2593 focus: 'Hypertrophy', 2594 equipment: 'Weights (Dumbbells and Plates), Cables, Bench, Pullup Bar, Resistance Band.', 2595 duration: '4-weeks', 2596 frequency: '6 days/week', 2597 experience: 'Beg-Adv', 2598 condition: 'N/A' 2599 } 2600 }; 2601 2602 returnhtml = '<style>.bonuscontainers {\ 2603 display: flex;\ 2604 flex-wrap: wrap;\ 2605}\ 2606.bonussub {\ 2607 color: #ffcc00;\ 2608 font-weight: 900;\ 2609 text-transform: uppercase;\ 2610}\ 2611#myModal .modal-content {\ 2612 max-width: 400px;\ 2613background-color: #000;\ 2614padding: 0;\ 2615}\ 2616.bonusmoreinfo {\ 2617 text-align: left;\ 2618 padding: 20px 0 0 0;\ 2619 border-top: 1px solid;\ 2620 min-height: 250px;\ 2621}\ 2622h3.bonustitle {\ 2623 text-transform: uppercase;\ 2624}\ 2625.bonuscontain {\
2626 color:#fff;\ 2627 padding: 20px;\ 2628 box-sizing: border-box;\ 2629}\ 2630.bonuspositioner {\ 2631 max-width: 400px;\ 2632 position: relative;\ 2633 margin: auto;\ 2634}\ 2635.bonuscontain {\ 2636 display: none;\ 2637}\ 2638.prev, .next {\ 2639 cursor: pointer;\ 2640 position: absolute;\ 2641 top: 50%;\ 2642 width: auto;\ 2643 margin-top: -22px;\ 2644 padding: 16px;\ 2645 color: white;\ 2646 font-weight: bold;\ 2647 font-size: 18px;\ 2648 transition: 0.6s ease;\ 2649 border-radius: 0 3px 3px 0;\ 2650 user-select: none;\ 2651}\ 2652.next {\ 2653 right: 0;\ 2654 border-radius: 3px 0 0 3px;\ 2655}\ 2656.prev:hover, .next:hover {\ 2657 background-color: rgba(0,0,0,0.8);\ 2658}\ 2659.text {\ 2660 color: #f2f2f2;\ 2661 font-size: 15px;\ 2662 padding: 8px 12px;\ 2663 position: absolute;\ 2664 bottom: 8px;\ 2665 width: 100%;\ 2666 text-align: center;\ 2667}\ 2668.numbertext {\ 2669 color: #f2f2f2;\ 2670 font-size: 12px;\ 2671 padding: 8px 12px;\ 2672 position: absolute;\ 2673 top: 0;\ 2674}\ 2675.dot {\ 2676 cursor: pointer;\ 2677 height: 15px;\ 2678 width: 15px;\ 2679 margin: 0 2px;\ 2680 background-color: #bbb;\ 2681 border-radius: 50%;\ 2682 display: inline-block;\ 2683 transition: background-color 0.6s ease;\ 2684}\ 2685.bonuspop .active, .bonuspop .dot:hover {\ 2686 background-color: #717171;\ 2687}\ 2688.bonusdots{\ 2689 display:none;\ 2690}\ 2691.fade {\ 2692 -webkit-animation-name: fade;\ 2693 -webkit-animation-duration: 1.5s;\ 2694 animation-name: fade;\ 2695 animation-duration: 1.5s;\ 2696}\ 2697@-webkit-keyframes fade {\ 2698 from {opacity: .4}\ 2699 to {opacity: 1}\ 2700}\ 2701@keyframes fade {\ 2702 from {opacity: .4}\ 2703 to {opacity: 1}\ 2704}.bonusrightside {\ 2705 float: right;\ 2706}\ 2707.bonusfirst {\ 2708 display: flex;\ 2709}\ 2710.bonusrightside {\ 2711 text-align: left;\ 2712 padding: 0 10px;\ 2713}\ 2714.bonustitle {\ 2715 margin: 0;\ 2716}\ 2717img.bonusimg {\ 2718 border: 2px solid #fff;\ 2719 max-width: 150px;\ 2720 height: 100%;\ 2721 margin: 5px 0 0;\ 2722}\ 2723.bonusfirst {\ 2724 min-height: 250px;\ 2725}\ 2726p.bonuspara {\ 2727 font-size: 14px;\ 2728 color: #fff;\ 2729}.bonusbottom {\ 2730 display: flex;\ 2731 justify-content: center;\ 2732 flex: 1 1 33%;\ 2733 padding: 20px 0;\ 2734 border-top: 1px solid;\ 2735 margin: 0 auto;\ 2736}\ 2737button.bonusbuy.addbonus {\ 2738 background: #c40c11;\ 2739 color: #fff;\ 2740 border: none;\ 2741 padding: 10px 10px;\ 2742 display: inline-block;\ 2743 text-transform: uppercase;\ 2744 font-size: 14px;\ 2745 flex-grow: 1;\ 2746}\ 2747.bonusback, .bonusforward {\ 2748 min-width: 45px;\ 2749 min-height: 25px;\ 2750 background: #c40c11;\ 2751 display: flex;\ 2752 justify-content: center;\ 2753 align-items: center;\ 2754}\ 2755.bonusaction{\ 2756 cursor:pointer;\ 2757}\ 2758.bonusback {\ 2759 margin: 0 5% 0 0;\ 2760}\ 2761.bonusforward {\ 2762 margin: 0 0 0 5%;\ 2763}\ 2764.bonuspop {\ 2765 border-top: 20px solid #c50d12;\ 2766}\ 2767#myModal .close {\ 2768 line-height: 1em;\ 2769 position: absolute;\ 2770 right: -35px;\ 2771 top: -24px;\ 2772 color: #9e9e9e;\ 2773}\ 2774.topimg {\ 2775 max-width: 100%;\ 2776}\ 2777.moreInfoHeading {\ 2778 font-weight: 700;\ 2779 font-size: 22px;\ 2780 text-align: center;\ 2781}\ 2782.moreInfoText {\ 2783 text-align: center; \ 2784}\ 2785.moreInfoSubHeading {\ 2786 margin: 15px 0;\ 2787 text-align: center;\ 2788 font-size: 18px;\ 2789}\ 2790#keepShopping {\ 2791 BACKGROUND-COLOR: black;\ 2792 border: 1px white solid;\ 2793 padding: 7px;\ 2794 max-width: 200px;\ 2795 margin: 0 auto;\ 2796}\ 2797.viewBonus {\ 2798 padding: 10px;\ 2799 max-width: 200px;\ 2800 margin: 0 auto;\ 2801}\ 2802.bonuscount {\ 2803 color: white;\ 2804 font-size: 18px;\ 2805 margin: 0 0 20px 0;\ 2806}\ 2807 </style>'; 2808 returnhtml += '<div class="close">X</div>'; 2809 returnhtml += '<div class="bonuspop">'; 2810 returnhtml += '<div class="bonuspopinner">'; 2811 returnhtml += '<div class="bonuscontainers">'; 2812 returnhtml += '<div class="bonuspositioner">'; 2813 2814 returnhtml += '<div class="bonuscontain fade " style="display: block;">'; 2815 returnhtml += '<div class="bonusfirst"><img loading="lazy" class="topimg" src="/wp-content/themes/engage-ax/images/bonuses/xmass-bonus-pop-top-2.png" alt="12-Days of X-MASS Exclusive Bonus"></div>'; 2816 returnhtml += '<div class="bonusmoreinfo">'; 2817 returnhtml += '<p class="moreInfoHeading">12-DAYS OF X-MASS EXCLUSIVE</p>'; 2818 if (cartSummary.qualbonusnum == 3) { 2819 returnhtml += '<p class="moreInfoText"> Your Purchase qualifies for 3 FREE bonus workout programs. Click below to select from the available bonuses.</p>'; 2820 } 2821 else { 2822 returnhtml += '<p class="moreInfoText"> Your Purchase has qualified for a free bonus workout program. Click below to select from the available bonuses.</p>'; 2823 2824 }
2825 returnhtml += '<div class="bonusforward bonusaction viewBonus" onclick="plusSlides(1)">VIEW BONUSES</div>'; 2826 if (cartSummary.qualbonusnum < 3) { 2827 returnhtml += '<p class="moreInfoSubHeading hideOn3">WANT 3 FREE BONUSES?</p>'; 2828 returnhtml += '<p class="moreInfoText hideOn3">2 Full Programs or $200 in supplements qualifies for 3 FREE Bonuses.</p>'; 2829 } 2830 else { 2831 returnhtml += '<p class="moreInfoSubHeading hideOn3"></p>'; 2832 } 2833 returnhtml += '<div id="keepShopping" class="bonusforward bonusaction" >KEEP SHOPPING</div>'; 2834 2835 returnhtml += '</div>'; 2836 2837 returnhtml += '</div></div>'; 2838 2839 2840 Object.keys(bonusOptions).forEach((bonus) => { 2841 returnhtml += '<div class="bonuscontain fade ' + (cartSummary.bonuses[bonusOptions[bonus].sku] == true ? "bonusincart" : "") + '" data-sku="' + bonusOptions[bonus].sku + '">'; 2842 returnhtml += '<div class="bonusfirst">'; 2843 returnhtml += '<img loading="lazy" class="bonusimg" src="' + bonusOptions[bonus].image + '" alt="' + bonusOptions[bonus].title + ' Bonus Program"></img>'; 2844 returnhtml += '<div class="bonusrightside">'; 2845 returnhtml += '<h3 class="bonustitle">' + bonusOptions[bonus].title + '</h3>'; 2846 returnhtml += '<p class="bonuspara">' + bonusOptions[bonus].description + '</p>'; 2847 returnhtml += '</div>'; 2848 returnhtml += '</div>'; 2849 returnhtml += '<div class="bonusmoreinfo">'; 2850 returnhtml += '<p class="bonusfocus"><span class="prgfocus bonussub">Program Focus: </span>' + bonusOptions[bonus].focus + '</h3>'; 2851 returnhtml += '<p class="bonusequipment"><span class="prgequip bonussub">Equipment: </span>' + bonusOptions[bonus].equipment + '</img>'; 2852 returnhtml += '<p class="bonusduration"><span class="prgduration bonussub">Duration: </span>' + bonusOptions[bonus].duration + '</p>'; 2853 returnhtml += '<p class="bonusfrequency"><span class="prgfreq bonussub">Frequency: </span>' + bonusOptions[bonus].frequency + '</p>'; 2854 returnhtml += '<p class="bonusexperience"><span class="prgexp bonussub">Experience Level: </span>' + bonusOptions[bonus].experience + '</p>'; 2855 returnhtml += '<p class="bonuscondition"><span class="prgcondtion bonussub">Conditioning: </span>' + bonusOptions[bonus].condition + '</p>'; 2856 returnhtml += '</div>'; 2857 returnhtml += '<div class="bonusbottom">'; 2858 returnhtml += '<div class="bonusback bonusaction" onclick="plusSlides(-1)"><</div>'; 2859 if (twobonuses == true && cartSummary.bonuses[bonusOptions[bonus].sku] != true) { 2860 returnhtml += '<button class="bonusbuy addbonus" data-sku="' + bonusOptions[bonus].sku + '" onClick="selectbonus(event)">Choose This Bonus</button>'; 2861 } else if (twobonuses == true && cartSummary.bonuses[bonusOptions[bonus].sku] == true) { 2862 returnhtml += '<button class="bonusbuy addbonus alreadyincart" data-sku="' + bonusOptions[bonus].sku + '" onClick="return false;">In Cart</button>'; 2863 } else { 2864 returnhtml += '<button class="bonusbuy addbonus add-program-cart" data-sku="' + bonusOptions[bonus].sku + '" onClick="jQuery(\'#myModal\').fadeOut()">Choose This Bonus</button>'; 2865 } 2866 returnhtml += '<div class="bonusforward bonusaction" onclick="plusSlides(1)">></div></div>'; 2867 returnhtml += '</div>'; 2868 }); 2869 returnhtml += '</div>'; 2870 returnhtml += '</div>'; 2871 returnhtml += '<div class="bonusdots">'; 2872 for (k = 1; k <= Object.keys(bonusOptions).length; k++) { 2873 returnhtml += '<div class="bonusdot">\ 2874 <span class="dot" onclick="currentSlide('+ k + ')"></span>\ 2875 </div>'; 2876 } 2877 returnhtml += '</div>'; 2878 2879 returnhtml += '<div class="bonuscount">'; 2880 returnhtml += '<span class="bonustext">'; 2881 if (twobonuses == true) { 2882 returnhtml += "Select Any 3 Bonuses"; 2883 } 2884 else { 2885 returnhtml += "Select Any Bonus"; 2886 } 2887 2888 returnhtml += '</span>'; 2889 returnhtml += '</div>'; 2890 2891 returnhtml += '</div>'; 2892 returnhtml += '<script>var slideIndex = 1;\ 2893showSlides(slideIndex);\ 2894function plusSlides(n) {\ 2895 showSlides(slideIndex += n);\ 2896}\ 2897function currentSlide(n) {\ 2898 showSlides(slideIndex = n);\ 2899}\ 2900function showSlides(n) {\ 2901 var i;\ 2902 var slides = document.getElementsByClassName("bonuscontain");\ 2903 var dots = document.getElementsByClassName("dot");\ 2904 if (n > slides.length) {slideIndex = 1}\ 2905 if (n < 1) {slideIndex = slides.length}\ 2906 for (i = 0; i < slides.length; i++) {\ 2907 slides[i].style.display = "none";\ 2908 }\ 2909 for (i = 0; i < dots.length; i++) {\ 2910 dots[i].className = dots[i].className.replace(" active", "");\ 2911 }\ 2912 slides[slideIndex-1].style.display = "block";\ 2913 dots[slideIndex-1].className += " active";\ 2914}</script>'; 2915 jQuery('#myModal .modal-content').html(returnhtml); 2916 jQuery('#myModal').fadeIn(); 2917 sessionStorage['bonusPoppedOnce'] = 'true'; 2918} 2919 2920function selectbonus(event) { 2921 if (jQuery(event.currentTarget).parents(".bonuscontain").hasClass("selectedbonus")) { 2922 jQuery(event.currentTarget).parents(".bonuscontain").removeClass("selectedbonus"); 2923 jQuery(event.currentTarget).html("Add This Bonus"); 2924 } else { 2925 jQuery(event.currentTarget).parents(".bonuscontain").addClass("selectedbonus"); 2926 jQuery(event.currentTarget).html("Remove Bonus"); 2927 } 2928 2929 2930 if ((jQuery(".selectedbonus").length == 2 && cartSummary.bonusnum == 1) || jQuery(".selectedbonus").length == 3 || (jQuery(".selectedbonus").length == 1 && cartSummary.bonusnum == 2)) { 2931 jQuery('#myModal').fadeOut(); 2932 let firstbonus = jQuery(".selectedbonus")[0].dataset.sku; 2933 let secondbonus = ''; 2934 let thirdbonus = ''; 2935 if (jQuery(".selectedbonus")[1] != undefined) { 2936 secondbonus = jQuery(".selectedbonus")[1].dataset.sku; 2937 } 2938 if(jQuery(".selectedbonus")[2] != undefined){ 2939 thirdbonus = jQuery(".selectedbonus")[2].dataset.sku; 2940 } 2941 UC.getCart(function (cart) { 2942 var itemInfo = { 2943 'item_id': firstbonus, 2944 'quantity': 1 2945 }; 2946 if (secondbonus != '') { 2947 UC.updateCartItems(cart, itemInfo); 2948 var itemInfo = { 2949 'item_id': secondbonus, 2950 'quantity': 1 2951 }; 2952 } 2953 if (thirdbonus != '') { 2954 UC.updateCartItems(cart, itemInfo); 2955 var itemInfo = { 2956 'item_id': thirdbonus, 2957 'quantity': 1 2958 }; 2959 } 2960 2961 UC.updateCartItems(cart, itemInfo); 2962 UC.postCart(cart, function (updatedCart, errors) { 2963 if (errors.length > 0) { 2964 if (errors[0].includes("coupon")) { 2965 AX.modal.hide('#axModal'); 2966 axupdateSnapshotItems(updatedCart); 2967 } else if (errors[0].includes("backorder")) { 2968 axupdateSnapshotItems(updatedCart); 2969 } else { 2970 AX.modal.show('#axModal', { 2971 content: '<div class="ax-modal-error">' + errors[0] + '</div>' 2972 }); 2973 2974 console.error('[AX CART]', errors); 2975 } 2976 } else { 2977 AX.modal.hide('#axModal'); 2978 jQuery('.ult-overlay.content-xx2.supp-pop-modal').removeClass(" ult-open"); 2979 axupdateSnapshotItems(updatedCart); 2980 UCWP.cartSnapShot.showSnapshot(); 2981 } 2982 }); 2983 }); 2984 2985 jQuery('#myModal .modal-content').html(""); 2986 } 2987} 2988 2989jQuery('body').on('click', '#keepShopping', function () { 2990 jQuery('#myModal').hide(); 2991}); 2992 2993// Get a link to the AX product view page for a specific cart item using it's Ultracart SKU. 2994// function getProductLink(cartItem) { 2995// var itemId = cartItem.item_id.toLowerCase(); 2996 2997// // Search for match in product json. 2998// // 2999// // Ultracart sku's contain flavor information, thus the need for 3000// // a looped comparison. 3001// var matchedSku = rxProductSkus.find(function (sku) { 3002// return itemId.startsWith(sku); 3003// }); 3004 3005// if (typeof rxProductsJson[matchedSku] !== 'undefined') { 3006// return supplementLinkBase + '/' + rxProductsJson[matchedSku].link; 3007// } 3008 3009// // Return false for now until all product types are handled so we can exclude link 3010// // elements from those cart items. 3011// return false;
3012// } 3013 3014 3015// function discountProgressHtml(cart) { 3016// var activeClass = 'discount-progress__bar--tier-active'; 3017 3018// var $cart = jQuery('.cart-snapshot'); 3019// var progress = parseInt($cart.attr('data-discount-progress') ?? 0, 10); 3020// var percent = parseInt($cart.attr('data-discount-percent') ?? 0, 10); 3021// var breakpoint = parseInt($cart.attr('data-discount-breakpoint') ?? 0, 10); 3022 3023// // Update values. 3024// var tier = AX.discounts.currentTier(cart); 3025// var $cart = jQuery('.cart-snapshot'); 3026 3027// $cart 3028// .attr('data-discount-breakpoint', tier.breakpoint ?? 0) 3029// .attr('data-discount-progress', AX.discounts.progress(cart)) 3030// .attr('data-discount-percent', tier.discount.percent ?? 0) 3031 3032// return ` 3033// <div class="discount-progress__widget discount-progress__wrapper"> 3034// <div class="discount-progress__inner"> 3035// <span class="discount-progress__message">Loading...</span> 3036 3037// <span class="discount-progress__fine-print">*Cannot be combined with other offers. <a href="javascript:void(0);" onclick="javascript:AX.discounts.termsModal();">Read more</a>.</span> 3038 3039// <div class="discount-progress noselect select-none"> 3040// <div class="discount-progress__bar--outer"> 3041// <div class="discount-progress__bar--inner" style="width: ${progress}%;"></div> 3042// </div> 3043 3044// <div 3045// class="discount-progress__bar--tier discount-progress__bar--tier-active" 3046// data-discount-breakpoint="0" 3047// data-discount-subtotal="true" 3048// data-discount-tier 3049// > 3050// <div class="discount-progress__bar--tier-text"> 3051// <span>FREE</span> 3052// <span>S&H</span> 3053// </div> 3054// </div> 3055 3056// <div 3057// class="discount-progress__bar--tier ${breakpoint >= 134 ? activeClass : ''}" 3058// data-discount-breakpoint="134" 3059// data-discount-subtotal="false" 3060// data-discount-tier 3061// > 3062// 20% 3063// </div> 3064// </div> 3065// </div> 3066// </div> 3067// ` 3068// } 3069 3070function discountProgressHtml(cart) { 3071 var activeClass = 'discount-progress__bar--tier-active'; 3072
3073 var $cart = jQuery('.cart-snapshot'); 3074 var progress = parseInt($cart.attr('data-discount-progress') ?? 0, 10); 3075 var percent = parseInt($cart.attr('data-discount-percent') ?? 0, 10); 3076 var breakpoint = parseInt($cart.attr('data-discount-breakpoint') ?? 0, 10); 3077 3078 // Update values. 3079 var tier = AX.discounts.currentTier(cart); 3080 var $cart = jQuery('.cart-snapshot'); 3081 3082 $cart 3083 .attr('data-discount-breakpoint', tier.breakpoint ?? 0) 3084 .attr('data-discount-progress', AX.discounts.progress(cart)) 3085 .attr('data-discount-percent', tier.discount.percent ?? 0) 3086 3087 return ` 3088 <div class="discount-progress__widget discount-progress__wrapper"> 3089 <div class="discount-progress__inner"> 3090 3091 <div class="discount-progress__title"> 3092 SAVE MORE & UNLOCK FREE SHIPPING! 3093 </div> 3094 3095 <div class="discount-progress noselect select-none"> 3096 <div class="discount-progress__bar--outer"> 3097 <div class="discount-progress__bar--inner" style="width: ${progress}%;"></div> 3098 </div> 3099 </div> 3100 3101 <span class="discount-progress__message">Loading...</span> 3102 3103 <span class="discount-progress__fine-print">*FREE Shipping to Continental US. <button onclick="javascript:AX.discounts.termsModal();">Read more</button></span> 3104 3105 </div> 3106 </div> 3107 3108 <div class="bundle-button__wrapper"> 3109 <a href="/bundle">BUILD A STACK & SAVE</a> 3110 </div> 3111 ` 3112} 3113function getCookie(name) { 3114 let value = "; " + document.cookie; 3115 let parts = value.split("; " + name + "="); 3116 if (parts.length === 2) return parts.pop().split(";").shift(); 3117} 3118async function sendTrackingData(eventName, eventData) { 3119 return; 3120 try { 3121 const response = await fetch('https://learn.athleanx.com/wp-content/plugins/ax_meta_conversion/metaReciever.php', { 3122 method: 'POST', 3123 credentials: 'include', 3124 headers: { 3125 'Content-Type': 'application/json', 3126 }, 3127 body: JSON.stringify({ 3128 event_name: eventName, 3129 event_data: JSON.parse(eventData) 3130 }) 3131 }); 3132 3133 if (!response.ok) { 3134 throw new Error('Network response was not ok'); 3135 } 3136 3137 const result = await response.json(); 3138 //console.log('Success:', result); 3139 } catch (error) { 3140 console.error('Error:', error); 3141 } 3142}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.