Jump to content

Display transaction records on product page


Recommended Posts

public function getTransactionRecords($id_product)
		$sql = 'SELECT p.id_product,
					c.`firstname` AS firstname,
					od.`product_name` AS product_name,
					od.`unit_price_tax_incl` AS unit_price,
					od.`product_quantity` AS product_quantity,
					oh.`date_add` AS date_add
				FROM ps_product p
					LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (p.`id_product` = od.`product_id`) 
					LEFT JOIN `'._DB_PREFIX_.'orders` o ON (od.`id_order` = o.`id_order`) 
					LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (o.`id_order` = oh.`id_order`)
					LEFT JOIN `'._DB_PREFIX_.'customer` c ON (o.`id_customer` = c.`id_customer`)
				WHERE oh.id_order_state in ('2','3','4','5') and p.`id_product` = '".$id_product."'
				ORDER BY od.id_order_detail ASC';
		return Db::getInstance()->ExecuteS($sql);

	public function hookDisplayLeftColumn($params)
			$id_product = (int)(Tools::getValue('id_product'));
			$prod  = new Product($id_product, true, (int)($this->context->language->id));
				  'transaction_records' => Configuration::get('TRANSACTIONRECORDS_SETTING'),
				  'transaction_records_link' => $this->context->link->getModuleLink('transactionrecords','display'),
				  'prod' => $prod
	  return $this->display(__FILE__, 'transactionrecords.tpl');

Hi I am trying to display transaction records on product page, and I'm not a developer. I wrote these codes according to documentation from prestashop official doc site, but I'm still struggling to make it work.


Anyone tries to displays those transaction records and make it work? Any help would be appreciated.

Share this post

Link to post
Share on other sites

Where did you put this code? Did you hook the function already?

Normally, this hook function will be called from within a module, like the module blockfacebook, blockcontact etc.

Maybe have a look there how they build the module (also see Prestashop developers guide for this) and how they hooked the function


finally, this piece of code seems odd:


WHERE oh.id_order_state in ('2','3','4','5') and p.`id_product` = '".$id_product."'


Think you need to remove the double quotes:


WHERE oh.id_order_state in ('2','3','4','5') and p.`id_product` = '.$id_product.'

My 2 cents,

Share this post

Link to post
Share on other sites

Hi Pascal,


Yes I have built the module according to documentation, and the module does show something as documentation shows. Then I tried to add these codes to do the work, I also tried removing the double quotes and still no luck.



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More