Post by anthgav » Sun May 17, 2015 10:39 pm

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?

Newbie

Posts

Joined
Sat May 02, 2015 8:24 am

Post by tabook » Mon May 18, 2015 5:16 pm

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.

Forget complex and inconvenient stock Categories and Products in OpenCart - use Acute Category Manager +!
Ready for 1.5.x and 2.x Editions


New member

Posts

Joined
Sun Mar 01, 2015 6:27 pm

Post by anthgav » Mon May 18, 2015 6:20 pm

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

Newbie

Posts

Joined
Sat May 02, 2015 8:24 am

Post by mupcku » Fri Jul 14, 2017 3:43 am

But if you have multiple products? Exactly which id you took with this code?

New member

Posts

Joined
Tue Jan 24, 2017 8:12 pm

Post by IP_CAM » Fri Jul 14, 2017 4:18 am

fixed, http link now works well,!
Image

Attachments

add_product_id_to_cart.jpg

add_product_id_to_cart.jpg (426.34 KiB) Viewed 219 times


Ernie's OpenShop v.1.75 + OpenCart v.1.5.6.5 LIGHT Test Sites with free responsive Themes
http://www.bigmax.ch/shop/ - http://www.ebikes.li - http://www.ipc.li/shop/ - http://www.openshop.li/shop/
Image


User avatar
Guru Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland
Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 39 guests