Page 1 of 1

Display Product ID in Shopping Basket?

Posted: Sun May 17, 2015 10:39 pm
by anthgav
I am currently trying to get the product ID to display through the whole process of products being displayed.
I have 4 files which I need the ID to display:
search.tpl
product.tpl
cart.tpl
confirm.tpl

I can get the Product ID to display by putting the following code where I require it:

Code: Select all

<?php echo $product_id; ?>
This works in all 4 files except cart.tpl. Does anyone have an idea of why it won't display in this file which is the Shopping Basket and what areas I need to check?

Re: Display Product ID in Shopping Basket?

Posted: Mon May 18, 2015 5:16 pm
by tabook
Becase cart.tpl doesn't have and should't have product id. Cart may contain 10000... products, so what is product id should be written?
So, for the cart you need to create additional fetching and output product id for every product.

Re: Display Product ID in Shopping Basket?

Posted: Mon May 18, 2015 6:20 pm
by anthgav
I managed to get this working last night.
In the following file /catalog/controller/checkout/cart.php there is the following array...

Code: Select all

$this->data['products'][] = array(
					'key'                 => $product['key'],
					'thumb'               => $image,
					'name'                => $product['name'],
					'product_id'          => $product['product_id'],
					'model'               => $product['model'],
					'option'              => $option_data,
					'quantity'            => $product['quantity'],
					'stock'               => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')),
					'reward'              => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''),
					'price'               => $price,
					'total'               => $total,
					'href'                => $this->url->link('product/product', 'product_id=' . $product['product_id']),
					'remove'              => $this->url->link('checkout/cart', 'remove=' . $product['key']),
					'recurring'           => $product['recurring'],
					'profile_name'        => $product['profile_name'],
					'profile_description' => $profile_description,
				);
I added the following line...

Code: Select all

'product_id'          => $product['product_id'],
Once I added that line into the array I was able to call the product ID in the cart.tpl

Re: Display Product ID in Shopping Basket?

Posted: Fri Jul 14, 2017 3:43 am
by mupcku
But if you have multiple products? Exactly which id you took with this code?

Re: Display Product ID in Shopping Basket?

Posted: Fri Jul 14, 2017 4:18 am
by IP_CAM
fixed, http link now works well,!
Image