在开始之前,我发现了这一点: 使用他们的 API 创建一个基本的 MailChimp 注册表单,这似乎可以满足我的要求,但需要注意的是:
我的表格在 Shopify 上。这是一个应用程序,可让客户在产品有货时收到通知。我想要一个复选框,让他们也可以订阅我们的时事通讯。所以最终结果是它仍然会发布到应用程序,但会将它们添加到我们的时事通讯数据库中。
上述解决方案可以远程完成吗?即我把 PHP 文件放在我的主网站上,并让 ajax 指向 url?有没有更简单的方法来做到这一点?
<script type="text/javascript">
$(document).ready(function() {
var create_callback = function(data) {
if (data.status == 'OK') {
$.fancybox({
'href': '#inline_message'
});
//alert(data.message);
} else {
//alert("Oops! An error occurred. Please check the email address you entered and try again.");
$.fancybox({
'href': '#inline_message'
});
$("#inline_message").html('<h3>Oops! Looks like an error occurred.</h3> <p>Please check the email address you entered and try again.</p>');
}
}
$('#notify_button').click(function(event) {
event.preventDefault();
BISPopover.create($('#notify_email').val(), $('#product-select :selected').val()).then(create_callback);
});
$('#BIS_form_submit').submit(function() {
var isChecked = $('#chkSelect').is(':checked');
if(isChecked){
$.ajax({
url: 'http://www.myURL.com/inc/store-address.php', // proper url to your "store-address.php" file
data: $('#BIS_form_submit').serialize(),
success: function(msg) {
$('#message').html(msg);
}
});
return false;
}
});
});
</script>
<div id="BIS_form">
<form id="BIS_form_submit">
<input type="hidden" name="ajax" value="true" />
<h3 id="notify-title">Notify me when this is back in stock:</h3>
<input type="email" id="notify_email" value="Email address" onfocus="value=''"/>
<button id="notify_button" class="first">Submit</button>
<input type="checkbox" id="chkSelect" /><span style="font-size:10px;position:relative;top:3px;left:3px;">Add me to the Newsletter</span>
</form>
</div>