Hi! I’m working on a website that uses a donation form. The form is connected to a database and, once submitted, creates a short, in page thank you message. The form was created before I started helping and we cannot change it. In order to track submissions better, I am trying to send anyone who submitted a donation to a thank you page using wix-location code resulting from the “onMessage” action. Unfortunately, nothing is happening.
Here is the code I have set up:
import wixLocation from ‘wix-location’;
export function html4_message(enterpayment) {
//Add your code for this event here:
wixLocation.to(“/holiday-campaign-thanks”);
}
Is there something I need to change? Is there a better way to do this? Thanks so much!
I believe that the wixLocation.to has to be in the $w.onReady(function(){ so maybe try your code like this
import wixLocation from ‘wix-location’;
export function html4_message(enterpayment) {
//Add your code for this event here:
$w.onReady( function (){
wixLocation.to (“/holiday-campaign-thanks”);
}
Thanks for the response. I keep getting an error message on the last } of an unexpected token, so can’t tell if it will work. Are you sure that’s the correct code?
One caveat I forgot to mention - a user submits the form, then is prompted to submit credit card info, then sees the message. Not sure if that extra credit card step will affect this or not.
@eric80159
I presume the form that you are talking about has a submit button… if this is the case you can just click on the button an set it to link to your message page after it submits. No code needed.
@mikemoynihan99 Thanks for the reply. While there is a button, individual pieces of the form is uneditable for some reason. All I can do is edit code or add actions after a message is sent to the donor.
@eric80159 have you got a picture?
@eric80159 i was just giving an example but here is the code with no errors
import wixLocation from ‘wix-location’;
export function html4_message(enterpayment) {
//Add your code for this event here:
$w.onReady( function (){
wixLocation.to(“/holiday-campaign-thanks”);
});
}
usually if it gives you a parsing error i have found it means one of the brackets { }, ( ) is not closed.
@dragonlord4469187 Thanks. The code was accepted, but when I tested in preview, the submission went through but I still wasn’t sent to the other page. Any idea why?
@mikemoynihan99 Above is a picture of all I get when I try to edit the form. I can give the full code if that’s helpful as well.
ok, well now we got some different stuff going on. your using the HTML code to call the form shown in the pic from another site, to simplify, your pasting another website into your website page. So i believe your trying to do the redirect to the thank you page at the wrong end. the submit button that is on that form is not “really” on your website, it is on amazons website which is the site that is hosting the form. I am guessing that this is some kind of amazon webstore or dropship catalog.
The only way you are going to be able to redirect the visitors on your site after they complete their amazon purchase (that is embedded into your site) is one way (to the best of my knowledge).
- Check the setting in your amazon store or payment processor for an option to send them a thank you message or a redirect to your website thank you page URL after the transaction.