Show the portion of code where you delete the cart after a successful
transaction.

DW
On Oct 29, 2012 10:41 AM, "Jeff P" <[email protected]> wrote:

> Hey everybody,
>
> I'm experiencing so strangeness with sessions and am hoping you folks
> could shed some light on on what's happening. I have a cart app in MG
> 3.1.299. When I complete an order and delete the cart from the session and
> show the order complete page a dump of the session shows the cart is no
> longer in the session scope. However, another call to the session on the
> same page shows the cart as a valid struct within the session.
>
> In my Controller.cfc I have an onRequestStart function that copies the
> cart and the user (if they exist) to the event scope. I also have it
> copying the entire session through the UserSession.cfc to try to figure
> this out. Here are the pertinent parts of my controller.cfc and
> userSession.cfc:
>
> *Controller.cfc*
>
>          <cffunction name="onRequestStart" access="public" output="false">
> <cfargument name="event" type="any">
>  <!--- copy the cart to the event scope if it exists. --->
> <cfif beans.UserSession.cartExists()>
> <cfset arguments.event.setValue("currentCart",
> beans.UserSession.getCurrentCart())>
> </cfif>
>  <!--- and for the user if they're logged in. --->
> <cfif beans.UserSession.loggedIn()>
> <cfset arguments.event.setValue("currentUser",
> beans.UserSession.getCurrentUser())>
> </cfif>
>  <!--- return the whole session for some testing --->
> <cfset arguments.event.setValue("userSession",
> beans.UserSession.getSession())>
> </cffunction>
>
> *UserSession.cfc*
>
>         <cffunction name="cartExists" access="public" output="false">
> <cflock timeout="3" type="readonly" scope="session">
> <cfreturn structKeyExists( session, "cart" )>
> </cflock>
> </cffunction>
>
>         <cffunction name="getCurrentCart" access="public" output="false">
> <cflock timeout="3" type="readonly" scope="session">
> <cfreturn session.cart>
> </cflock>
> </cffunction>
>  <cffunction name="getCurrentUser" access="public" output="false">
> <cflock timeout="3" type="readonly" scope="session">
> <cfreturn session.user>
> </cflock>
> </cffunction>
>  <cffunction name="getSession" access="public" output="false">
> <cflock timeout="3" type="readonly" scope="session">
> <cfreturn session>
> </cflock>
> </cffunction>
>
>         <cffunction name="loggedIn" access="public" output="false">
> <cflock timeout="3" type="readonly" scope="session">
> <cfreturn structKeyExists( session, "user" )>
> </cflock>
> </cffunction>
>
> In my template I have a chink of code that displays a link to the cart if
> it exists and has at least one item in it:
>
> If I use the currentCart variable set in Controller.cfc, it returns the
> cart from the session after the order is processed even though a cfdump of
> the session shows it isn't there.
>
> <cfif isStruct(variables.currentCart) and
> variables.currentCart.getItemCount() gte 1>
> <div class="row-fluid">
> <div id="viewCart" class="span12">
> <a href="#click_ViewCart#">Your cart: <span
> class="bold">#variables.currentCart.getItemCount()#</span> item<cfif
> variables.currentCart.getItemCount() neq 1>s</cfif></a> <a
> href="#click_ViewCart#"><img src="images/shoppingCart.png" alt="view
> cart"></a>
> </div>
> </div>
> </cfif>
>
> *The display section still shows up after the order is complete*.
>
> But, If I use the entire getSession function from the Controller.cfc it
> acts as it's supposed to:
>
> <cfif structKeyExists(variables.userSession, "cart") and
> variables.userSession.cart.getItemCount() gte 1>
> <div class="row-fluid">
> <div id="viewCart" class="span12">
> <a href="#click_ViewCart#">Your cart: <span
> class="bold">#variables.userSession.cart.getItemCount()#</span> item<cfif
> variables.userSession.cart.getItemCount() neq 1>s</cfif></a> <a
> href="#click_ViewCart#"><img src="images/shoppingCart.png" alt="view
> cart"></a>
> </div>
> </div>
> </cfif>
>
> *The display section doesn't show up after the order is complete.*
>
> How can one call to the session return that the cart doesn't exist and
> then a second, later call to the session on the same page return that it
> does?
>
> Thank you for looking at this,
>
> Jeff P.
>
> --
> Model-Glue Sites:
> Home Page: http://www.model-glue.com
> Documentation: http://docs.model-glue.com
> Bug Tracker: http://bugs.model-glue.com
> Blog: http://www.model-glue.com/blog
>
> You received this message because you are subscribed to the Google
> Groups "model-glue" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/model-glue?hl=en

-- 
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog

You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

Reply via email to