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 Virtuemart category based on geoip

Hide Virtuemart category based on geoip

I'm trying to figure out a way to hide a particular Virtuemart category from shoppers outside the United States?

I've done rules based on VM cat id, but I have not done a rule that hides a category.  I'm thinking between Metamod , Chameleon and Advanced Module Manager I am hoping to figure this out.

if $geoip->country_code != 'US') {
    //hide VM category
}

Any tips will be appreciated!
Thank you for your time.

mowlman
Beginner Modder
ranks
useravatar
Offline
6 Posts
Administrator has disabled public posting

Re: Hide Virtuemart category based on geoip

Hi mowlman,

Can you clarify what you mean by "hiding a category"?

1. is the category displayed in a module, as one in a list of categories?
2. is it a module all by itself? (1 category per module, somehow?)
3. is it in the main VM component?
4. or are you happy for the category to appear in the module/component, but will just redirect people away from the page they land on if they are not in the US?

There will be different solutions for each scenario.
In 1, you'll need to edit the module used to display the list of categories
In 2 you can use MetaMod alone
In 3 you'll need to edit some of the VM template files
In 4 you can do this with MetaMod or Chameleon - just trigger a redirect.

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

Re: Hide Virtuemart category based on geoip

Hi Stephen, this is exactly the issue I am facing as well.

In my case I am using Virtuemart Categories to separate categories for different regions

Redirecting to a specific page doesn't work for me as the categories and subcategories are pretty complex, I just want to enable all virtuemart products in my menu and then hide non-relevant ones by geoip region.

Can you offer some advice on the VM template file edits you refer to and how to implement them into a Chameleon rule.

Cheers

metabern
Beginner Modder
ranks
useravatar
Offline
18 Posts
Administrator has disabled public posting

Re: Hide Virtuemart category based on geoip

Hi metabern,

You mention "in my menu..." so I wonder if this might be simpler than you think smile
If you mean that you have made Joomla menu items using the menu manager (and not some other sort of dynamic menu of VM categories, perhaps provided in a VM module), then it's really easy to selectively disable these using Chameleon.

The basic setup will be that you create a rule that detects the GeoIP country/region, and in the Succeed Action you select all the menu items you want it to disable.
Make a new rule for each country/region you want to detect.

The biggest challenge that can occur as you scale your site is keeping these rules up to date as you add/edit countries and/or categories and menu items.

To make this easier, there's a cool trick you can do with the Succeed Action. That is, instead of choosing the menu items to disable 1-at-a-time, you can use the control called "Unpublish menu items where note…". Because menu items can have a note associated with them, you can use this note to control the Chameleon succeed action.
e.g. for all menu items that are for USA only, you could add a note:  VM-USA
Then for visitors from the USA you want your rule to remove all VM menu items EXCEPT for the USA ones.
In the "Unpublish menu items where note…" control, you can use a Regex:

#VM-(?!USA)#

That will match all menu items that have a comment that contains "VM-" but is not "VM-USA".

It's then much simpler to manage which menu items will get turned on and off for each country. For any menu item you want to control like this, just add a menu item comment with "VM-" followed by the country code that it should display on. Of course you still need 1 Chameleon rule per country, to detect the GeoIP country and trigger the appropriate regex.

Hope that helps
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
3328 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1686
Total Polls:
6
Total Posts:
5933
Total Posts Today:
7
User Info:
 
Total Users:
4432
Newest User:
kinggambling14
Members Online:
0
Guests Online:
233

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