-3

this is simple question . How can i update product price using product id in opencart ?

I found catalog/controller/product/product.php file . And i see one query

$price = $this->currency->format($this->tax->calculate($recurring_info['price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);

But how can i update the price . For example if my product-id=2 then i have to update the price = 10

I have ftp access . So please give any sample code .

John
  • 97
  • 5
  • 1
    https://meta.stackexchange.com/questions/108551/what-site-to-use-if-you-have-a-gimme-teh-codez-question – Ronan Boiteau Jun 23 '19 at 10:27
  • John, Opencart uses MVC Architecture. So you have to find the Controller File (product.php) and make changes to it. You should give it a try first and ask questions if you can't get the result you are looking for. – Harish ST Jun 23 '19 at 12:57
  • @HarishST thanks . I update the question . Please check – John Jun 24 '19 at 05:34

1 Answers1

0

I am not sure why you need to do this when you have the option to change the product Price from admin Panel, Yet you can change the $data['price'] variable to change the price in the view page. But changing this variable alone won't be enough since when you check out the order and while performing other operations the price won't get reflected since the product price is taken from the oc_product table.

So the right way to do is changing the value in the oc_product table which is what the Opencart admin panel does. So please reconsider your thought before messing it up.

$data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);

As you can see in the above code the price is taken from $product_info['price'] which is from oc_product table.

Harish ST
  • 1,475
  • 9
  • 23