Our site uses Newsletter for our mailing list and Event Tickets for tickets for online ticketing. I want to add a checkbox to the ticket order page (which already knows email and name) so purchasers can subscribe to our mailing list at the same time just by checking the box.
I have achieved this – sort of – by adding some Javascript to the Ticket Checkout page:
(I tried to post some Javascript here but it got blocked as unsafe. Essentially it was:
Create a JSON object with email address/name
Open a link to wp-json/newsletter/v2/subscriptions with an XMLHttpRequest
Post the Json to the Newsletter plugin)
This does indeed add the subscriber to the Newsletter plugin but no List is selected (I have three) and recipients complain of multiple confirmation emails from the Newsletter plugin. This seems like a pretty basic requirement – is there a proper way integrating ticket ordering with newsletter subscription? Should I be communicating from the Server side?
Any suggestions gratefully received!