[Skip to main content](#vessel-content)

#   How could I get the price of the product in php?

##

- **[progreccor](/forum/user/4816-progreccor "View progreccor's Profile")**
- [![progreccor's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4816.jpg)](/forum/user/4816-progreccor "View progreccor's Profile") Topic Author
- [ Offline](/forum/user/4816-progreccor "Москва")
- SEO, webdesign

Less More

- Posts: 2293
- Thank you received: 314
-
-
-
- [](http://www.d-dd.ru)
-

11 years 3 months ago [\#210396](#210396) by [progreccor](/forum/user/4816-progreccor "View progreccor's Profile")  *[How could I get the price of the product in php?](/forum/4-how-to/878539-how-could-i-get-the-price-of-the-product-in-php#210396 "-- HikaShop version -- : 2.5.0 -- Joomla version -- : 5.4.3 -- PHP version -- : 5.6.3  I am try to modify search results so they can output the price of the products.  I am using this code to get the product by its id:  But I don't get the price of the product.  Yes, I can get it from the database but may be there are any ways to do it by your methods from the class?")* was created by *[progreccor](/forum/user/4816-progreccor "View progreccor's Profile")*

-- HikaShop version -- : 2.5.0
-- Joomla version -- : 5.4.3
-- PHP version -- : 5.6.3

I am try to modify search results so they can output the price of the products.

I am using this code to get the product by its id:
Code:

$productClass = hikashop_get('class.product'); $product=$productClass-&gt;get($product_id);

But I don't get the price of the product.

Yes, I can get it from the database but may be there are any ways to do it by your methods from the class?

---

Я не явлюсь официальной службой поддержки!
Я здесь добровольно!

Хочешь получить купон на скидку Hikashop? Спроси меня как!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzg3ODUzOS1ob3ctY291bGQtaS1nZXQtdGhlLXByaWNlLW9mLXRoZS1wcm9kdWN0LWluLXBocD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86564
- Thank you received: 14311
-
-

11 years 3 months ago [\#210417](#210417) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How could I get the price of the product in php?](/forum/4-how-to/878539-how-could-i-get-the-price-of-the-product-in-php#210417 "-- HikaShop version -- : 2.5.0 -- Joomla version -- : 5.4.3 -- PHP version -- : 5.6.3  I am try to modify search results so they can output the price of the products.  I am using this code to get the product by its id:  But I don't get the price of the product.  Yes, I can get it from the database but may be there are any ways to do it by your methods from the class?")*

Hi,

You can get the prices of the product like this: Code:

$config =&amp; hikashop_config(); $currencyClass = hikashop_get('class.currency'); $main_currency = $currency_id = (int)$config-&gt;get('main_currency',1); $zone_id = explode(',',$config-&gt;get('main_tax_zone',0)); if(count($zone_id)){ $zone_id = array_shift($zone_id); }else{ $zone_id=0; } $ids = array($product-&gt;product_id); $discount_before_tax = (int)$config-&gt;get('discount_before_tax',0); $currencyClass-&gt;getPrices($product,$ids,$currency_id,$main_currency,$zone_id,$discount_before_tax);

The prices of the product will be in a "prices" array in the $product object.

The following user(s) said Thank You: [progreccor](/forum/user/4816-progreccor "View progreccor's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzg3ODUzOS1ob3ctY291bGQtaS1nZXQtdGhlLXByaWNlLW9mLXRoZS1wcm9kdWN0LWluLXBocD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[cgonline](/forum/user/34948-cgonline "View cgonline's Profile")**
- [![cgonline's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/34948-cgonline "View cgonline's Profile")
- [ Offline](/forum/user/34948-cgonline)

Less More

- Posts: 12
- Thank you received: 0
-
-

11 years 2 months ago [\#211938](#211938) by [cgonline](/forum/user/34948-cgonline "View cgonline's Profile")  Replied by *[cgonline](/forum/user/34948-cgonline "View cgonline's Profile")* on topic *[How could I get the price of the product in php?](/forum/4-how-to/878539-how-could-i-get-the-price-of-the-product-in-php#211938 "-- HikaShop version -- : 2.5.0 -- Joomla version -- : 5.4.3 -- PHP version -- : 5.6.3  I am try to modify search results so they can output the price of the products.  I am using this code to get the product by its id:  But I don't get the price of the product.  Yes, I can get it from the database but may be there are any ways to do it by your methods from the class?")*

Hi

That code is not working here, but it seems to be a common issue (people cant load the prices).
Why not extend the hikashopProductClass with a 'getPrices($includetax)' method instead? (or something of the likes)

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzg3ODUzOS1ob3ctY291bGQtaS1nZXQtdGhlLXByaWNlLW9mLXRoZS1wcm9kdWN0LWluLXBocD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86564
- Thank you received: 14311
-
-

11 years 2 months ago [\#211941](#211941) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How could I get the price of the product in php?](/forum/4-how-to/878539-how-could-i-get-the-price-of-the-product-in-php#211941 "-- HikaShop version -- : 2.5.0 -- Joomla version -- : 5.4.3 -- PHP version -- : 5.6.3  I am try to modify search results so they can output the price of the products.  I am using this code to get the product by its id:  But I don't get the price of the product.  Yes, I can get it from the database but may be there are any ways to do it by your methods from the class?")*

Hi,

That code works fine, so you must be missing something in what you have before and/or after it.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzg3ODUzOS1ob3ctY291bGQtaS1nZXQtdGhlLXByaWNlLW9mLXRoZS1wcm9kdWN0LWluLXBocD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.059 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
