在opencart中更新产品阵列

在opencart中更新产品阵列,opencart,Opencart,我试图在根opencart文件夹中创建的新文件中更新当前购物车中的产品数量和总数 首先,我从另一个文件中获取已发布在此处的总数和数量。然后我加载products数组。然后,如果$total和$quantity存在且不等于0,我将使用quantity和total的新值更新products数组。我的问题是我不太确定如何加载products数组并使用quantity和total的新值更新它 这就是我到目前为止所想到的。任何帮助都将不胜感激 <?php $total = mysql_real_es

我试图在根opencart文件夹中创建的新文件中更新当前购物车中的产品数量和总数

首先,我从另一个文件中获取已发布在此处的总数和数量。然后我加载products数组。然后,如果$total和$quantity存在且不等于0,我将使用quantity和total的新值更新products数组。我的问题是我不太确定如何加载products数组并使用quantity和total的新值更新它

这就是我到目前为止所想到的。任何帮助都将不胜感激

<?php
$total = mysql_real_escape_string(htmlentities($_POST['total']));
$quantity = mysql_real_escape_string(htmlentities($_POST['quantity']));

$this->data['products'] = array();
$products = $this->cart->getProducts();

if ($total && $total != 0 && $quantity && $quantity != 0){
product['quantity'] = $quantity;
product['total'] = $total;
}
?>

如果您的意思是如何更新当前的实时购物车项目,它们存储在会话中
购物车
键下的键值对中,因此您可以从

$this->session->data['cart']
要查看购物车读取它们的内部工作方式,您可以查看
/system/library/cart.php

中的
getProducts()
方法,该条件:
if($total&&$total!=0&&$quantity&$quantity!=0){
应该缩短为
if($total&&$quantity){
,因为条件
if($var){
还检查
是否($var!=0){}