How to access product details using PHP?

  • Posts: 76
  • Thank you received: 2
11 years 5 months ago #107988

Hi there,

I have products which are sold in different weights. I have created a weight characteristic to be used for these products and it all works fine.

The cost per kg decreases if you by larger weights. I want to show the saving made by choosing larger weights.

I would know how to do this (I think) by editing the view file "product show" if I could just work out how to get the following quantities from the hikashop system using php code:

  • The currently selected variant price.
  • The currently selected variant characteristic value.
  • The available variants charactersitic values
  • The price of a variant with a given charactersitic value

The idea being I could extract a numeric quantity from the "charactersitic value" string, find the smallest of these values, find the price corresponding to that value and put them into to a little calculation with the currently selected variant details to show how much money they have saved by selecting a greater weight.

Does anyone know enough about the hikashop system to work out how to get hold of these values in the "product show" view file? Or if I've missed a piece of documentation, please point me to it...

Jonathan

Please Log in or Create an account to join the conversation.

  • Posts: 82759
  • Thank you received: 13346
  • MODERATOR
11 years 5 months ago #108023

Hi,

All the information of the product is available in the $this->element variable in the show.php view file.
So you can do a var_dump on that variable to see what it contains and how to access what you need.
We actually have a simplified version here:
www.hikashop.com/en/support/documentation/157
It actually doesn't contain the characteristic data in it.

The following user(s) said Thank You: jberry210490

Please Log in or Create an account to join the conversation.

  • Posts: 76
  • Thank you received: 2
11 years 4 months ago #108303

Thanks Nicolas,

Exactly what I needed. Got my little "saving box" to work now.

Jonathan

Please Log in or Create an account to join the conversation.

Time to create page: 0.063 seconds
Powered by Kunena Forum