Opencart – restrict payment and shipping methods based on products weight

Restrict payment method (for example Cash on Delivery) if product weight is above 1 kg (or any other default unit) IN: /catalog/model/payment/cod.php AFTER: public function getMethod($address, $total) { ADD: if ($this->cart->getWeight() > 1) return; Restrict shipping method, for example, disable Weight Based Shipping if weight is less than 1 kg: IN: catalog/model/shipping/weight.php BEFORE: if ($status) { ADD: if ($this->cart->getWeight() < 1) {$status = false;} […]

Read More»

Push free shipping when available – Opencart

<file name=”catalog/model/shipping/flat.php”> <operation> <search position=”before”><![CDATA[ if ($status) { ]]></search> <add><![CDATA[ if ((float)$this->cart->getTotal() >= $this->config->get(‘free_total’)) { $status = false; } ]]></add> </operation> </file>

Read More»

Category id in product

Open catalog/controler/product/product.php Find first Add after it Open catalog/view/theme/*/template/procuct/product.php Add this wherever you want

Read More»

Division by zero in weight.php

PHP Warning: Division by zero in ******\PHP\htdocs\online\system\library\weight.php on line 38 right code: public function convert($value, $from, $to) { if ($from == $to) { return $value; } if (isset($this->weights[$from])) { $from = $this->weights[$from][‘value’]; } else { $from = 0; } if (isset($this->weights[$to])) { $to = $this->weights[$to][‘value’]; } else { $to = 0; } if($from == 0){ […]

Read More»

Add products from subcategory to category in OpenCart

Open file catalog/controller/product/category.php Add filter_sub_category = true; in the array:   Code from ign

Read More»

Different product templates in Opencart

Copy the product.tpl file and adjust to what you want. Now presuming the product_id of this item is always going to be the same, what you can do is this… In the controller\product\product.php file, find this: if (file_exists(DIR_TEMPLATE . $this->config->get(‘config_template’) . ‘/template/product/product.tpl’)) { $this->template = $this->config->get(‘config_template’) . ‘/template/product/product.tpl’; } else { $this->template = ‘default/template/product/product.tpl’; } […]

Read More»
shared on