News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Shopper group name price image

Started by gpessoa, March 17, 2014, 21:37:18 PM

Previous topic - Next topic

gpessoa

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
J 4.4.4; VM 4.2.6; PHP 8.3.6

K&K media production

#1
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';
}

gpessoa

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?

J 4.4.4; VM 4.2.6; PHP 8.3.6

K&K media production

Hi,
in_array looks if the shoppergroups of your user is one of the group 1.
Regards,
Maik

gpessoa

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]
J 4.4.4; VM 4.2.6; PHP 8.3.6

K&K media production

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.

gpessoa

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!
J 4.4.4; VM 4.2.6; PHP 8.3.6

K&K media production

And which image for someone who is in 4 groups???

gpessoa

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
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!
J 4.4.4; VM 4.2.6; PHP 8.3.6

K&K media production

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.

gpessoa

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!
J 4.4.4; VM 4.2.6; PHP 8.3.6

K&K media production

If you restructure your shoppergroups that each shopper is member of only one group with prices, you can use my code.

gpessoa

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?
J 4.4.4; VM 4.2.6; PHP 8.3.6

K&K media production

In this case the user becomes 3 images!

It depends where the image should be displayed.

gpessoa

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
J 4.4.4; VM 4.2.6; PHP 8.3.6