Search code examples
phpmysqlshopping-cartopencart

Opencart Set default tax class to all items


I am working on a Opencart project and it is for Australia customers. So I have to set GST 10% to all items. The items are already added to the cart and I figured a way to add tax classes and I added it to a product and it works good.

The problem is the catalog has more than 10000 products already and I need to update tax classes to all the products. I knew we can run a query to do that but my question is "Is there a way to set a tax class to default" Please let me know. Thanks

My Opencart version is 1.5.1.3


Solution

  • The easiest way to do this would be to use SQL. You will need to run the following code in your phpMyAdmin or whatever other tool you use for SQL on your server

    UPDATE `product` SET `tax_class_id` = '123';
    

    changing 123 to the tax class ID. You may also need to add a database prefix to the table name product depending on your setup

    EDIT

    To get this to work with new products by default, open /admin/controller/catalog/product.php and change this line

    $this->data['tax_class_id'] = 0;
    

    setting the 0 to the tax class ID