encoded prices

  • Posts: 46
  • Thank you received: 2
10 years 5 months ago #196970

-- 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 :

  1. The real price is visible only for logged pro users ( i made an access level for the group "privilegied")
  2. The price have to be shown in an encoded form for the guests
For now, i just use a "tip" for that : i put the normal price for privilegied, and i use a prefix (1111) before the price for the guests. I made a small script on the product/listing_price view :
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.

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 5 months ago #196976

Hi,

You can use such 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.

  • Posts: 46
  • Thank you received: 2
10 years 5 months ago #197074

Thanks,

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.057 seconds
Powered by Kunena Forum