Author Topic: Cart not emptying  (Read 4018 times)

DeepaVaith

  • Beginner
  • *
  • Posts: 33
Cart not emptying
« on: April 17, 2012, 20:36:30 pm »
Can someone please help me.  This is the paypal.log file after my order is confirmed-but the cart is not empty.
The only time the cart empties is if I go back to the store from the paypal link.  In case I have a few tabs open
with items in the cart, none of the carts empty when the page is refreshed.  Is this intended/bug..It seems an odd
thing to do. 


2012-04-17 18:28:01
message: paypal_data 4.91   b64606   Ineligible   94HWRMKJABBYN   0.00   11:27:54 Apr 17, 2012 PDT   Completed   windows-1252   deepa   0.44   3.4   512383cf2c149c1cb34df1f58f1c3505   verified   deepa_1329192018_biz@yahoo.com   1   AuL6cw-ASsYwHgJfs4X-aE93YB3lAkvo-T8iS0uZRe5yvSl-ZybQU2-7   deepa__1333386065_per@yahoo.com   3X235666C3490850P   instant   vaith   deepa_1329192018_biz@yahoo.com   0.44   VHB2TFSFARJQ4   web_accept   Order Number: b64606   USD      US   1   0.00   512383cf2c149c1cb34df1f58f1c3505   4.91   0.00   1c27f374ac336

2012-04-17 18:28:01
message: process IPN

2012-04-17 18:28:01
message: process IPN OK

2012-04-17 18:28:01
message: plgVmOnPaymentNotification return new_status:C

2012-04-17 18:28:01
message: Notification: emptyCart

DeepaVaith

  • Beginner
  • *
  • Posts: 33
Re: Cart not emptying
« Reply #1 on: April 17, 2012, 20:56:07 pm »
I forgot to mention joomla 1.5 and VM 2.0.6. 
Even letting me know if what I'm asking for is not provided by VM will be great :(

Thanks,
Deepa

DeepaVaith

  • Beginner
  • *
  • Posts: 33
Re: Cart not emptying
« Reply #2 on: April 17, 2012, 21:42:43 pm »
hmm...it seems to have something to do with these lines in vmpsplugin.php in the emptyCart function.
   // Recover session in wich the payment is done
$this->logInfo('Notification: before new session emptyCart ' . $session_id, 'message');
       session_id($session_id);
       session_start();
$this->logInfo('Notification: after new session emptyCart ' . $session_id, 'message');
The first message is logged with the correct session id and the second message is not written out.
The session id matches what is in the database-even if I call the emptycart with this session id it
does not work. 
Is this a bug?  Is there a quick way to fix it....If so, please point me in the right direction.
Oh please let me not be talking to myself here!!!! :)



Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9905
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Cart not emptying
« Reply #3 on: April 17, 2012, 23:52:10 pm »
No, should work imho, but I am just not the expert for this.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

DeepaVaith

  • Beginner
  • *
  • Posts: 33
Re: Cart not emptying
« Reply #4 on: April 18, 2012, 03:49:33 am »
I've tried it in every version from the first release to the 2.0.6.
And it does not work it any version when called from the
plgVmOnPaymentNotification, but works on the click
from Paypal which calls plgVmOnPaymentResponseReceived.
Am I right in this understanding? 
Milbo - thanks for replying.  Though your reply has made things
more confusing :(

alatak

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2047
    • alatak.net
Re: Cart not emptying
« Reply #5 on: April 18, 2012, 12:17:20 pm »
Hi,

Yes you are rigth . The cart is not emptied.
I have fix it for the next version.


Meanwhile you can fix it by changing the code line 450 in file plud-gins/vmpayment/paypal/paypal.php
replace
Code: [Select]
$this->emptyCart($return_context);by
Code: [Select]
$this->emptyCart($paypal_data['custom']);

DeepaVaith

  • Beginner
  • *
  • Posts: 33
Re: Cart not emptying
« Reply #6 on: April 18, 2012, 18:31:13 pm »
Hi, Thanks for your response.  The problem is not solved.   I changed the line in paypal.php.
I've attached the changes in vmpsplugin.php and the output from the paypal.log files
below.

I added more debugging statements to the emptycart function in vmpsplugin.php file
There seems to be a problem in the session_start line in red.  The session id in the
function, matches  the id in the table. 

Please help!

function emptyCart($session_id) {
   if (!class_exists('VirtueMartCart'))
       require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
   $this->logInfo('Notification: emptyCart ' . $session_id, 'message');
/*$_db = JFactory::getDBO();
   $_q = "SELECT data FROM #__session WHERE session_id='".$session_id. "'";

$this->logInfo('Notification: query' . $_q, 'message');
   $_db->setQuery($_q);
   $_r = $_db->loadResult(); // TODO Error check
$this->logInfo('Notification: after query' . $_r, 'message');  */

   if ($session_id != null) {
       $session = JFactory::getSession();
       $session->close();

       // Recover session in wich the payment is done
      $this->logInfo('Notification: after session close', 'message');
       session_id($session_id);
      $this->logInfo('Notification: after getting session', 'message');

          session_start();
      $this->logInfo('Notification: after session_start' . $session_id, 'message');

   }

   $cart = VirtueMartCart::getCart();
   $this->logInfo('Notification: getCart ' . $session_id, 'message');
   $cart->emptyCart();
   $this->logInfo('Notification: final emptyCart ' . $session_id, 'message');
   return true;
    }


Log file from Paypal

2012-04-18 16:23:41

message: plgVmOnPaymentNotification return new_status:C

2012-04-18 16:23:41
message: Notification: emptyCart 2f6956fae42734587377a39c5bfe7970

2012-04-18 16:23:41
message: Notification: after session close

2012-04-18 16:23:41
message: Notification: after getting session

DeepaVaith

  • Beginner
  • *
  • Posts: 33
Re: Cart not emptying
« Reply #7 on: April 19, 2012, 03:48:58 am »
Was anyone able to take a look at it?  I'm really desperate as the launch date for
the site has been postponed due to this problem only. 
Any idea when this can be solved?

Thanks,
Deepa

alatak

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2047
    • alatak.net
Re: Cart not emptying
« Reply #8 on: April 19, 2012, 09:15:40 am »
Hi,

Yes , change this function emptyCart in the file  vmpsplugin.php

Code: [Select]
function emptyCart($session_id) {
if (!class_exists('VirtueMartCart'))
    require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
$this->logInfo('Notification: emptyCart ' . $session_id, 'message');
if ($session_id != null) {
    // Recover session in wich the payment is done
     session_id($session_id);
     session_start();
}

DeepaVaith

  • Beginner
  • *
  • Posts: 33
Re: Cart not emptying
« Reply #9 on: April 19, 2012, 11:14:58 am »
Hi Alatak,
   Thanks for the prompt responses.  Now the cart is emptying, but I am being logged out
too.  Can it be worked such that the user does not have to login again if they have more
than one tab open?
Thanks,
Deepa

DeepaVaith

  • Beginner
  • *
  • Posts: 33
Re: Cart not emptying
« Reply #10 on: April 20, 2012, 10:36:43 am »
Any luck or pointers? 

DeepaVaith

  • Beginner
  • *
  • Posts: 33
Re: Cart not emptying
« Reply #11 on: April 20, 2012, 16:51:09 pm »
Hi!  Please can you tell me if this is something that is likely to be fixed soon?
I am unable to get the contents of the session at that point-if you can tell how to do
that I can try to take it from there.
Thanks.

DeepaVaith

  • Beginner
  • *
  • Posts: 33
Re: Cart not emptying
« Reply #12 on: April 23, 2012, 12:05:46 pm »
Hi! I am sounding like quite a pain...but I'm completely stuck.  My site is ready and this is
the only thing holding up the launch.  Please could you help me with this bug or let
me know if this is not something that is going to be fixed in soon?  I've tried www.vm-expert.com/
too, but there has been no response from them. 
I am really desperate at this stage....

Thanks,
Deepa

DeepaVaith

  • Beginner
  • *
  • Posts: 33
Re: Cart not emptying
« Reply #13 on: April 25, 2012, 18:16:59 pm »
Am I the only one on this forum with this problem?  Please can someone respond.
Thanks,
Deepa