0

I want to create a custom newsletter subscription using Magento 1.9.1.0.

Currently, I have one newsletter subscription that captures emails and stores it in Newsletter -> Newsletter Subscribers.

I want to create another one that stores it in the same location. This time, when the users subscribe on the new one, it will popup a modal.

Is this possible or is there any other way around for this? Thank you.

EDIT: If possible, is it possible to execute/submit the subscription via Ajax? I think this would solve my problem but I don't know how to write it in Ajax.

asked Aug 16, 2016 at 14:02

1 Answer 1

0

I managed to make it work by using this code from here.

I tweaked the code to fit my current code structure. First, my form has an ID of newsletter-ajax.

Here's what I did with the JavaScript Ajax Code:

  1. Declare this variables var formId = 'newsletter-ajax'; var myForm = new VarienForm(formId, true); var postUrl = "/newsletter/subscriber/new";
  2. Create the ajax function function doAjax() { if (myForm.validator.validate()) { new Ajax.Updater( { success:'formSuccess' }, postUrl, { method:'post', asynchronous:true, evalScripts:false, onComplete:function(request, json) { Element.hide(formId); Element.show('formSuccess'); }, onLoading:function(request, json){ Element.show('formLoader'); }, parameters: $(formId).serialize(true), } ); } }

  3. Create the event observer new Event.observe(formId, 'submit', function(e){ e.stop(); doAjax(); });

Do note that these codes should be inside a <script> tag (pretty sure everyone knows this).

Read more about how I did it at twincreations from the link above.

answered Aug 16, 2016 at 16:26

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.