如何在opencart中为全球所有产品设置折扣价 [英] How to set discount price for all products globally in opencart

查看:227
本文介绍了如何在opencart中为全球所有产品设置折扣价的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将商店中所有产品的折扣价降低到-5%.它必须显示在产品详细信息页面和产品列表页面中,例如单个折扣价(删除线).我想将折扣应用于全球商店中的所有产品.正如我尝试过的那样,我们在添加产品时可以选择在选项选项卡中设置折扣价,但是为每种产品添加折扣似乎是一个漫长的过程.所以我想在全球范围内应用它.任何帮助或想法将不胜感激.

I need a discount price in all products in store to -5%. It has to show in product detail page and also product listing page like the individual discount price (strike-through). I want to apply the discount to all products in store globally. As i have tried, we have option to set discount price in the option tab while adding products but adding discount for each product seems to be long process. So i want to apply it globally. Any help or ideas will be greatly appreciated.

我检查了一些扩展名,但所有扩展名都在结帐页面上显示了全球折扣.我想根据产品价格在产品详细信息页面中显示它.

I checked some extensions but all show the global discount in the checkout page. I want to show it in the product details page based on the product price.

推荐答案

在产品控制器中

$this->load->model('catalog/product');
$products = $this->model_catalog_product->getProducts();
foreach ($products as $product) {
$this->model_catalog_product->setdiscount($product['product_id'],$product['price']);
}

在模型中

public function getProducts()
{
$query = $this->db->query("SELECT product_id, price FROM oc_product");
return $query->rows; 
}
    public function setdiscount($id,$price)
{

    $price=($price*95)/100;
    $query = $this->db->query("INSERT INTO oc_product_discount (product_id,customer_group_id,quantity,priority,price,date_start,date_end) VALUES ('".$id."','1','1','1','".$price."','xxx','yyy')");
}

您选择的

xxx和yyy.并根据您的要求更改customer_group_id,数量,优先级.

xxx and yyy of your choice. and do change the customer_group_id,quantity,priority as per your req.

我已经为您提供了流程,可以随时随地进行更改.

i have provided you the flow, do changes wherever you want.

这篇关于如何在opencart中为全球所有产品设置折扣价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆