VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: gpessoa on March 17, 2014, 21:37:18 PM

Title: Shopper group name price image
Post by: gpessoa on March 17, 2014, 21:37:18 PM
Hi
Wow can I set a Div class Image, Kid off

<?php //if($product->product_special == 1) { ?>
                    <!--
                     <div class="hot-product"></div>
                     -->
                     <?php //} ?>

but related to shopper group name price?

The idea is show a different image depending of witch shopper group name the client belongs
Thanks in advanced

J 2.5.18
VM 2.26d
Title: Re: Shopper group name price image
Post by: K&K media production on March 18, 2014, 00:23:07 AM
It is based on the shoppergroup ID:


$usermodel = VmModel::getModel('user');
$user = $usermodel->getCurrentUser();
if (in_array('1', $user->shopper_groups)) {
echo 'you are in shopper group with ID 1';
} else {
echo 'you are not in shopper group with ID 1';
}
Title: Re: Shopper group name price image
Post by: gpessoa on March 18, 2014, 01:00:38 AM
Hi KK
Thanks for your help,
Btw, I have 6 shopper groups and same times one single client belongs to at 4 of then.
In this case, how do we handle that?

Title: Re: Shopper group name price image
Post by: K&K media production on March 18, 2014, 01:19:40 AM
Hi,
in_array looks if the shoppergroups of your user is one of the group 1.
Regards,
Maik
Title: Re: Shopper group name price image
Post by: gpessoa on March 18, 2014, 02:53:40 AM
Hi Maik
Sorry but I couldn't follow you as my knowledge is not that good...
In attachment I send a few images that may help
Thanks for your time!


[attachment cleanup by admin]
Title: Re: Shopper group name price image
Post by: K&K media production on March 18, 2014, 11:59:35 AM
Yes it works. The user is in 4 groups: 1,2,3,4

You look if the user is in group 1 ... the script said yes, the user is in group 1.

Other user is in groups 2,3,4,5 ... the script said no, the user is not in group 1.
Title: Re: Shopper group name price image
Post by: gpessoa on March 18, 2014, 12:19:48 PM
Hi Maik
Yes, that I understand...
But my problem is that I want to have a different div image to each one of this groups...
Your suggestion only works  for two situations (is in group 1, then image group 1; is out of group 1, then other image)
What I want is:
If in group 1, then Div Image group 1
If in group 2, then Div Image group 2
If in group 3, then Div Image group 3
If in group 4, then Div Image group 4
If in group 4, then Div Image group 5
If in group 6, then Div Image group 6
Thanks for your time!
Title: Re: Shopper group name price image
Post by: K&K media production on March 18, 2014, 12:43:05 PM
And which image for someone who is in 4 groups???
Title: Re: Shopper group name price image
Post by: gpessoa on March 18, 2014, 14:09:46 PM
Hi Maik,
There´s no need because Client only see one image/ price in each product, no meter how many groups he belongs.
Client may belong to a several Shopper Groups, but he only see one single price (that I want to provide with one image under the price).
So, imagine 5000 products and all 5000 has prices for shopper groups 1 and 2;
in this 5000 products, 2000 also have prices to groups 3, 2000 also have prices to groups 4, 3500 also have prices to groups 5 and 800 have prices to groups 6.
The user, depending the hierarchy of the VM multi price, will only see the price that we belongs (filtered by shopper group price)
This take us to another question that I already ask, but until today get no answer http://forum.virtuemart.net/index.php?topic=122527.msg418086#msg418086 (http://forum.virtuemart.net/index.php?topic=122527.msg418086#msg418086)
That's way I need an independent image to echo under each shopper group name price, in order the client know exactly that price he sees is a regular retail price, a special retail price, a resell price, or a resell best price...
Once again thanks for your time!
Title: Re: Shopper group name price image
Post by: K&K media production on March 18, 2014, 14:41:47 PM
This can couse problems if one user have multiple prices. I recommend you to restucture your shoppergroups! Some groups for prices and other groups for other different things, so each user have only one unique price for one group.
Title: Re: Shopper group name price image
Post by: gpessoa on March 18, 2014, 17:35:54 PM
Hi Maik,
Maybe you right on that multi price thing; maybe is that why there are no hierarchy on it!
As far I tested, VM assumes the first shopper group name price that fits on that user, even the user belongs to a few more Shopper Groups!

However, even doing  that, my problem still persists, because I need to echo a unique image under each one shopper group name price.

Thanks for your time!
Title: Re: Shopper group name price image
Post by: K&K media production on March 18, 2014, 19:03:23 PM
If you restructure your shoppergroups that each shopper is member of only one group with prices, you can use my code.
Title: Re: Shopper group name price image
Post by: gpessoa on March 18, 2014, 19:38:51 PM
Hi Maik,
Maybe if we use the same code a few times...
Like this:
$usermodel = VmModel::getModel('user');
$user = $usermodel->getCurrentUser();
if (in_array('2', $user->shopper_groups)) {
echo 'image to SG ID 2';
} else {
echo 'image to anonymous';
}

$usermodel = VmModel::getModel('user');
$user = $usermodel->getCurrentUser();
if (in_array('3', $user->shopper_groups)) {
echo 'image to SG ID 3';
} else {
echo 'image to anonymous';
}

$usermodel = VmModel::getModel('user');
$user = $usermodel->getCurrentUser();
if (in_array('4', $user->shopper_groups)) {
echo 'image to SG ID 4';
} else {
echo 'image to anonymous';
}

And so on...
Is this, repeating the code ok?
And another question: Where to put the code in the default or in the default_showprices template?
Title: Re: Shopper group name price image
Post by: K&K media production on March 18, 2014, 22:19:14 PM
In this case the user becomes 3 images!

It depends where the image should be displayed.
Title: Re: Shopper group name price image
Post by: gpessoa on March 18, 2014, 23:34:24 PM
Hi Maik,
QuoteIn this case the user becomes 3 images!
No, restructuring shopper groups, the User will assign only his only shopper group div image price.
The question is: Is that correct repeating the all script, or the code should be changed to same thing like:
$usermodel = VmModel::getModel('user');
$user = $usermodel->getCurrentUser();
if (in_array('2', $user->shopper_groups)) {
echo 'image to SG ID 2';
if (in_array('3', $user->shopper_groups)) {
echo 'image to SG ID 3';
if (in_array('4', $user->shopper_groups)) {
echo 'image to SG ID 4';
if (in_array('5', $user->shopper_groups)) {
echo 'image to SG ID 5';
if (in_array('6', $user->shopper_groups)) {
echo 'image to SG ID 6';
} else {
echo 'image to anonymous shopper groups, that is shopper group ID 1';
}

Quote
It depends where the image should be displayed.
Sorry, my mistake. I mean in the product detail page
Thanks again
Title: Re: Shopper group name price image
Post by: K&K media production on March 19, 2014, 15:32:11 PM
If the user is in group 3,4,5 and 6 he will become 4 images with this code. Use from second step else if and the user will see only one image for the first hit. In this case the user will see only the image for group ID 3. If he should see image 6, you must begin with if group 6, else if group 5, else if group 4 and so on.
Title: Re: Shopper group name price image
Post by: gpessoa on March 21, 2014, 02:56:08 AM
Hi Maik,
I created a few client tests an also a few products tests with the all shopper groups prices.
I run a few tests and found that this script as it is doesn´t work for me.

As I already told you, there are products that I sell who do not have prices for certain shopper groups because I don't have price for them.
Example certain products that I don't resell, but even the reseller user can buy them with retail or retail best price, based on the shopper group he belongs.
Using the script as it is, and changes that you said, happens the user get wrong information.
If the user is a resell, he gets the resell price information in all products, even in those he don't have resell price.

VM already shows (and works fine) the user the price he have, concerning the shopper groups (User SG + product price SG) he has rights.
Basically what I need is to give that information to the User:
like (User XY)
Product A = echo 'the price you are seeing is from shopper group resell price'
Product B = echo 'the price you are seeing is from shopper group retail best price'
This way, the user knows exactly the if he buy product B he has no resell price, but also has not retail price, because the price he has is retail best price (between retail and resell)


So, if you could update your script to something like
if (in_array('1', $user->shopper_groups) AND (shopper group price) then echo
I believe this will work fine.

Thanks in advanced for your time!