使用opencart并尝试在产品会话中输入另一个值。默认情况下,它只会带来ID。我怎样才能获得更多信息?
if (!in_array($this->request->post['product_id'], $this->session->data['wishlist'])) {
$this->session->data['wishlist'][] = $this->request->post['product_id'];
$this->session->data['wishlist'][] = $my_var;
}
答案 0 :(得分:1)
如果我正确阅读了这一点,您正试图将其他数据添加到现有阵列......您正在寻找的是
array_push();
array_push - 将一个或多个元素推送到数组的末尾
语法:
int array_push ( array &$array , mixed $value1 [, mixed $... ] )
示例:
$array = array();
$addingthistoarray = "value to add";
array_push($array, $addingthistoarray);
答案 1 :(得分:0)
我不确定你到底在找什么,但你应该可以做这样的事情(假设你的“$ _SESSION”):
session_start();
$_SESSION['wishlist'] = array( ... );
...
$_SESSION['wishlist']['product_id'] = $this->request->post['product_id'];
...