Thursday, February 18, 2016

Set default quantity and subtract option for product options in admin area - Opencart 2.X

To change the default quantity in the "Data" tab of the admin page when inserted a new product:

go to: admin/controller/catalog/product.php

find this:

CODE: SELECT ALL
if (isset($this->request->post['quantity'])) {
            $this->data['quantity'] = $this->request->post['quantity'];
       } elseif (!empty($product_info)) {
            $this->data['quantity'] = $product_info['quantity'];
       } else {
         $this->data['quantity'] = 1;
      }


lines 890 - 895

replace line 904
CODE: SELECT ALL
$this->data['quantity'] = 1;
with
CODE: SELECT ALL
$this->data['quantity'] = "YOUR VALUE HERE";



Find line 906-911

if (isset($this->request->post['subtract'])) {
$data['subtract'] = $this->request->post['subtract'];
} elseif (!empty($product_info)) {
$data['subtract'] = $product_info['subtract'];
} else {
$data['subtract'] = 1;

Replace with:
if (isset($this->request->post['subtract'])) {
$data['subtract'] = $this->request->post['subtract'];
} elseif (!empty($product_info)) {
$data['subtract'] = $product_info['subtract'];
} else {
$data['subtract'] = 0;




Have fun!


Ref: http://forum.opencart.com/viewtopic.php?f=20&t=37696&p=181396

No comments: