فــرم ثــبــت ســفــارش
/* End custom CSS */
`}
${is_dummy_markup ? message_position === 'bottom' ? props.ResponseDummyMarkup(message_successIcon, message_proClass) : '' : ''}
${is_dummy_markup ? ' ' : message_position === 'bottom' ? props.SubmitResponseMarkup`${parent}${state}${message_successIcon}${message_errorIcon}${message_proClass}` : ''}
`
parent.activateValidation({"message":"\u0641\u06cc\u0644\u062f \u0636\u0631\u0648\u0631\u06cc \u0627\u0633\u062a.","minLength":1,"maxLength":"","type":"none","required":false,"expression":"null"}, el) }
/>
<${validation.ErrorMessage}
errors=${validation.errors}
name="mf-listing-lname"
as=${html``}
/>
parent.activateValidation({"message":"\u067e\u0631 \u06a9\u0631\u062f\u0646 \u0627\u06cc\u0646 \u0641\u06cc\u0644\u062f \u0627\u0644\u0632\u0627\u0645\u06cc \u0627\u0633\u062a.","minLength":1,"maxLength":"","type":"none","required":true,"expression":"null"}, el)}
/>
<${validation.ErrorMessage}
errors=${validation.errors}
name="mf-telephone"
as=${html``}
/>
parent.activateValidation({"message":"\u0641\u06cc\u0644\u062f \u0636\u0631\u0648\u0631\u06cc \u0627\u0633\u062a.","emailMessage":"\u0644\u0637\u0641\u0627 \u06cc\u06a9 \u0622\u062f\u0631\u0633 \u0627\u06cc\u0645\u06cc\u0644 \u0645\u0639\u062a\u0628\u0631 \u0648\u0627\u0631\u062f \u06a9\u0646\u06cc\u062f","minLength":1,"maxLength":"","type":"none","required":false,"expression":"null"}, el)}
/>
<${validation.ErrorMessage}
errors=${validation.errors}
name="mf-email"
as=${html``}
/>
<${validation.ErrorMessage}
errors=${validation.errors}
name="mf-textarea"
as=${html``}
/>
${(function(){
document.addEventListener("DOMContentLoaded", function() {
// اجرای کد پس از ثبت موفق (چون Entry ثبت میشود، این رویداد اجرا خواهد شد)
jQuery(document).on('metform_after_submit', function(event, response) {
// گرفتن مقادیر فیلدها
const name = jQuery("[name='mf-listing-lname']").val() || "نام وارد نشده";
const email = jQuery("[name='mf-email']").val() || "ایمیل وارد نشده";
const phone = jQuery("[name='mf-telephone']").val() || "تلفن وارد نشده";
const orderDetails = jQuery("[name='mf-textarea']").val() || "توضیحی داده نشده است";
// ساخت پیام واتساپ
const message = `📦 سفارش جدید از سایت عسل پلاست پیشرو
—————————
👤 نام: ${name}
📧 ایمیل: ${email}
📞 تلفن: ${phone}
📝 توضیحات سفارش: ${orderDetails}`;
const url = `https://wa.me/989197821304?text=${encodeURIComponent(message)}`;
// 3. ایجاد لینک واتساپ به شکل دکمه (حل مشکل Pop-up Blocker)
const whatsappLink = jQuery('')
.attr('href', url)
.attr('target', '_blank')
.css({
'display': 'block',
'marginTop': '15px',
'padding': '10px 20px',
'backgroundColor': '#25D366',
'color': 'white',
'textAlign': 'center',
'borderRadius': '5px',
'textDecoration': 'none',
'fontWeight': 'bold',
'cursor': 'pointer'
})
.text('💬 ارسال سفارش به واتساپ');
// 4. ریست کردن فرم
jQuery("form.metform-form")[0].reset();
// 5. نمایش پیام موفقیت سفارشی و دکمه لینک جدید
const success = document.createElement("div");
success.textContent = "✅ درخواست شما با موفقیت ثبت شد. لطفاً برای نهایی کردن روی دکمه زیر کلیک کنید:";
success.style.color = "green";
success.style.marginTop = "10px";
success.style.textAlign = "center";
jQuery("form.metform-form").append(success).append(whatsappLink);
});
});
})()}