TNEW PreCart Forms

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?

Parents
  • 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

Reply
  • 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

Children
  • 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:

    • I use LWP_VALIDATE_CART to do nothing but call a procedure I wrote called LWP_CP_PRECART_CUSTOMIZATIONS (this is because we have a number of precart cusomizations, so I save some brain power by separating them out by having different validation numbers calling different procedures.  I gave them better names as they went on.
    • In LWP_CP_PRECART_CUSTOMIZATIONS, for the suggested donation, at the top, I have my two hidden input types with the values of "true" and "68" as well as then my desired parameter in the body for the next procedure of donation_amt, 68 being the ID from TR_LOCAL_PROCEDURE where I have placed the procedure LWP_CP_ADD_CONT_TO_ORDER which takes the parameters @sessionKey and @donation_amt with the submit button at the end.  (I also have a "no thanks" button for those souls who choose not to donate to take them directly to the cart.)
    • Then LWP_CP_ADD_CONT_TO_ORDER takes care of the work of adding the contribution to the order.  Because I wanted to do as little work as possible, that procedure actually calls another one, LWP_CP_MAINTAIN_CART_CONTRIBUTION which is a SUPER MINOR update to the standard WP_MAINTAIN_CART_CONTRIBUTION.  Plus, that way I ensure that I am not messing anything up that I might have forgotten.
    • Then, at the end of LWP_CP_ADD_CONT_TO_ORDER, I have a quick test to determine whether or not there are additional precart pages that would need to be loaded (like for our Valet or Pre-Show dinners), and it either then calls LWP_VALIDATE_CART again or else just ends allowing the patron to go to the cart.
    • There is also some custom logic back in the first two LWP_VALIDATE_CART and LWP_CP_PRECART_CUSTOMIZATIONS which keep the suggested donation ask to just one time, even if the patron keeps buying things that bring up the valet and pre-show dinner page.

    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.

    John

  • 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!