Announcement

Collapse
No announcement yet.

strange problem with BasketInfo & CFM module

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    strange problem with BasketInfo & CFM module

    Hi folks,

    One of the stores I'm working on just developed an odd problem. It only happens if you log in to an account, say "Customer A;" go part way thru checkout, then log out, and log back in as Customer B. Everything looks fine until you go to checkout. Then, on the OCST page, Customer A's info shows up, even though you're now logged in as someone else.

    I took a look at the DB, and I see that the problem is apparently caused by the customfields module. It's saving a copy of the entire basket status, including the customer ID, into the BasketInfo table. Once that info has been saved, it doesn't get deleted when you log out; and it doesn't get changed when you log back in. And when you get to OCST, this saved info is used to fill in all the fields, instead of the actual info for the account that you're currently logged in to.

    After looking at the customfields module source code in the LSK, I gather that this behavior is triggered by a couple of mvt:item tags. The module creates the BasketInfo when rendering OSEL, and reads it when rendering OCST. It looks like these tags are part of the Suivant theme. Is this a Suivant bug? It seems strange for the read operation to occur before the write.

    Thanks --
    Last edited by Kent Multer; 11-25-15, 02:58 AM.
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    #2
    Re: strange problem with BasketInfo & CFM module

    This is template code we have in the Suivant readytheme to save the customer fields so if they go though checkout and leave in the middle the fields they have filled in are already populated for them when they return (same basket session only).

    On OCST you will find this logic:

    Code:
    <mvt:item name="customfields" param="Read_Basket('basket', g.saved_fields)" />
    <mvt:if expr="NOT ISNULL g.saved_fields" >
        <mvt:assign name="g.ShipFirstName" value="g.saved_fields:ship_fname" />
        <mvt:assign name="g.ShipLastName" value="g.saved_fields:ship_lname" />
        <mvt:assign name="g.ShipEmail" value="g.saved_fields:ship_email" />
        <mvt:assign name="g.ShipCompany" value="g.saved_fields:ship_comp" />
        <mvt:assign name="g.ShipPhone" value="g.saved_fields:ship_phone" />
        <mvt:assign name="g.ShipFax" value="g.saved_fields:ship_fax" />
        <mvt:assign name="g.ShipAddress1" value="g.saved_fields:ship_addr1" />
        <mvt:assign name="g.ShipAddress2" value="g.saved_fields:ship_addr2" />
        <mvt:assign name="g.ShipCity" value="g.saved_fields:ship_city" />
        <mvt:assign name="g.ShipStateSelect" value="g.saved_fields:ship_state" />
        <mvt:assign name="g.ShipState" value="g.saved_fields:ship_state" />
        <mvt:assign name="g.ShipZip" value="g.saved_fields:ship_zip" />
        <mvt:assign name="g.ShipCountry" value="g.saved_fields:ship_cntry" />    
        <mvt:assign name="g.BillFirstName" value="g.saved_fields:bill_fname" />
        <mvt:assign name="g.BillLastName" value="g.saved_fields:bill_lname" />
        <mvt:assign name="g.BillEmail" value="g.saved_fields:bill_email" />
        <mvt:assign name="g.BillCompany" value="g.saved_fields:bill_comp" />
        <mvt:assign name="g.BillPhone" value="g.saved_fields:bill_phone" />
        <mvt:assign name="g.BillFax" value="g.saved_fields:bill_fax" />
        <mvt:assign name="g.BillAddress1" value="g.saved_fields:bill_addr1" />
        <mvt:assign name="g.BillAddress2" value="g.saved_fields:bill_addr2" />
        <mvt:assign name="g.BillCity" value="g.saved_fields:bill_city" />
        <mvt:assign name="g.BillStateSelect" value="g.saved_fields:bill_state" />
        <mvt:assign name="g.BillState" value="g.saved_fields:bill_state" />
        <mvt:assign name="g.BillZip" value="g.saved_fields:bill_zip" />
        <mvt:assign name="g.BillCountry" value="g.saved_fields:bill_cntry" />
    </mvt:if>
    We are reading the fields in from the custom basket field (if it exists) and populating the variables on the page.

    There is also this tag on OSEL to save the fields:

    Code:
    <mvt:item name="customfields" param="Write_Basket('basket', g.basket)" />
    If you don't need/want this functionality you can remove the code from the pages.
    Last edited by Brennan; 11-25-15, 02:22 PM.
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      Re: strange problem with BasketInfo &amp; CFM module

      Hi Brennan,

      Thanks for the clarification. I do think I found a small bug in this implementation. If a customer goes into checkout as far as the OSEL page, and then goes back and logs into a different account, the saved name & address will show up when they return to OCST. Of course, that isn't a very common scenario. We stumbled on it because we're doing some heavy testing of our customized checkout, and this involves switching between 2 or 3 different accounts without completing an order.

      An easy fix would be to delete the saved BasketInfo whenever a customer logs in. The CFM module doesn't have a Delete_Basket function; maybe someone can make a note to add that feature. For now, I can write a fix into one of the custom modules; or we can just remove the Read_Basket and Write_Basket, as you suggested.

      Thanks --
      Kent Multer
      Magic Metal Productions
      http://TheMagicM.com
      * Web developer/designer
      * E-commerce and Miva
      * Author, The Official Miva Web Scripting Book -- available on-line:
      http://www.amazon.com/exec/obidos/IS...icmetalproducA

      Comment


        #4
        Re: strange problem with BasketInfo &amp; CFM module

        Follow-up: I just thought of a simple way to fix this problem. I wrapped the OCST code with an mvt:if element, so that it will not be executed if the customer is logged in. That allows the name & address info from the customer's account to appear.

        Specifically:
        Code:
        <mvt:if expr="NOT g.Customer:id">
        	<mvt:item name="customfields" param="Read_Basket('basket', g.saved_fields)" />
        	<mvt:if expr="NOT ISNULL g.saved_fields" >
        		<mvt:assign name="g.ShipFirstName" value="g.saved_fields:ship_fname" />
        		<mvt:assign name="g.ShipLastName" value="g.saved_fields:ship_lname" />
        		<mvt:assign name="g.ShipEmail" value="g.saved_fields:ship_email" />
        		<mvt:assign name="g.ShipCompany" value="g.saved_fields:ship_comp" />
        		<mvt:assign name="g.ShipPhone" value="g.saved_fields:ship_phone" />
        		<mvt:assign name="g.ShipFax" value="g.saved_fields:ship_fax" />
        		<mvt:assign name="g.ShipAddress1" value="g.saved_fields:ship_addr1" />
        		<mvt:assign name="g.ShipAddress2" value="g.saved_fields:ship_addr2" />
        		<mvt:assign name="g.ShipCity" value="g.saved_fields:ship_city" />
        		<mvt:assign name="g.ShipState" value="g.saved_fields:ship_state" />
        		<mvt:assign name="g.ShipZip" value="g.saved_fields:ship_zip" />
        		<mvt:assign name="g.ShipCountry" value="g.saved_fields:ship_cntry" />	
        		<mvt:assign name="g.BillFirstName" value="g.saved_fields:bill_fname" />
        		<mvt:assign name="g.BillLastName" value="g.saved_fields:bill_lname" />
        		<mvt:assign name="g.BillEmail" value="g.saved_fields:bill_email" />
        		<mvt:assign name="g.BillCompany" value="g.saved_fields:bill_comp" />
        		<mvt:assign name="g.BillPhone" value="g.saved_fields:bill_phone" />
        		<mvt:assign name="g.BillFax" value="g.saved_fields:bill_fax" />
        		<mvt:assign name="g.BillAddress1" value="g.saved_fields:bill_addr1" />
        		<mvt:assign name="g.BillAddress2" value="g.saved_fields:bill_addr2" />
        		<mvt:assign name="g.BillCity" value="g.saved_fields:bill_city" />
        		<mvt:assign name="g.BillState" value="g.saved_fields:bill_state" />
        		<mvt:assign name="g.BillZip" value="g.saved_fields:bill_zip" />
        		<mvt:assign name="g.BillCountry" value="g.saved_fields:bill_cntry" />	
        	</mvt:if>
        </mvt:if>
        Hope that's helpful --
        Kent Multer
        Magic Metal Productions
        http://TheMagicM.com
        * Web developer/designer
        * E-commerce and Miva
        * Author, The Official Miva Web Scripting Book -- available on-line:
        http://www.amazon.com/exec/obidos/IS...icmetalproducA

        Comment

        Working...
        X