מחירי ההשקה שלנו יעלו כשנגיע ל-50 לקוחות.
מי שנרשם היום נועל את המחיר לתמיד - גם אם המחיר יעלה מחר.
רכישה חד-פעמית
`
: `
₪${p.monthly}
/ חודש
`;
const setupHtml = isBuy()
? `+ ₪${BUY_INFRA_MONTHLY}/חודש אחסון ורישיונות`
: (p.saleFrom
? `דמי הקמה:
₪${p.saleFrom.toLocaleString()} ₪${p.setup.toLocaleString()}`
: `דמי הקמה: ₪${p.setup.toLocaleString()}`);
const badge = p.badge ? `
${p.badge}
` : '';
return `
`;
}).join('');
const btn1 = document.getElementById('btn1');
btn1.disabled = true; btn1.setAttribute('aria-disabled', 'true');
if (preselectKey) {
const card = grid.querySelector(`.plan[data-plan="${preselectKey}"]`);
if (card) pickPlan(card);
}
}
/* ================================================================
NAVIGATION - skip validation when going back
================================================================ */
function go(n) {
if (n > cur && !validate(cur)) return;
if (n === 4) toggleCatalogField();
if (n === 5) fillSummary();
if (n === 6) setupPayCards();
document.getElementById('s' + cur).style.display = 'none';
cur = n;
const el = document.getElementById('s' + cur);
el.style.display = 'block';
el.classList.remove('card-enter');
void el.offsetWidth;
el.classList.add('card-enter');
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
drawProgress();
if (cur === 6) submitData();
}
function drawProgress() {
for (let i = 1; i {
c.classList.remove('sel');
c.setAttribute('aria-checked', 'false');
});
card.classList.add('sel');
card.setAttribute('aria-checked', 'true');
plan = card.dataset.plan;
const b = document.getElementById('btn1');
b.disabled = false;
b.removeAttribute('aria-disabled');
}
function pickOpt(opt, group) {
opt.closest('.opts').querySelectorAll('.opt').forEach(o => {
o.classList.remove('sel');
o.setAttribute('aria-checked', 'false');
});
opt.classList.add('sel');
opt.setAttribute('aria-checked', 'true');
domain = opt.dataset.val;
document.querySelectorAll('.cond').forEach(c => c.classList.remove('show'));
if (domain === 'existing') document.getElementById('cond-existing').classList.add('show');
if (domain === 'new') document.getElementById('cond-new').classList.add('show');
if (track === 'store') {
const cc = document.getElementById('cond-catalog-size');
if (cc && (domain === 'existing' || domain === 'new')) cc.classList.add('show');
}
const b = document.getElementById('btn3');
b.disabled = false;
b.removeAttribute('aria-disabled');
}
function toggleCatalogField() {
const cc = document.getElementById('cond-catalog-size');
if (!cc) return;
cc.classList.toggle('show', track === 'store');
}
function pickMini(opt) {
const group = opt.closest('[data-group]').dataset.group;
opt.closest('[data-group]').querySelectorAll('.opt-sm').forEach(o => {
o.classList.remove('sel');
o.setAttribute('aria-checked', 'false');
});
opt.classList.add('sel');
opt.setAttribute('aria-checked', 'true');
mini[group] = opt.dataset.value;
}
/* ================================================================
SUMMARY (step 5)
================================================================ */
function fillSummary() {
if (!plan) return;
const p = currentPlanData(plan);
if (!p) return;
document.getElementById('sum-plan').textContent = plan;
const monthlyAmount = isBuy() ? BUY_INFRA_MONTHLY : p.monthly;
if (isBuy()) {
document.getElementById('sum-monthly-label').textContent = 'אחסון ורישיונות (חודשי)';
document.getElementById('sum-setup-label').textContent = 'מחיר רכישה (חד-פעמי)';
} else {
document.getElementById('sum-monthly-label').textContent = 'מנוי חודשי';
document.getElementById('sum-setup-label').textContent = 'דמי הקמה (חד-פעמי)';
}
const primary = isBuy() ? p.price : p.setup;
if (coupon && coupon.type === 'free_setup') {
document.getElementById('sum-setup').innerHTML =
'
₪' + primary.toLocaleString() + ' ₪0';
document.getElementById('sum-monthly').textContent = '₪' + monthlyAmount.toLocaleString() + ' / חודש';
document.getElementById('sum-coupon-row').style.display = 'flex';
document.getElementById('sum-coupon-val').textContent = '100% הנחה';
} else if (coupon && coupon.type === 'percent_setup') {
const discounted = Math.round(primary * (1 - coupon.pct / 100));
document.getElementById('sum-setup').innerHTML =
'
₪' + primary.toLocaleString() + ' ₪' + discounted.toLocaleString();
document.getElementById('sum-monthly').textContent = '₪' + monthlyAmount.toLocaleString() + ' / חודש';
document.getElementById('sum-coupon-row').style.display = 'flex';
document.getElementById('sum-coupon-val').textContent = coupon.pct + '% הנחה';
} else if (coupon && coupon.type === 'percent_monthly') {
const discountedMonthly = Math.round(monthlyAmount * (1 - coupon.pct / 100));
document.getElementById('sum-setup').textContent = '₪' + primary.toLocaleString();
document.getElementById('sum-monthly').innerHTML =
'
₪' + monthlyAmount.toLocaleString() + ' ₪' + discountedMonthly.toLocaleString() + ' / חודש';
document.getElementById('sum-coupon-row').style.display = 'flex';
document.getElementById('sum-coupon-val').textContent = coupon.pct + '% הנחה על המנוי';
} else {
document.getElementById('sum-setup').textContent = '₪' + primary.toLocaleString();
document.getElementById('sum-monthly').textContent = '₪' + monthlyAmount.toLocaleString() + ' / חודש';
document.getElementById('sum-coupon-row').style.display = 'none';
}
document.getElementById('understood-txt').textContent = isBuy()
? 'אני מבין/ה שהאתר יעלה לאוויר לאחר אישור שלי של התוכן והתשלום החד-פעמי'
: 'אני מבין/ה שהאתר יעלה לאוויר לאחר אישור שלי של התוכן ותשלום המנוי החודשי';
}
/* ================================================================
COUPON - case-insensitive match
================================================================ */
function tryCoupon() {
const raw = document.getElementById('coupon-inp').value.trim();
const ok = document.getElementById('cmsg-ok');
const err = document.getElementById('cmsg-err');
ok.style.display = 'none';
err.style.display = 'none';
const match = Object.entries(COUPONS).find(([k]) => k.toLowerCase() === raw.toLowerCase());
if (match) {
const [code, data] = match;
coupon = { code, ...data };
ok.textContent = '✓ ' + data.label;
ok.style.display = 'block';
fillSummary();
} else {
coupon = null;
err.textContent = 'קוד קופון לא תקין';
err.style.display = 'block';
fillSummary();
}
}
/* ================================================================
TERMS
================================================================ */
function updateBtn5() {
const b = document.getElementById('btn5');
const ok = termsOk && understoodOk;
b.disabled = !ok;
if (ok) b.removeAttribute('aria-disabled');
else b.setAttribute('aria-disabled', 'true');
}
function toggleTerms() {
termsOk = !termsOk;
const cb = document.getElementById('terms-cb');
cb.classList.toggle('on', termsOk);
cb.setAttribute('aria-checked', String(termsOk));
updateBtn5();
}
function toggleUnderstood() {
understoodOk = !understoodOk;
const cb = document.getElementById('understood-cb');
cb.classList.toggle('on', understoodOk);
cb.setAttribute('aria-checked', String(understoodOk));
updateBtn5();
}
/* ================================================================
PAYMENT (step 6)
================================================================ */
function growLinkFor(kind, planKey) {
// kind: 'setup' | 'monthly' | 'onetime'
const g = GROW[track];
if (isBuy()) return (g.buy && g.buy.onetime && g.buy.onetime[planKey]) || '#';
return (g.rent && g.rent[kind] && g.rent[kind][planKey]) || '#';
}
function setupPayCards() {
if (!plan) return;
const p = currentPlanData(plan);
if (!p) return;
const cardA = document.getElementById('pay-a');
const cardB = document.getElementById('pay-b');
const btnA = document.getElementById('pay-a-btn');
const btnB = document.getElementById('pay-b-btn');
const afterBtn = document.getElementById('btn-after-setup');
const monthlyActions = document.getElementById('monthly-actions');
monthlyActions.classList.remove('show');
const primary = isBuy() ? p.price : p.setup;
const primaryLabel = isBuy() ? 'שלם עבור בניית האתר' : 'שלם דמי הקמה';
const primaryDesc = isBuy() ? 'תשלום חד-פעמי • האתר שלך לתמיד' : 'תשלום חד-פעמי • חובה להתחלת הפרויקט';
const monthlyAmount = isBuy() ? BUY_INFRA_MONTHLY : p.monthly;
if (coupon && coupon.type === 'percent_monthly') {
/* קישורי Grow הם בסכום קבוע מראש - לא ניתן ליצור אוטומטית קישור בסכום חודשי מוזל.
מפנים לוואטסאפ עם הסכום המוזל כדי שאייל יסגור את המנוי ידנית. */
const discountedMonthly = Math.round(monthlyAmount * (1 - coupon.pct / 100));
document.getElementById('pay-b-title').textContent =
(isBuy() ? 'הגדר תשלום חודשי' : 'הגדר מנוי') + ' - ₪' + discountedMonthly.toLocaleString() + ' (במקום ₪' + monthlyAmount.toLocaleString() + ')';
document.getElementById('pay-b-desc').innerHTML =
'
' + coupon.label + ' - הגדרה מוזלת דרך וואטסאפ';
const waTextMonthly = encodeURIComponent(`היי, יש לי קוד קופון ${coupon.code} ל-${plan}, המחיר החודשי המוזל אמור להיות ₪${discountedMonthly.toLocaleString()} במקום ₪${monthlyAmount.toLocaleString()}`);
btnB.href = `https://wa.me/972587178899?text=${waTextMonthly}`;
} else {
btnB.href = isBuy() ? GROW.buyInfraMonthly : growLinkFor('monthly', plan);
document.getElementById('pay-b-title').textContent = isBuy()
? 'הגדר תשלום חודשי - ₪' + BUY_INFRA_MONTHLY + ' (אחסון ורישיונות)'
: 'הגדר מנוי - ₪' + p.monthly + ' / חודש';
document.getElementById('pay-b-desc').textContent = 'אופציונלי עכשיו - ניתן גם לפני עלייה לאוויר';
}
document.getElementById('btn-skip-monthly').textContent = isBuy()
? 'דלג על התשלום החודשי עכשיו - נסדר לפני עלייה לאוויר'
: 'דלג על המנוי עכשיו - נסדר לפני עלייה לאוויר';
if (coupon && coupon.type === 'free_setup') {
cardA.className = 'pay-card free-pay';
document.getElementById('pay-a-num').textContent = '✓';
document.getElementById('pay-a-title').textContent = (isBuy() ? 'מחיר רכישה' : 'דמי הקמה') + ' - ₪0';
document.getElementById('pay-a-desc').innerHTML = '
' + coupon.label + '';
btnA.style.display = 'none';
cardB.style.opacity = '1'; cardB.style.pointerEvents = 'auto';
cardB.classList.add('active-pay');
afterBtn.style.display = 'none';
monthlyActions.classList.add('show');
} else if (coupon && coupon.type === 'percent_setup') {
/* קישורי Grow הם בסכום קבוע מראש - אי אפשר ליצור אוטומטית קישור בסכום מוזל.
לכן, בקופון אחוזים, מפנים לוואטסאפ עם הסכום המוזל כדי שאייל יסגור תשלום ידני. */
const discounted = Math.round(primary * (1 - coupon.pct / 100));
cardA.className = 'pay-card active-pay';
document.getElementById('pay-a-num').textContent = '1';
document.getElementById('pay-a-title').textContent = primaryLabel + ' - ₪' + discounted.toLocaleString() + ' (במקום ₪' + primary.toLocaleString() + ')';
document.getElementById('pay-a-desc').innerHTML = '
' + coupon.label + ' - תשלום מוזל דרך וואטסאפ';
const waText = encodeURIComponent(`היי, יש לי קוד קופון ${coupon.code} ל-${plan}, המחיר המוזל אמור להיות ₪${discounted.toLocaleString()} במקום ₪${primary.toLocaleString()}`);
btnA.href = `https://wa.me/972587178899?text=${waText}`;
btnA.target = '_blank';
btnA.style.display = '';
cardB.style.opacity = '0.4'; cardB.style.pointerEvents = 'none';
cardB.classList.remove('active-pay');
afterBtn.classList.remove('show');
} else {
cardA.className = 'pay-card active-pay';
document.getElementById('pay-a-num').textContent = '1';
document.getElementById('pay-a-title').textContent = primaryLabel + ' - ₪' + primary.toLocaleString();
document.getElementById('pay-a-desc').textContent = primaryDesc;
btnA.href = growLinkFor(isBuy() ? 'onetime' : 'setup', plan); btnA.style.display = '';
cardB.style.opacity = '0.4'; cardB.style.pointerEvents = 'none';
cardB.classList.remove('active-pay');
afterBtn.classList.remove('show');
}
}
function afterSetupPay() {
if (plan) { localStorage.setItem('s4r_plan', plan); localStorage.setItem('s4r_track', track); localStorage.setItem('s4r_mode', mode); }
setTimeout(() => document.getElementById('btn-after-setup').classList.add('show'), 1800);
}
function unlockMonthly() {
document.getElementById('pay-a').className = 'pay-card done-pay';
document.getElementById('pay-a-num').textContent = '✓';
document.getElementById('btn-after-setup').classList.remove('show');
const b = document.getElementById('pay-b');
b.style.opacity = '1'; b.style.pointerEvents = 'auto';
b.classList.add('active-pay');
document.getElementById('monthly-actions').classList.add('show');
}
function afterMonthlyPay() {
if (plan) { localStorage.setItem('s4r_plan', plan); localStorage.setItem('s4r_track', track); localStorage.setItem('s4r_mode', mode); }
setTimeout(() => go(7), 1200);
}
/* ================================================================
FORM SUBMIT
================================================================ */
function submitData() {
fetch(WP_ENDPOINT, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
plan, track, mode,
name: v('f-name'), phone: v('f-phone'), email: v('f-email'),
domain_choice: domain,
domain_existing: v('f-domain-exist'), domain_pref: v('f-domain-pref'),
biz_name: v('f-biz-name'), biz_type: v('f-biz-type'), services: v('f-services'),
catalog_size: v('f-catalog-size') || null,
logo: mini.logo || null, photos: mini.photos || null, style_pref: mini.style || null,
coupon_code: coupon?.code || null,
referral: v('f-referral') || null,
submitted_at: new Date().toISOString(),
}),
}).catch(() => {});
}
/* ================================================================
VALIDATION - only called when going forward
================================================================ */
function validate(step) {
if (step === 1) {
if (!plan) { flash('בחר חבילה להמשיך'); return false; }
return true;
}
if (step === 2) {
if (!v('f-name') || !v('f-phone') || !v('f-email')) { flash('אנא מלא את כל שדות החובה'); return false; }
if (!v('f-email').includes('@')) { flash('אנא הזן כתובת אימייל תקינה'); return false; }
return true;
}
if (step === 3) {
if (!domain) { flash('בחר אפשרות דומיין להמשיך'); return false; }
if (domain === 'existing' && !v('f-domain-exist')) {
flash('נא להזין את כתובת הדומיין הקיים');
return false;
}
return true;
}
if (step === 4) {
if (!v('f-biz-name') || !v('f-biz-type') || !v('f-services')) { flash('אנא מלא את שדות החובה'); return false; }
return true;
}
if (step === 5) {
if (!termsOk) { flash('אשר את תנאי השימוש להמשיך'); return false; }
if (!understoodOk) { flash('אשר את הבנתך לגבי תהליך העלייה לאוויר'); return false; }
return true;
}
return true;
}
function v(id) { return document.getElementById(id)?.value?.trim() || ''; }
let _toastTimer = null;
function flash(msg) {
const t = document.getElementById('s4r-toast');
t.textContent = msg;
t.classList.add('show');
clearTimeout(_toastTimer);
_toastTimer = setTimeout(() => t.classList.remove('show'), 3200);
}
/* ================================================================
INIT - read ?track=&mode=&plan= from URL
================================================================ */
(function initFromUrl() {
const params = new URLSearchParams(window.location.search);
/* Return from Grow payment (?paid=setup) - restore state, jump to step 7 */
if (params.get('paid') === 'setup') {
const savedPlan = localStorage.getItem('s4r_plan');
const savedTrack = localStorage.getItem('s4r_track') || 'brochure';
const savedMode = localStorage.getItem('s4r_mode') || 'rent';
track = savedTrack; mode = savedMode;
setMode(mode, { keepPlan: true, preselect: savedPlan });
if (savedPlan && currentPlanData(savedPlan)) plan = savedPlan;
localStorage.removeItem('s4r_plan'); localStorage.removeItem('s4r_track'); localStorage.removeItem('s4r_mode');
history.replaceState({}, '', window.location.pathname);
document.getElementById('s1').style.display = 'none';
cur = 7;
document.getElementById('s7').style.display = 'block';
drawProgress();
return;
}
const rawTrack = (params.get('track') || 'brochure').toLowerCase();
track = CATALOG[rawTrack] ? rawTrack : 'brochure';
/* תמיכה בקישורים ישנים - סלאגים באנגלית וגם שם עברי ישיר.
אותם 3 שמות (starter/professional/growth, וגם X-sale לקנייה) עובדים גם לתדמית וגם לחנות -
ה-track (?track=brochure|store) הוא מה שקובע איזה CATALOG בפועל נטען, לא הסלאג עצמו. */
const PLAN_SLUGS = {
starter: 'התחלה', professional: 'מקצועית', growth: 'צמיחה',
/* אין 'growth-sale' בכוונה - צמיחה לא קיימת כאפשרות רכישה, ראה CATALOG. */
'starter-sale': 'התחלה', 'professional-sale': 'מקצועית',
};
const rawPlan = params.get('plan');
const preselect = rawPlan ? (PLAN_SLUGS[rawPlan.toLowerCase()] || rawPlan) : null;
/* מצב: אם ה-slug מסתיים ב-"-sale", מצב הקנייה מוסק אוטומטית מהשם (לינק אחד, בלי צורך ב-&mode=buy נפרד).
פרמטר ?mode= מפורש תמיד מנצח אם קיים. */
const rawMode = params.get('mode');
if (rawMode) {
mode = (rawMode.toLowerCase() === 'buy') ? 'buy' : 'rent';
} else if (rawPlan && rawPlan.toLowerCase().endsWith('-sale')) {
mode = 'buy';
} else {
mode = 'rent';
}
setMode(mode, { preselect });
})();
drawProgress();