Zen Cart Logo
Forums / General Questions / persisting form data during checkout ...

persisting form data during checkout ...

Views: 1,735

Results 1 to 20 of 23
8 Nov 2011, 7:37 AM
#1
grossd avatar

grossd

Zen Follower

Join Date:
Sep 2005
Posts:
173
Plugin Contributions:
0

persisting form data during checkout ...

Hello,

Not sure if this is the right forum category for this question, but others didn't seem to fit ...

I'd like to write an SQL query that is parameterized by the current "active" language, so that i retrieve product names in the correct language. I can't find where this information is stored (in the database) or made available in the code (generated constant).

Any help would be much appreciated,

Dan

p.s. if this is the wrong spot for the question, where do such questions belong?

8 Nov 2011, 7:54 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: persisting form data during checkout ...

Why?

zen_get_product_name($products_id) already does that.

8 Nov 2011, 7:58 AM
#3
grossd avatar

grossd

Zen Follower

Join Date:
Sep 2005
Posts:
173
Plugin Contributions:
0

Re: persisting form data during checkout ...

In short -- its the learning curve :-)

btw, getting more and more into mod programming, I really would like to add those zencart idioms, as i learn them, to the wiki page ...

thanks.

8 Nov 2011, 8:45 AM
#4
grossd avatar

grossd

Zen Follower

Join Date:
Sep 2005
Posts:
173
Plugin Contributions:
0

Re: persisting form data during checkout ...

Is there a function that given a category returns linked products? That's what i am basically coding right now.

8 Nov 2011, 10:06 AM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: persisting form data during checkout ...

To use for what purpose?

8 Nov 2011, 10:12 AM
#6
grossd avatar

grossd

Zen Follower

Join Date:
Sep 2005
Posts:
173
Plugin Contributions:
0

Re: persisting form data during checkout ...

I am creating a checkout candy variant module -- that works a bit differently than the ones currently available. It's to support including one or more products during checkout that are then sent to charity. To support indicating which products should appear in the list i am asking the user to create a " charity" category and link products to that category. All active products so linked show up in the charity list during checkout.

Like this i can reuse the current user interface instead of creating a new user interface (and db tables), to indicate which products are eligible for charity.

8 Nov 2011, 10:17 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: persisting form data during checkout ...

So, this is related to stuff in 4 or 5 other threads you've got running already?

8 Nov 2011, 10:19 AM
#8
grossd avatar

grossd

Zen Follower

Join Date:
Sep 2005
Posts:
173
Plugin Contributions:
0

Re: persisting form data during checkout ...

Yes, its the same store we are working on. And i wanted to give it a try and repackage/generalize/parameterize some hard coded functionality into a new community module.

8 Nov 2011, 10:22 AM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: persisting form data during checkout ...

You might consider zen_get_categories_products_list().

And it would be helpful if you kept related posts in one thread for continuity sake, as it helps ensure you get focused advice instead of being asked to explain the goal all over again each time. Also makes it more meaningful to future readers who might be looking for similar answers. And makes moderators' lives easier too.

8 Nov 2011, 10:24 AM
#10
grossd avatar

grossd

Zen Follower

Join Date:
Sep 2005
Posts:
173
Plugin Contributions:
0

Re: persisting form data during checkout ...

ok.

I guess, i wasn't sure where coding questions go -- although they related to an add-on question asked earlier in the add-on topic area.

10 Nov 2011, 12:34 AM
#11
grossd avatar

grossd

Zen Follower

Join Date:
Sep 2005
Posts:
173
Plugin Contributions:
0

Re: persisting form data during checkout ...

I hope this is the right sub forum to ask the following:

I have somewhat enhanced the checkout_shipping page with some checkout "candy" -- adding several input fields to purchase charity products during checkout. A problem i encountered is that when the user wants to change the delivery address, the user leaves the checkout shipping page by pressing the "Change Address" button, which takes the user to the checkout_shipping_address page. When returning from there, all data entered in the charity entry fields is of course gone.

To overcome this problem I registered (via page/checkout_shipping/on_load_main.js) a java script function that attaches a "save_charity_quantities" event handler to the page unload event. This event handler adds parameters to the destination URL (checkout_shipping_address page), which are then picked up by event routines in checkout_shipping_address and passed back, when the user returns to the checkout_shipping page, which then inserts them into the entry fields.

A better approach however, would be to use cookies and just store candy quantities in cookies and then retrieve them in the checkout_shipping page. However, this would force the need to use cookies. I understand that zenart typically uses cookies. But also works when cookies are disabled. Does zencart have utility functions to work with cookies -- which take care of situations when cookies are not enabled?

thanks,

Dan

10 Nov 2011, 4:22 AM
#12
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: persisting form data during checkout ...

Actually, Zen Cart doesn't use cookies for any of that data.
The only "cookie" ZC uses is the cookie PHP creates for the session ID, and in that respect ZC doesn't actually "use" or "create" the cookie at all ... PHP does.

The way Zen Cart persists data between pages is through session variables, many of which are actually objects which store and retrieve data from database records and aren't actually storing any session data in and of themselves at all.

You could set session variables for your needs. BUT remember, you're dealing with PERSONAL data when you start through checkout, and as such you start getting very close to things covered by PCI rules.
If you're even remotely considering applying similar persistance on the payments page like you've described for shipping page, you'll be dabbling directly smack in the middle of PCI stuff, and I would suggest you steer as far away from that as possible unless you intend to go fully into it and apply for PCI compliance. I doubt you're really interested in that sort of thing, so I suggest you don't even remotely consider persisting anything related to payments or card numbers or any other selections related to billing. Shipping is already sensitive simply because you're dealing with "identity".

10 Nov 2011, 4:51 AM
#13
grossd avatar

grossd

Zen Follower

Join Date:
Sep 2005
Posts:
173
Plugin Contributions:
0

Re: persisting form data during checkout ...

Thank you for the detailed response, and alerting me to the privacy and compliance issues. Right now its really only the quantity of charity products that are made persistent.

I had though of making these persistent with placing them into $_Session, but wasn't able to learn how the session variable could be set from within java script.

I need to access the charity quantity values after the user presses a change address hyper link -- input fields are not carried over at that point in time, and the only mechanism i found that can access at this stage the values is a java script triggered from the window onunload event.

The other approach i guess could be to turn the hyperlinked change address button to a form with hidden input fields, whereby java script would ensure that those hidden input fields are set -- but then i would change core code in the template file -- something i wanted to avoid.

i now use cookies and it really simplifies matters -- localizing the peristence code to the checkout_shipping page, now i am having the opposite problem -- the cookies set in javascript don't seem to get reset in php -- so the values persist for too long :-)

thanks,

Dan

10 Nov 2011, 5:27 AM
#14
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: persisting form data during checkout ...

Hoping this question doesn't sound obtuse, but ... how is "charity selection" relevant to "shipping choices"?

10 Nov 2011, 5:38 AM
#15
grossd avatar

grossd

Zen Follower

Join Date:
Sep 2005
Posts:
173
Plugin Contributions:
0

Re: persisting form data during checkout ...

Good question.

It is the design choice we took over, when we "inherited" that project. It is less so related to shipping but more so the first page during checkout. One could envision placing it later in the checkout process -- say just before committing to the order -- but the persistence problem, when, say, continuing shopping, and then returning to checkout would still exist.

Perhaps a better solution would be to have a charity page "squeezed" inbetween others during checkout -- but our client would't probably like the additional clicks it requires.

Your question does alert me to the fact that i need a more global solution -- i.e. not persistent between two pages -- but across one shopping experience. To avoid the need to have to re-enter charity selections/quatities. Cookies appear to fit the bill, so does i guess storing data in the session object -- which i guess also persists (for how long actually)?

thank you,

Dan

10 Nov 2011, 5:45 AM
#16
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: persisting form data during checkout ...

Why doesn't it belong on the shopping-cart page? It's essentially a choice with respect to what is included in the overall transaction. Couldn't that be a selection made at that point? The shopping-cart page is really the first step in the actual checkout flow.

10 Nov 2011, 5:54 AM
#17
grossd avatar

grossd

Zen Follower

Join Date:
Sep 2005
Posts:
173
Plugin Contributions:
0

Re: persisting form data during checkout ...

Conceptually, its a last minute choice offered and made by the client -- an impulse buy. Although, i guess the shipping page is not "last minute". It surely worth investigating with the client. It does appears beneficial to have the choice on the cart page -- so that other choices -- that require persistence of data is reduced -- or altogether avoided.

Thinking about it more, i think there is no place in the zencart product selection and order workflow where a value entered in a field normally needs to persist on a form -- unless a client specifically wishes to update the value. So, what we are trying to accomplish adds additional complexity.

10 Nov 2011, 9:23 AM
#18
grossd avatar

grossd

Zen Follower

Join Date:
Sep 2005
Posts:
173
Plugin Contributions:
0

Re: persisting form data during checkout ...

I have trouble deleting the cookies at the end of the order process. For some strange reason the setcookie('chesed_sz','',$pastdate); command executes successfully (returns true), but the cookie continues to live in IE with the original expiration date.

To go away from a cookie solution i found a coded approach, using ajax, that supports via an "RPC" call, to set session variables.

Essentially, i would be creating an rpc.php file that would receive the ajax call and set the session. Something like below (the actual rpc code is from the internet, not adapted yet to my need): I am however wondering whether i am introducing a serious security risk here. What code should rpc.php additionally include, and where should it reside, to avoid opening any security holes?

thank you,

Dan

rpc.php
switch($_REQUEST['action']) {
case 'charity1':
/* do something */
$_SESSION[charity1]= $+POST[var];
break;
...
}

function createRequestObject() {
var ro;
ro = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();

 return ro;

}

var http = createRequestObject();

function sndReq(action) {
http.open('get', 'rpc.php?action='+action);
http.onreadystatechange = handleResponse;
http.send(null);
}

function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
var update = new Array();

      if(response.indexOf('|') != -1) {
           update = response.split('|');
           document.getElementById(update[0]).innerHTML = update[1];
      }
10 Nov 2011, 12:41 PM
#19
grossd avatar

grossd

Zen Follower

Join Date:
Sep 2005
Posts:
173
Plugin Contributions:
0

Re: persisting form data during checkout ...

Hello,

If i were two complete one purchase order, and then without quitting or login out start a second purchase order, would those two purchase orders share the same zenid -- the unique session identifier -- or would the second time arround a different unique zenid be generated? At the end of an order, when the shopping cart is dropped is this the time when the zenid is also destroyed?

If not, is there some identifier that is unique per each end-to-end order.

thanks,

Dan

10 Nov 2011, 2:31 PM
#20
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: persisting form data during checkout ...

The order number (id) is unique to each order. The session id is not reflected in any order records, so is irrelevant.