最近,我为我的企业安装了 Opencart cms,以便销售和出租一些产品。起初一切都还好,我设计了一个标志,创造了一个漂亮的主题并加入了一个新的类别。但是一段时间后,我发现不编辑 Opencart 的源代码就无法租用产品,我发现很难做到这一点。我尝试通过在第 239 行添加 $product_data[] 语句并将加号替换为 'price' 和 'total' 的乘号来进行编辑/catalog/controller/checkout/cart.php
,如下if-else
所示:
从:
$product_data[] = array(
'cart_id' => $cart['cart_id'],
'product_id' => $product_query->row['product_id'],
'name' => $product_query->row['name'],
'model' => $product_query->row['model'],
'shipping' => $product_query->row['shipping'],
'image' => $product_query->row['image'],
'option' => $option_data,
'download' => $download_data,
'quantity' => $cart['quantity'],
'minimum' => $product_query->row['minimum'],
'subtract' => $product_query->row['subtract'],
'stock' => $stock,
'price' => ($price + $option_price),
'total' => ($price + $option_price) * $cart['quantity'],
'reward' => $reward * $cart['quantity'],
'points' => ($product_query->row['points'] ? ($product_query->row['points'] + $option_points) * $cart['quantity'] : 0),
'tax_class_id' => $product_query->row['tax_class_id'],
'weight' => ($product_query->row['weight'] + $option_weight) * $cart['quantity'],
'weight_class_id' => $product_query->row['weight_class_id'],
'length' => $product_query->row['length'],
'width' => $product_query->row['width'],
'height' => $product_query->row['height'],
'length_class_id' => $product_query->row['length_class_id'],
'recurring' => $recurring
);
至:
if $option_query->row['type'] == 'select' & $option_query->row['name'] == 'Duration')
{
$product_data[] = array(
'cart_id' => $cart['cart_id'],
'product_id' => $product_query->row['product_id'],
'name' => $product_query->row['name'],
'model' => $product_query->row['model'],
'shipping' => $product_query->row['shipping'],
'image' => $product_query->row['image'],
'option' => $option_data,
'download' => $download_data,
'quantity' => $cart['quantity'],
'minimum' => $product_query->row['minimum'],
'subtract' => $product_query->row['subtract'],
'stock' => $stock,
'price' => ($price * $option_price),
'total' => ($price * $option_price) * $cart['quantity'],
'reward' => $reward * $cart['quantity'],
'points' => ($product_query->row['points'] ? ($product_query->row['points'] + $option_points) * $cart['quantity'] : 0),
'tax_class_id' => $product_query->row['tax_class_id'],
'weight' => ($product_query->row['weight'] + $option_weight) * $cart['quantity'],
'weight_class_id' => $product_query->row['weight_class_id'],
'length' => $product_query->row['length'],
'width' => $product_query->row['width'],
'height' => $product_query->row['height'],
'length_class_id' => $product_query->row['length_class_id'],
'recurring' => $recurring
);
}else{
$product_data[] = array(
'cart_id' => $cart['cart_id'],
'product_id' => $product_query->row['product_id'],
'name' => $product_query->row['name'],
'model' => $product_query->row['model'],
'shipping' => $product_query->row['shipping'],
'image' => $product_query->row['image'],
'option' => $option_data,
'download' => $download_data,
'quantity' => $cart['quantity'],
'minimum' => $product_query->row['minimum'],
'subtract' => $product_query->row['subtract'],
'stock' => $stock,
'price' => ($price + $option_price),
'total' => ($price + $option_price) * $cart['quantity'],
'reward' => $reward * $cart['quantity'],
'points' => ($product_query->row['points'] ? ($product_query->row['points'] + $option_points) * $cart['quantity'] : 0),
'tax_class_id' => $product_query->row['tax_class_id'],
'weight' => ($product_query->row['weight'] + $option_weight) * $cart['quantity'],
'weight_class_id' => $product_query->row['weight_class_id'],
'length' => $product_query->row['length'],
'width' => $product_query->row['width'],
'height' => $product_query->row['height'],
'length_class_id' => $product_query->row['length_class_id'],
'recurring' => $recurring
);
}
但是当我尝试测试它时,当我在同一张卡上放置一个带有另一个不同选项的持续时间选项时,我会为所有卡片项目获得一大笔款项 ($price * $option_price)
请问我该如何解决它或者是否有另一种方法可以在 Opencart 上同时出租和销售产品
简化: 我想添加一个持续时间选项价格(1 天或 2 天...),客户可以选择租用产品的天数并退货。总计 = 项目价格 * 持续时间(天数) * 产品数量