I was hoping to create a dynamic form on our PreCart page using a JavaScript function that would generate the form fields based on the contents of the cart before checkout. The form data would be validated through an API call in the JavaScript, and the cart validation would then be dependent on the response from the JavaScript form. I see in the comments for the LWP_VALIDATE_CART procedure, that this might be possible, but I don't quite get how its supposed to be done.
The part I don't quite understand is: "it may use javascript to define a button, radio buttons, dropdown list or check boxes which when clicked will return to this proc for further processing by making HREF="/precart/precart.asmx?p=1005405001" where 1005405001 indicates the particular button being clicked including an integer value that may be the encryption of the results of the control."
My idea would be that the JavaScript would handle all form validations with URL redirects or message inserts. But I also want to return the form data, as well as some data from the API back to the procedure, so that it can be stored in a local table for reporting and tracking purposes.
Anyone have thoughts on how this last part can be accomplished? Or know that its not possible with the validate cart procedure?
Jesse,
If you are still looking into this, unless I am misunderstanding something here, it should actually be easier than that to pass data back to the procedure. I wrote a simple precart suggested donation form for our subscription sales this year that loaded a custom form with a patron-specific custom suggested donation value that would then take that number and pass it back to the procedure so that could be added as a donation to the order.
You should be able to use the form syntax they give you on this page https://www.tessituranetwork.com/TNEW_7/TNEW.htm#Topics/Customizations.htm?Highlight=precart under "Example 2", "Single Optional Parameter", and use that to set up as many fields as you need. I am currently setting up an education form that dynamically builds the number of entries needed based upon the number of registrations selected using that as a basis. Then it is just a matter of passing the fields back to the procedure.
As far as the long number "p=1005405001", my understanding is that what that would do is to reload that same precart page, and you would either have specific instructions in the procedure to reload the same page, with or without changes, or something of that nature.
Best of luck!
John
Ok, so If I am understanding the documentation correctly, I first need to write a stored procedure that is capable of processing the data provided by the form. Then the form action will call that URL that actually calls the local procedure that is capable of executing the procedure using the form data as the parameters. Am I on the right track here?
Yes, so for example, in the suggested donation form I mention above, I do the following:
So in what order you write your procedures I suppose might vary based on how you map it out, but essentially you need 2 procedures. The one loading the precart page and the one processing the form information using the parameters as specified by the form. Depending upon your logic, you can keep calling the same procedure over and over depending on the results of the form input, but that is all up to you.
Let me know if any of that does not make sense. It would not be the first time.
This is super helpful. I think I have enough information to start playing around with the process. From here I might just need to dive in and actually try it out to start making sense of it. Thanks!