Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass custom variable in cart?

I am using Opencart 2.0.1.1. There is hidden text field on product page that I want to post on cart page. I am following this tutorial but getting Undefined index issue.

<input type="hidden" name="design" value="12">

I have done the following coding so for:

In catalog/controller/checkout/cart.php

$option['design']=$this->request->post['design'];
$this->cart->add($this->request->post['product_id'],$quantity,$option);

Then in $data['products'][] = array( added 'design' => $product['design'],

Then in system/library/cart.php

In $this->data[$key] = array( added 'design' => $options['design'],

Then in cart.tpl in view\theme\template-name\template\checkout\cart.tpl

echo $product['design'];

Can anyone please help me on this issue?

like image 957
Triyugi Narayan Mani Avatar asked Jul 29 '16 12:07

Triyugi Narayan Mani


1 Answers

If you are getting a null or invalid index your variable isn't being passed, I would make sure your input is inside the form being submitted and make sure you have it spelled right just in case. Also use php

print _r($_POST);

To verify if its posting the data. If you see it listed then double check your class method.

You would need to provide us with more content so that we could troubleshoot the issue more accurately.

like image 65
Jtuck Avatar answered Nov 10 '22 19:11

Jtuck