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
04-Aug-11 10:12:42
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
Cheers,
Stephen
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
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();
}
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();
}
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();
}
Re: Empty Virtuemart cart if user is re-directed to specific URL.
YEEES It worked!!!
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.
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
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();
}
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5943
- Posts this week:
- 2
- User Info:
- Total Users:
- 7642
- Newest User:
- mary26
- Members Online:
- 0
- Guests Online:
- 241
- 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