- Posts: 46
- Thank you received: 2
encoded prices
- saturnales
-
Topic Author
- Offline
Less
More
11 years 6 months ago #196970
by saturnales
encoded prices was created by saturnales
-- HikaShop version -- : 2.4.1
-- Joomla version -- : 3.3.6
Hello
My shop is a distributors-only catalog.
I dont use the cart functionalities ( except wishlist)
all logged users have to mention a VAT number
For each product, i put 2 differents prices :
It works fine but its really dirty for 3 reasons :
I wonder if there is a way to call ( and test) the group id of my price owner from the product/listing_price view. Then i would be able to recognize the guest prices, and i wouldnt be forced to put a prefix on my prices.
Thanks
-- Joomla version -- : 3.3.6
Hello
My shop is a distributors-only catalog.
I dont use the cart functionalities ( except wishlist)
all logged users have to mention a VAT number
For each product, i put 2 differents prices :
- The real price is visible only for logged pro users ( i made an access level for the group "privilegied")
- The price have to be shown in an encoded form for the guests
Code:
if(substr(strval(intval($price->price_value)), 0, 4) == '1111'){
$decoded = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
$encoded = array("U", "P", "A", "N", "C", "H", "T", "O", "R", "K");
echo str_replace($decoded, $encoded, substr(strval(intval($price->price_value)),4)
);
It works fine but its really dirty for 3 reasons :
- Its badly ugly
- If one of my product , for exemple, is normally sold 1111 $ ( which is unprobable i admit), the encoded version will display nothing
- i always have to write 1111 before the guestt price into the back office, and the admin product listing give me headache
I wonder if there is a way to call ( and test) the group id of my price owner from the product/listing_price view. Then i would be able to recognize the guest prices, and i wouldnt be forced to put a prefix on my prices.
Thanks
Please Log in or Create an account to join the conversation.
11 years 6 months ago #196976
by nicolas
Replied by nicolas on topic encoded prices
Hi,
You can use such code:
You can use such code:
Code:
$user = JFactory::getUser();
$group_id = 18; //replace 18 by the id of your privileged user group
if(in_array($group_id, $user->getAuthorisedGroups() )){
$decoded = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
$encoded = array("U", "P", "A", "N", "C", "H", "T", "O", "R", "K");
echo str_replace($decoded, $encoded, $price->price_value);
}
The following user(s) said Thank You: saturnales
Please Log in or Create an account to join the conversation.
- saturnales
-
Topic Author
- Offline
Less
More
- Posts: 46
- Thank you received: 2
11 years 6 months ago #197074
by saturnales
Replied by saturnales on topic encoded prices
Thanks,
I i'm not used to the native joomla objects & methods.
This helps me a lot.
I i'm not used to the native joomla objects & methods.
This helps me a lot.
Please Log in or Create an account to join the conversation.
Time to create page: 0.142 seconds