How to handle backwards compatibility after WP e-Commerce stopped using $_SESSION?

96 views
Skip to first unread message

Leif-Arne Helland

unread,
Nov 26, 2012, 5:10:29 PM11/26/12
to wordpress-e-c...@googlegroups.com
I have created a shipping module which uses both $_SESSION['wpsc_delivery_country'and $_SESSION['wpsc_zipcode']. After upgrading to 3.8.9 my plugin stopped working, and I had to use $wpsc_cart->delivery_country instead of $_SESSION['wpsc_delivery_country'for the plugin to work on 3.8.9 and later, but I am not sure this is the correct approach. 

What is the best way to handle session data such as delivery country and zip code if I want to support WP e-Commerce 3.8 and higher?

Zao Web Design, LLC

unread,
Nov 26, 2012, 5:13:59 PM11/26/12
to WordPress e-Commerce Plugin Development
Hi Leif,

It would probably always be a good idea to consult the cart object rather than the session if you can.  Prior to 3.8.9, these values were set with $_SESSION, 3.8.9+, they're set using the wpsc_update_customer_meta() API.  I'd advise testing both pre and post 3.8.9 using the cart object checking code and ensuring it is compatible.


Thanks,

M. Justin Sainton
Zao Web Design, LLC
Principal / Project Manager
http://www.zaowebdesign.com
(c) 971.222.6330
(f) 1.413.723.0396



On Mon, Nov 26, 2012 at 2:10 PM, Leif-Arne Helland <leif.arn...@gmail.com> wrote:
I have created a shipping module which uses both $_SESSION['wpsc_delivery_country'and $_SESSION['wpsc_zipcode']. After upgrading to 3.8.9 my plugin stopped working, and I had to use $wpsc_cart->delivery_country instead of $_SESSION['wpsc_delivery_country'for the plugin to work on 3.8.9 and later, but I am not sure this is the correct approach. 

What is the best way to handle session data such as delivery country and zip code if I want to support WP e-Commerce 3.8 and higher?

--
You received this message because you are subscribed to the Google Groups "WordPress e-Commerce Plugin Development" group.
To view this discussion on the web visit https://groups.google.com/d/msg/wordpress-e-commerce-plugin/-/QqNlsP-Azz8J.
To post to this group, send email to wordpress-e-c...@googlegroups.com.
To unsubscribe from this group, send email to wordpress-e-commerc...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/wordpress-e-commerce-plugin?hl=en.

Leif-Arne Helland

unread,
Nov 26, 2012, 5:37:28 PM11/26/12
to wordpress-e-c...@googlegroups.com
Thank you for replying so quickly.

If I only want to support 3.8.9 and later I can use wpsc_get_customer_meta to fetch delivery country, but until then I should check the $wpsc_cart object directly? 

Zao Web Design, LLC

unread,
Nov 26, 2012, 5:39:47 PM11/26/12
to WordPress e-Commerce Plugin Development
IIRC, that should work fine.  Test and let us know!


Thanks,

M. Justin Sainton
Zao Web Design, LLC
Principal / Project Manager
http://www.zaowebdesign.com
(c) 971.222.6330
(f) 1.413.723.0396



Nick Price

unread,
Nov 27, 2012, 1:32:39 PM11/27/12
to wordpress-e-c...@googlegroups.com
I have built my own checkout form using WPEC that fills out a hidden checkout form on the same page using Javascript, so I could do some more advanced things that you cannot normally accomplish.  There are several controls on the page that require a reload, and in a normal installation they come at the top of the page, so that the reload happens before the user types any data into the forms.  On my page, I've got them located later on the page, and when someone modifies their values, all the form data is submitted via AJAX, and then the control is changed, that way the form data is not lost.

Basically, I am setting the "wpsc_checkout_saved_values" and "shippingSameBilling" variables manually.  Is there a way to do this with the new WPEC, or should I just store the data elsewhere and restore it manually when the page is loaded?

Thanks
Nick

--
You received this message because you are subscribed to the Google Groups "WordPress e-Commerce Plugin Development" group.

Nick Price

unread,
Nov 26, 2012, 5:11:54 PM11/26/12
to wordpress-e-c...@googlegroups.com
I am also looking for information on this; I have a lot of code that relies on the "classic" session variables and would love to get "current".

On Nov 26, 2012, at 4:10 PM, Leif-Arne Helland <leif.arn...@gmail.com> wrote:

I have created a shipping module which uses both $_SESSION['wpsc_delivery_country'and $_SESSION['wpsc_zipcode']. After upgrading to 3.8.9 my plugin stopped working, and I had to use $wpsc_cart->delivery_country instead of $_SESSION['wpsc_delivery_country'for the plugin to work on 3.8.9 and later, but I am not sure this is the correct approach. 

What is the best way to handle session data such as delivery country and zip code if I want to support WP e-Commerce 3.8 and higher?

--
You received this message because you are subscribed to the Google Groups "WordPress e-Commerce Plugin Development" group.

Leif-Arne Helland

unread,
Dec 2, 2012, 5:53:33 PM12/2/12
to WordPress e-Commerce Plugin Development
I changed from $_SESSION to $wpsc_cart->delivery_country and tested in
both 3.8.5 and 3.8.9.3, and it works in both versions. Thanks again
for your help.

On 26 Nov, 23:40, "Zao Web Design, LLC" <off...@zaowebdesign.com>
wrote:
> IIRC, that should work fine.  Test and let us know!
>
> Thanks,
>
> *M. Justin Sainton
> Zao Web Design, LLC
> Principal / Project Managerhttp://www.zaowebdesign.com
> (c) 971.222.6330
> (f) 1.413.723.0396*
>
> On Mon, Nov 26, 2012 at 2:37 PM, Leif-Arne Helland <
>
>
>
>
>
>
>
> leif.arne.hell...@gmail.com> wrote:
> > If I only want to support 3.8.9 and later I can use *wpsc_get_customer_meta
> > **to fetch delivery country, but until then I should check the $wpsc_cart
> > object directly? *

Zao Web Design, LLC

unread,
Dec 2, 2012, 6:08:51 PM12/2/12
to WordPress e-Commerce Plugin Development
Glad to hear it, thanks for reporting back!


Thanks,

M. Justin Sainton
Zao Web Design, LLC
Principal / Project Manager
http://www.zaowebdesign.com
(c) 971.222.6330
(f) 1.413.723.0396
--
You received this message because you are subscribed to the Google Groups "WordPress e-Commerce Plugin Development" group.
Reply all
Reply to author
Forward
0 new messages