Display certain price

Kustutatud
Alates Tundmatu

Hi,
we have entered "regular" price and other prices by the groups.
On product pages, we are displaying "regular" prices to everyone, and registered users receive their prices, as they should.
I would like to show difference between those prices, but can't seem to display both prices at the same time. Are they overwritten before displaying?

Basicly like this:
Price:100
Group1: 90
Group2: 80
...

Guests see: 
100

Registered user with Group1 sees:
90
[s]100 [/s](10 less)

Something like that, as we are displaying some calculations with both prices (before this asson, we used fixed percentage.
Thanks for hints :)

Nejc

tim
Founder
Alates Sweden
Liige alates
tim

Yes they are overwritten before sent to the view file. You would have to access the database to retrieve them or go through the ctrl oject.

var_dump( reference::ctrl_product($product_id)->customer_group_prices );

At least I think that was the name of the parameter inside ctrl_product. I'm on mobile.

Kustutatud
Alates Tundmatu

So, those prices can't really just simply be retrieved. I would also use that in XML outputs, as with that addon installed and in use, it's not really usable anymore. What if I would manually set user id, at least in XML, would that output correct price?

tim
Founder
Alates Sweden
Liige alates
tim

If accessing the set of prices from the database filtered an ready with one command is not simple then I have lost the meaning of the word :-D

Kustutatud
Alates Tundmatu

No, getting those prices is just fine, but how to also get "regular" price, which is now only visible to non registered users?

tim
Founder
Alates Sweden
Liige alates
tim

Right, and reference::product($product_id)->price would be overwritten by the customer price.

You can insert this into ref_product.inc.php:



          $this->_data['price'] = 0;

          $products_prices_query = database::query(
            "select * from ". DB_TABLE_PRODUCTS_PRICES ."
            where product_id = ". (int)$this->_id ."
            limit 1;"
          );
          $product_price = database::fetch($products_prices_query);

          if ($product_price[$this->_currency_code] != 0) {
            $this->_data['price'] = currency::convert($product_price[$this->_currency_code], $this->_currency_code, settings::get('store_currency_code'));
          } else {
            $this->_data['price'] = $product_price[settings::get('store_currency_code')];
          }

          break;```
Then access by [b]reference::product($product_id)->original_price[/b]
Kustutatud
Alates Tundmatu

I think something is missing, as this is returning NULL. Isn't price overwriten with regular_price?

edit: ah, just changed the two lines to $this->_data['original_price']

Now I get float value returned :)
As always, thanks for help!

tim
Founder
Alates Sweden
Liige alates
tim

Ah, sorry I missed that. Well done.

Teie
This website uses no cookies and no third party tracking technology. We think we can do better than others and really think about your privacy.