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.

 

Hide VM cart module if cart is empty

Hide VM cart module if cart is empty

Gah, not matter what I try I can't seem to get the right recipe for hiding the VM cart module if there are no items in the cart!

I thought it would be:

Code:


$vm = JomGenius("virtuemart"); // initialise object
if ( $vm->check( "is_cart_populated = false" ) )
return 35;

.. but this doesn't seem to work?

arcascomputing
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: Hide VM cart module if cart is empty

Hi,

yes there's a small bug there - fixing this for the next version.

Meanwhile, you can do it this way which does work:

$vm = JomGenius("virtuemart");
if ( $vm->check("number_cart_items = 0") ) return 35;

Thanks for reporting it,
Stephem

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
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Hide VM cart module if cart is empty

Hi there

Thanks for that, got that working now however the code you supplied would DISPLAY the module if there were no items in it rather than HIDE it.  So for other's reference I tweaked the code to this and it works:

Code:

$vm = JomGenius("virtuemart");

if ( !$vm->check("number_cart_items = 0") ) return 35;

(Just inserted the exclamation mark at the start to trigger PHP's "if not" behaviour.)

arcascomputing
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: Hide VM cart module if cart is empty

Oh, right, yeah, that's what you wanted.

Also I released MetaMod v2.6 yesterday which fixed the original problem. So you can now use this to do the same thing:

Code:

$vm = JomGenius("virtuemart"); // initialise object


if ( $vm->check( "is_cart_populated = true" ) )

return 35;

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
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Hide VM cart module if cart is empty

Good Day,

I just added metamod to the site to hide the cart when empty but it is still showing up. Can you tell me what I may be doing wrong?

Used the code above...tried both of them but neither worked...

site is live at tracyelizabeth.net...

Greatly appreciate the help!

tclarke
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Hide VM cart module if cart is empty

Hi tclarke,

It's probably a setup thing. Please ensure you follow the instructions in the Quick Start guide: http://www.metamodpro.com/metamod/quick-start

In particular, ensure that the cart module is set to "none" menu items, the MetaMod is set to ALL menu items, and the MetaMod is published.

Write back if you're still having problems.

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
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Hide VM cart module if cart is empty

Hi,
using non-pro version right now.

$vm = JomGenius("virtuemart"); // initialise object
if ( $vm->check( "is_cart_populated = true" ) )
return 35;

this works. But I have to refresh the page in order to see the cart module.
I guess this is due to VM ajax.

Will the pro version show the module immediately after a product has been added?
Or is there a workaround I could try?

Cheers,
mizu

mizu
Beginner Modder
ranks
useravatar
Offline
1 Posts
Administrator has disabled public posting

Re: Hide VM cart module if cart is empty

Hi Mizu,

no, unfortunately there's no work-around for this. Modules are only rendered on a full page refresh, so if you have things going on with AJAX then there's no page refresh and hence no chance for MetaMod or any other module to display on the page.

The only way I can think of to attack the problem is to messs with the JS for the product adding, and get it to display something on the page as soon as something is added. But that's not a job for MetaMod, sorry.

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
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1697
Total Polls:
6
Total Posts:
5941
Total Posts Today:
1
User Info:
 
Total Users:
5421
Newest User:
garena99
Members Online:
0
Guests Online:
388

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