${function() {
const variantData = data.variant || {"id":"ceea7272-6b8e-4ef7-9ee1-9b859d0b396a","product_id":"2fe09ce1-24b1-4de7-adc2-b9fe511ff936","title":"","weight_unit":"kg","inventory_quantity":643,"sku":"WH2101-DP","barcode":"","position":1,"option1":"","option2":"","option3":"","note":"","image":null,"wholesale_price":[{"price":159,"min_quantity":1}],"weight":"0","compare_at_price":"0","price":"159","retail_price":"0","available":true,"url":"\/products\/alloyworks-3-row-aluminum-radiator-for-1987-2006-jeep-wrangler-tj-yj-4-0-4-2l-l6-gas-23-h-x-26-w?variant=ceea7272-6b8e-4ef7-9ee1-9b859d0b396a","available_quantity":643,"options":[],"off_ratio":0,"flashsale_info":[],"sales":1};
const saveType = "percentage";
const saveText = "Save {{saved_amount}}";
const productLabelDiscountOn = true;
return `
-
${saveText.replace('\{\{saved_amount\}\}',
saveType == 'percentage'
? variantData.off_ratio + '%'
: ` `
)}
`;
}()}
Check the Fit
Please check if this fits your vehicle before purchasing
Select a vehicle to verify fitment
This Part Fits Your Vehicle
This Part May Not Fit
Visible only when the product is out of stock. Currently in preview mode.
Notify Me
Alloyworks 3 Row Aluminum Radiator For 1987-2006 Jeep Wrangler TJ YJ 4.0 4.2L L6 Gas 23" H x 26" W
Email
(function(){
function $(selector){
return document.querySelector(selector);
}
const EMAIL_REG = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
// 获取dom数据
const doms = {
button: $('#app-arrival-reminder-button'),
previewBox: $('#app-arrival-reminder-preview-box'),
toast: $('#app-arrival-reminder-toast'),
lightbox: $('#arrival-lightbox'),
datalist: $('#app-arrival-reminder-email-list'),
imgRender: $('#app-arrival-reminder-product-image-render'),
productVariant: $('#app-arrival-reminder-product-variant'),
emailInput: $('#app-arrival-reminder-form .reminder-email-input'),
emailWarn: $('#app-arrival-reminder-form .reminder-email-warn-wrap'),
emailWarnText: $('#app-arrival-reminder-form .reminder-email-warn-text'),
submitButton: $('#app-arrival-reminder-submit-button')
};
// 选中的sku数据
let selectedVariant = {"id":"ceea7272-6b8e-4ef7-9ee1-9b859d0b396a","product_id":"2fe09ce1-24b1-4de7-adc2-b9fe511ff936","title":"","weight_unit":"kg","inventory_quantity":643,"sku":"WH2101-DP","barcode":"","position":1,"option1":"","option2":"","option3":"","note":"","image":null,"wholesale_price":[{"price":159,"min_quantity":1}],"weight":"0","compare_at_price":"0","price":"159","retail_price":"0","available":true,"url":"\/products\/alloyworks-3-row-aluminum-radiator-for-1987-2006-jeep-wrangler-tj-yj-4-0-4-2l-l6-gas-23-h-x-26-w?variant=ceea7272-6b8e-4ef7-9ee1-9b859d0b396a","available_quantity":643,"options":[],"off_ratio":0,"flashsale_info":[],"sales":1};
// 上报
function reportData(params){
// 编辑/预览不上报
if(false){
return;
}
window.sa.track(params.event_name, {
business_type: 'product_plugin',
function_name: 'Back_in_Stock',
plugin_name: "Back_in_Stock",
template_name: "product",
template_type: 1,
module: "apps",
module_type: "Back_in_Stock",
event_info: JSON.stringify({
action_type: 'Back_in_Stock'
}),
...params
});
}
// 按钮曝光上报
function buttonPVReport(){
reportData({
event_name: 'function_expose',
event_type: 'expose',
event_desc: '无货商品时触发'
});
}
// 弹窗曝光上报
function popupPVReport(){
reportData({
event_name: 'function_expose',
event_type: 'popup_expose',
event_desc: '弹窗曝光时触发'
});
}
// submit按钮点击上报
function submitClickReport(){
reportData({
event_name: 'function_click',
event_type: 'popup_click',
event_desc: '填入邮箱之后,点击notify 触发',
event_info: JSON.stringify({
action_type: 'email_click'
}),
});
}
// -----------------------初始化-----------------
init();
// 初始化操作
function init(){
// 为确保window有后面添加的值例如window.sa 需要在DOMContentLoaded回调事件中执行逻辑
document.addEventListener("DOMContentLoaded", function() {
// 设置邮件联想
setDataList();
if(!true){
// 初始无货 按钮pv事件埋点上报
buttonPVReport();
}
});
}
// 设置邮件联想
function setDataList(){
const customer_email = window.C_SETTINGS.customer.customer_email;
if(customer_email){
const options = document.createElement('option');
options.setAttribute('value', customer_email);
doms.datalist.appendChild(options);
}
}
// -----------------------事件操作----------------
// 监听sku变化事件
document.addEventListener('dj.variantChange', variantChange);
// 监听提醒按钮点击事件
doms.button.addEventListener('click', reminderButtonClick);
// 监听提交按钮点击事件
doms.submitButton.addEventListener('click', submit);
// 监听input元素的keydown事件
doms.emailInput.addEventListener('keydown', function(e) {
// 判断是否按下了Enter键
if (e.keyCode === 13 || e.key === 'Enter') {
submit();
}
});
// 显示正常按钮
function showReminderButton(){
doms.button.classList.remove('app-arrival-hidden');
doms.previewBox.classList.add('app-arrival-preview-hidden');
buttonPVReport();
}
// 展示预览按钮
function showPreviewButton(){
doms.button.classList.remove('app-arrival-hidden');
doms.previewBox.classList.remove('app-arrival-preview-hidden');
}
// 隐藏按钮
function hiddenReminderButton(){
doms.button.classList.add('app-arrival-hidden');
doms.previewBox.classList.add('app-arrival-preview-hidden');
}
// 提交数据, 请求接口
function submit(){
// 获取邮箱数据
const email = doms.emailInput.value.trim();
if(!email){
doms.emailWarnText.innerText = "Please enter your email address";
doms.emailWarn.classList.remove('app-arrival-hidden');
return;
}
if(!EMAIL_REG.test(email)){
doms.emailWarnText.innerText = "Please enter a valid email address";
doms.emailWarn.classList.remove('app-arrival-hidden');
return;
}
// 邮箱校验成功
doms.emailWarn.classList.add('app-arrival-hidden');
// 预览时不调接口
if(false){
SPZ.whenApiDefined(doms.toast).then(apis => {
apis.showToast("Currently in preview mode, subscription is for testing only", 3000);
});
return;
}
// 加入loading样式
doms.submitButton.classList.add('reminder-submit-button-loading');
// 提交数据请求接口
let quantity = 1;
const quantityDom = $('#app-arrival-reminder-quantity-render ljs-quantity');
if(quantityDom){
quantity = Number(quantityDom.getAttribute('value')) || 1;
}
const params = {
customer_email: email,
product_num: quantity,
product_id: selectedVariant.product_id,
product_variant_id: selectedVariant.id
};
fetch(`${window.C_SETTINGS.routes.root}/api/front/gobbler/v1/subscribe`, {
method: 'POST',
body: JSON.stringify(params),
headers: {
'Content-Type': 'application/json'
}
}).then((res)=>res.json()).then((res)=>{
/* 后端错误提示 */
if(res.errors && res.errors.length){
SPZ.whenApiDefined(doms.toast).then(apis=>{
apis.showToast(res.errors[0], 3000);
});
return;
}
/* code
* 0 SUCCESS 订阅成功
* 1 PRODUCT_OFFLINE 商品下架
* 2 INVENTORY_NOT_EMPTY 商品库存不为空
* 3 REPEAT_SUBSCRIBE 重复订阅
* 4 EMAIL_EMPTY 邮件为空
* 5 EMAIL_WRONG_FORMAT 邮件格式错误
* 99999 INVALID_PARAMS 其他参数错误
*/
const codeMap = {
SUCCESS: ()=>{
SPZ.whenApiDefined(doms.lightbox).then(apis=>{
apis.close();
});
SPZ.whenApiDefined(doms.toast).then(apis=>{
apis.showToast("Thank you for your subscription! We will notify you as soon as the product is back in stock!", 3000);
});
},
INVENTORY_NOT_EMPTY: ()=>{
SPZ.whenApiDefined(doms.lightbox).then(apis=>{
apis.close();
});
SPZ.whenApiDefined(doms.toast).then(apis=>{
apis.showToast("Subscription failed. Product back in stock, please proceed to checkout.", 3000);
});
setTimeout(()=>{
window.location.reload();
}, 3000);
},
REPEAT_SUBSCRIBE: ()=>{
SPZ.whenApiDefined(doms.toast).then(apis=>{
apis.showToast("You've already subscribed to this product. We'll let you know as soon as it's back in stock. Feel free to explore our other products.", 3000);
});
},
EMAIL_EMPTY: ()=>{
SPZ.whenApiDefined(doms.toast).then(apis=>{
apis.showToast("Please enter your email address", 3000);
});
},
EMAIL_WRONG_FORMAT: ()=>{
SPZ.whenApiDefined(doms.toast).then(apis=>{
apis.showToast("Please enter a valid email address", 3000);
});
}
};
codeMap.PRODUCT_OFFLINE = codeMap.SUCCESS;
codeMap[res.code] && codeMap[res.code]();
}).finally(()=>{
doms.submitButton.classList.remove('reminder-submit-button-loading');
});
// submit点击上报
submitClickReport();
}
// 重新渲染dialog
function refreshRenderDialog(){
console.log('selectedVariant', selectedVariant);
const images = selectedVariant.image || {"src":"\/\/img.staticdj.com\/b43e8d5a005baa37d49108d6bd939892.png","path":"b43e8d5a005baa37d49108d6bd939892.png","width":1500,"height":1500,"alt":"Alloyworks 3 Row Aluminum Radiator For 1987-2006 Jeep Wrangler TJ YJ 4.0 4.2L L6 Gas 23\" H x 26\" W\u00a0","aspect_ratio":1};
const imagePosition = images.aspect_ratio > 1 ? 'left top' : 'center center';
// 重新渲染图片
SPZ.whenApiDefined(doms.imgRender).then((apis)=>{
apis.render({
images,
imagePosition
});
});
// 邮件错误提示置空
doms.emailWarn.classList.add('app-arrival-hidden');
// 重新渲染款式说明
if(selectedVariant.title){
doms.productVariant.innerText = selectedVariant.title.split('-').join('/');
}
// 表单数据置空
doms.emailInput.value = '';
}
// sku变化 单一款式不会触发
function variantChange(e){
const selected = e.detail.selected;
// 子款式没变不执行操作 例如数量变化
if(selected.id === selectedVariant.id){
return;
}
selectedVariant = selected;
console.log('selectedVariant', selectedVariant);
// 数量变化
if(selected.available || selected.product_id === undefined){
// 有库存 编辑时展示预览按钮 否则隐藏按钮
if(false){
showPreviewButton();
}else {
hiddenReminderButton();
}
}else{
// 无库存 显示正常按钮
showReminderButton();
}
}
// 提醒按钮点击
function reminderButtonClick(){
refreshRenderDialog();
// 弹窗曝光上报
popupPVReport();
}
document.body.appendChild(doms.toast);
document.body.appendChild(doms.lightbox.parentElement);
})();
${function() {
const minDays = parseInt('3');
const maxDays = parseInt('9');
const customText = "Free Shipping on All Orders excl. HI & AK.\n \nEstimated Delivery\uff1a{min_date} - {max_date}";
const minDate = new Date(Date.now() + (minDays * 86400000));
const maxDate = new Date(Date.now() + (maxDays * 86400000));
const formatDate = (minDate.getFullYear() == maxDate.getFullYear() && minDate.getFullYear() == new Date().getFullYear())
? new Intl.DateTimeFormat('en', { month: 'short', day: '2-digit' })
: new Intl.DateTimeFormat('en', { month: 'short', day: '2-digit', year: 'numeric' });
const tipText = customText.replace(/\{min_date\}/g, '' + formatDate.format(minDate) + ' ')
.replace(/\{max_date\}/g, '' + formatDate.format(maxDate) + ' ');
return `
`;
}()}