Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Empty Virtuemart cart if user is re-directed to specific URL.

Empty Virtuemart cart if user is re-directed to specific URL.

Hello,

Do you know if it is possible to call SESSION which will empty Virtuemart shopping cart if user was re-directed to specific shop URL, in my case it would be checkout.cancel site.
Shooping cart is conrolled by Virtuemart file /administrator/components/com_virtuemart/classes/ps_cart.php and command to empty cart is called from a file ps_checkout.php

$ps_cart->reset();

$_SESSION['savedcart']['idx']=0;

$ps_cart->saveCart();

Would be great to do this trick with MetaMod module smile

Edited By: zmogus
04-Aug-11 09:12:42

zmogus
Beginner Modder
ranks
useravatar
Offline
10 Posts
Administrator has disabled public posting

Re: Empty Virtuemart cart if user is re-directed to specific URL.

Maybe it is somehow possible to call a SESSION ps_carrt reset?
I tried to find example how to call other sessions but could nto find it.

zmogus
Beginner Modder
ranks
useravatar
Offline
10 Posts
Administrator has disabled public posting

Re: Empty Virtuemart cart if user is re-directed to specific URL.

I haven't tried this, but it will probably work as long as VM has been loaded on the page (which it probably has been as long as there's a VM module on the page, or it's a VM page):

if (some_condition_here...) {
  require_once(CLASSPATH.'ps_cart.php');
  $ps_cart = new ps_cart;
  $ps_cart->reset();
  $_SESSION['savedcart']['idx']=0;
  $ps_cart->saveCart();
}


I'd love to know if this works for you smile

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: Empty Virtuemart cart if user is re-directed to specific URL.

Hi Stephen,

Thank you for quick reply. Sorry for asking, how I should write a condition for specific URL which starts http://www .domain.com/index.php?option=com_virtuemart&page=checkout.gatewayresult&transactionId=

After word transactionId= every time will be different transaction ID written, so I can add contion as static URL. IF I would add % in the end will it work?

Cheers

zmogus
Beginner Modder
ranks
useravatar
Offline
10 Posts
Administrator has disabled public posting

Re: Empty Virtuemart cart if user is re-directed to specific URL.

I tried to do a test if user goes to Frontpage cart should reset. but it did not worked forme, my code was:

$vm = JomGenius("virtuemart"); // need this at the start of every rule
if ( $core_genius->vmcheck( "pagetype = frontpage"))
{
  require_once(CLASSPATH.'ps_cart.php');
  $ps_cart = new ps_cart;
  $ps_cart->reset();
  $_SESSION['savedcart']['idx']=0;
  $ps_cart->saveCart();
}

zmogus
Beginner Modder
ranks
useravatar
Offline
10 Posts
Administrator has disabled public posting

Re: Empty Virtuemart cart if user is re-directed to specific URL.

This should do what you want:

if ($option == "com_virtuemart" and JRequest::getVar("page") == "checkout.gatewayresult") {
  require_once(CLASSPATH.'ps_cart.php');
  $ps_cart = new ps_cart;
  $ps_cart->reset();
  $_SESSION['savedcart']['idx']=0;
  $ps_cart->saveCart();
}

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: Empty Virtuemart cart if user is re-directed to specific URL.

The rule you suggested was slightly wrong. You could use this instead:

$vm = JomGenius("virtuemart"); // need this at the start of every rule
if ( $vm->check( "pagetype = frontpage"))
{
  require_once(CLASSPATH.'ps_cart.php');
  $ps_cart = new ps_cart;
  $ps_cart->reset();
  $_SESSION['savedcart']['idx']=0;
  $ps_cart->saveCart();
}

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: Empty Virtuemart cart if user is re-directed to specific URL.

YEEES It worked!!! smile
Very big thank you to you, Stephen.

It emptied the shopping cart. It is a cool feature. I was trying to modify my payment method code but later I remembered about existence of a great module METAMOD, and i was right it did a trick.

zmogus
Beginner Modder
ranks
useravatar
Offline
10 Posts
Administrator has disabled public posting

Re: Empty Virtuemart cart if user is re-directed to specific URL.

Hi,

Your suggested code worked perfect. But I have discovered that this code will nto work if i will created one more Metamod module for other payment method.
I have two payment methods and each method ReturnURL is different.
For a first one:
getVar("page") == "checkout.gatewayresult"
and for the second one:
getVar("page") == "checkout.thankyou"

Will two variables work in one Metamod module?

Cheers

zmogus
Beginner Modder
ranks
useravatar
Offline
10 Posts
Administrator has disabled public posting

Re: Empty Virtuemart cart if user is re-directed to specific URL.

When I tired to make code like the one below it not works:

if ($option == "com_virtuemart" and JRequest::getVar("page") == "checkout.gatewayresult") {
  require_once(CLASSPATH.'ps_cart.php');
  $ps_cart = new ps_cart;
  $ps_cart->reset();
  $_SESSION['savedcart']['idx']=0;
  $ps_cart->saveCart();
}

if ($option == "com_virtuemart" and JRequest::getVar("page") == "checkout.thankyou") {
  require_once(CLASSPATH.'ps_cart.php');
  $ps_cart = new ps_cart;
  $ps_cart->reset();
  $_SESSION['savedcart']['idx']=0;
  $ps_cart->saveCart();
}

zmogus
Beginner Modder
ranks
useravatar
Offline
10 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5913
Dormant:
User Info:
 
Total Users:
10778
Newest User:
negina4qx
Members Online:
0
Guests Online:
192

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked