Hello Everyone,
I have created a website using modx evolution v1.0.2.
The website that I have developed has 12 different types of users (categorized in groups). Each user will be shown a different price depending on the group to which he belongs.
Till now I have been able to fetch the group name of current logged in user (created a snippet for that), but how can I achieve the above mentioned functionality so that each user should be able to see only the price that I have coded according to his group.
For example:
If a user is associated with the ’ocassional’ group then he should be shown the price as , say, 50 bucks
and if a user is associated with the ’regular’ group then he should be shown the price as, say, 40 bucks
I can easily do this by coding a single snippet for every product’s variant, but there are a lot of variants (more than 100 and growing).
I have created a resource(page) for every product and it’s variant. Every variant has a price. It is this price that I want to be shown according to the logged in user group membership.
I hope I am able to explain my query clearly.
Please help me do this functionality.
Thanks
-
☆ A M B ☆
- 24,524 Posts
1. Please upgrade to 1.0.3; it closes some potential security vulnerabilities.
2. Use TVs, one for each variant’s price. Then in your snippet, depending on the user’s group (use a php "switch" conditional) get the appropriate TV. This way you only need one document for each product.
Or, if the price variant is always a percentage of the regular price, just use the same "switch" conditional to calculate the variant price on-the-fly according to the visitor’s group.
I have more than 100 variants, that means I should create 100 TVs :-O
Is there exists an easier solution?
-
☆ A M B ☆
- 24,524 Posts
Are the prices for the different groups consistant? Are they a certain percentage of the full price?
No the prices for different groups are not consistent.
I will be inputting prices for different groups manually. I only need to fetch the group ownership (which I had done already) and then display the required amount accordingly for each variant page.
The prices for every group will be different for each variant.
Like this
Every variant will have a set of 12 different prices to be displayed according to the group membership of current logged in user.
Suppose if a user belongs to the ’occasional’ group then he would be shown a price of 50 bucks, and
if he belongs to the ’regular’ group then he would be shown a price of 40 bucks for that variant.
-
☆ A M B ☆
- 24,524 Posts
Looks to me like no matter how you cut it you’ll need to enter 12 prices for each variant somewhere. Might as well use TVs as anything else, as I suggested before. Seems to me it would have made sense to make each of the 12 prices a fixed percentage of the full price; "occasional" would be %80, and "regular" would be %75, for example. Then you’d only need one price for each variant, and a single snippet to make the appropriate calculation depending on the user’s group.