Opencart为租赁创建新选项

时间:2016-05-24 09:09:10

标签: php opencart opencart2.x opencart-module

最近,我为我的公司安装了Opencart cms,以便出售和租用一些产品。起初一切都很好,我设计了一个标志,创造了一个美丽的主题,并推出了一个新的类别。但过了一段时间后,我发现如果不编辑Opencart的源代码就无法租用产品,我发现很难做到这一点。 我尝试通过在第239行添加 $ product_data [] /catalog/controller/checkout/cart.php声明来修改if-else,并将加号替换为' price'和'总计'变得那样:

从:

 $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天......),客户可以选择他将租用产品并退回产品的天数。 总计=项目价格*持续时间(天数)*产品数量

0 个答案:

没有答案