JOURNALSAY Minimalist Black White Transparent Stamp Creative Retro Scrapbooking
${function(){
const tipText = "Please select a {{ name }}".replace(/\{\{\s+name\s+\}\}/g, data);
return `${tipText}
`
}()}
${function() {
const variantData = data.variant || {"id":"e89b4d22-7058-4752-869c-399a30060b08","product_id":"2ffe8dca-b832-4b5d-8c36-d9e492587fd2","title":"biao ge wen zi","weight_unit":"kg","inventory_quantity":1020,"sku":"YZ-GJTM3-11","barcode":"","position":1,"option1":"biao ge wen zi","option2":"","option3":"","note":"","image":{"src":"\/\/img.staticdj.com\/75136be43d93f003647083b391b548df.jpeg","path":"75136be43d93f003647083b391b548df.jpeg","width":800,"height":800,"alt":"JOURNALSAY Minimalist Black White Transparent Stamp Creative Retro Scrapbooking","aspect_ratio":1},"wholesale_price":[{"price":1.44,"min_quantity":1}],"weight":"0.04","compare_at_price":"2.88","price":"1.44","retail_price":"2.88","available":true,"url":"\/products\/journalsay-minimalist-black-white-transparent-stamp-creative-retro-scrapbooking?variant=e89b4d22-7058-4752-869c-399a30060b08","available_quantity":1020,"options":[{"name":"Color","value":"biao ge wen zi"}],"off_ratio":"50","flashsale_info":{"variant_id":"e89b4d22-7058-4752-869c-399a30060b08","product_id":"","quantity":0,"discount_id":"f4e8b0c0-8a3e-44f7-baf8-1beeae10361c","limit_time":526771,"limit_buy":-1,"user_limit_buy":-1,"discount_sales":1,"discount_sales_rate":"1","discount_stock":1020,"ends_at":1734334199,"starts_at":1733731200,"allow_oversold":"uncheck","allocation_method":"none","price":"1.44","compare_at_price":"2.88","discount_price":"1.44","customary_saved_price":"1.44","customary_off_ratio":"50","discount_saved_price":"1.44","discount_off_ratio":"50","use_before_price":false,"before_price":"0","title":"","properties":"","color_setting_promotional_copy":"","discount_quantity":0,"is_need_split":false},"sales":11545};
const saveType = "percentage";
const productLabelDiscountOn = true;
return `
-
${saveType == 'percentage'
? `-${variantData.off_ratio}%`
: `-`
}
`;
}()}
Product was out of stock.
Product is unavailable.
Visible only when the product is out of stock. Currently in preview mode.
Notify Me
JOURNALSAY Minimalist Black White Transparent Stamp Creative Retro Scrapbooking
biao ge wen zi
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":"e89b4d22-7058-4752-869c-399a30060b08","product_id":"2ffe8dca-b832-4b5d-8c36-d9e492587fd2","title":"biao ge wen zi","weight_unit":"kg","inventory_quantity":1020,"sku":"YZ-GJTM3-11","barcode":"","position":1,"option1":"biao ge wen zi","option2":"","option3":"","note":"","image":{"src":"\/\/img.staticdj.com\/75136be43d93f003647083b391b548df.jpeg","path":"75136be43d93f003647083b391b548df.jpeg","width":800,"height":800,"alt":"JOURNALSAY Minimalist Black White Transparent Stamp Creative Retro Scrapbooking","aspect_ratio":1},"wholesale_price":[{"price":1.44,"min_quantity":1}],"weight":"0.04","compare_at_price":"2.88","price":"1.44","retail_price":"2.88","available":true,"url":"\/products\/journalsay-minimalist-black-white-transparent-stamp-creative-retro-scrapbooking?variant=e89b4d22-7058-4752-869c-399a30060b08","available_quantity":1020,"options":[{"name":"Color","value":"biao ge wen zi"}],"off_ratio":"50","flashsale_info":{"variant_id":"e89b4d22-7058-4752-869c-399a30060b08","product_id":"","quantity":0,"discount_id":"f4e8b0c0-8a3e-44f7-baf8-1beeae10361c","limit_time":526771,"limit_buy":-1,"user_limit_buy":-1,"discount_sales":1,"discount_sales_rate":"1","discount_stock":1020,"ends_at":1734334199,"starts_at":1733731200,"allow_oversold":"uncheck","allocation_method":"none","price":"1.44","compare_at_price":"2.88","discount_price":"1.44","customary_saved_price":"1.44","customary_off_ratio":"50","discount_saved_price":"1.44","discount_off_ratio":"50","use_before_price":false,"before_price":"0","title":"","properties":"","color_setting_promotional_copy":"","discount_quantity":0,"is_need_split":false},"sales":11545};
// 上报
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\/0a7cf31f35585939d4297ddaca3f2af0.jpg","path":"0a7cf31f35585939d4297ddaca3f2af0.jpg","width":800,"height":800,"alt":"JOURNALSAY Minimalist Black White Transparent Stamp Creative Retro Scrapbooking","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('7');
const maxDays = parseInt('30');
const customText = "90% Orders Fast Ship Within 48 Hours
\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 `
${tipText}
`;
}()}
${function() {
const postageFreeAmount = 29;
const custom_text = "Buy {amount} more to enjoy FREE Shipping";
const totalPrice = +data.total_price;
const diffPrice = postageFreeAmount - totalPrice;
const percentDiff = (diffPrice > 0 ? (totalPrice / postageFreeAmount * 100) : 100) + '%';
let tipText = "Your order is free delivery";
if (diffPrice > 0) {
tipText = custom_text.replace('{amount}', `
`);
}
return `
`;
}()}
/** @private {string} */
class SpzCustomAnchorScroll extends SPZ.BaseElement {
static deferredMount() {
return false;
}
constructor(element) {
super(element);
/** @private {Element} */
this.scrollableContainer_ = null;
}
isLayoutSupported(layout) {
return layout == SPZCore.Layout.LOGIC;
}
buildCallback() {
this.viewport_ = this.getViewport();
this.initActions_();
}
setTarget(containerId, targetId) {
this.containerId = '#' + containerId;
this.targetId = '#' + targetId;
}
scrollToTarget() {
const container = document.querySelector(this.containerId);
const target = container.querySelector(this.targetId);
const {scrollTop} = container;
const eleOffsetTop = this.getOffsetTop_(target, container);
this.viewport_
.interpolateScrollIntoView_(
container,
scrollTop,
scrollTop + eleOffsetTop
);
}
initActions_() {
this.registerAction(
'scrollToTarget',
(invocation) => this.scrollToTarget(invocation?.caller)
);
this.registerAction(
'setTarget',
(invocation) => this.setTarget(invocation?.args?.containerId, invocation?.args?.targetId)
);
}
/**
* @param {Element} element
* @param {Element} container
* @return {number}
* @private
*/
getOffsetTop_(element, container) {
if (!element./*OK*/ getClientRects().length) {
return 0;
}
const rect = element./*OK*/ getBoundingClientRect();
if (rect.width || rect.height) {
return rect.top - container./*OK*/ getBoundingClientRect().top;
}
return rect.top;
}
}
SPZ.defineElement('spz-custom-anchor-scroll', SpzCustomAnchorScroll);
const STRENGTHEN_TRUST_URL = "/api/strengthen_trust/settings";
class SpzCustomStrengthenTrust extends SPZ.BaseElement {
constructor(element) {
super(element);
this.renderElement_ = null;
}
isLayoutSupported(layout) {
return layout == SPZCore.Layout.CONTAINER;
}
buildCallback() {
this.xhr_ = SPZServices.xhrFor(this.win);
const renderId = this.element.getAttribute('render-id');
SPZCore.Dom.waitForChild(
document.body,
() => !!document.getElementById(renderId),
() => {
this.renderElement_ = SPZCore.Dom.scopedQuerySelector(
document.body,
`#${renderId}`
);
if (this.renderElement_) {
this.render_();
}
this.registerAction('track', (invocation) => {
this.track_(invocation.args);
});
}
);
}
render_() {
this.fetchData_().then((data) => {
if (!data) {
return;
}
SPZ.whenApiDefined(this.renderElement_).then((apis) => {
apis?.render(data);
document.querySelector('#strengthen-trust-render-1539149753700').addEventListener('click',(event)=>{
if(event.target.nodeName == 'A'){
this.track_({type: 'trust_content_click'});
}
})
});
});
}
track_(data = {}) {
const track = window.sa && window.sa.track;
if (!track) {
return;
}
track('trust_enhancement_event', data);
}
parseJSON_(string) {
let result = {};
try {
result = JSON.parse(string);
} catch (e) {}
return result;
}
fetchData_() {
return this.xhr_
.fetchJson(STRENGTHEN_TRUST_URL)
.then((responseData) => {
if (!responseData || !responseData.data) {
return null;
}
const data = responseData.data;
const moduleSettings = (data.module_settings || []).reduce((result, moduleSetting) => {
return result.concat(Object.assign(moduleSetting, {
logos: (moduleSetting.logos || []).map((item) => {
return moduleSetting.logos_type == 'custom' ? this.parseJSON_(item) : item;
})
}));
}, []);
return Object.assign(data, {
module_settings: moduleSettings,
isEditor: window.self !== window.top,
});
});
}
}
SPZ.defineElement('spz-custom-strengthen-trust', SpzCustomStrengthenTrust);
${data.module_title}
To display this card to customers, you need to go to "Booster & Store Conversion" to turn on the trust enhancement feature.
${item.content.replaceAll("{store_name}","Journalsay")}
To display this card to customers, you need to go to "Booster & Store Conversion" to turn on the trust enhancement feature.