Sorry if this topic has been asked before. I'm new with opencart. How can I configure a payment method for example Cash on Delivery with different category. Lets say there are 2 categories, A and B. Only Cash on Delivery is available with category A when customer wants to checkout.
What need to be changed in the cod.php? I'm using Opencart Version 3.0.3.1.
Thank you.
Found this code before which when a product has weight above 1 then disable cod.
IN: /catalog/model/payment/cod.php
AFTER: public function getMethod($address, $total) {
ADD: if ($this->cart->getWeight() > 1) return;
you can do using this module : https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=27392
if hardcoded ok then you can add this code on :
IN: /catalog/model/payment/cod.php
//category cod validation
$VALIDATE=[1,123,12,112,346]; // add your category id here
$products = $this->cart->getProducts();
foreach ($products as $cart) {
$query = $this->db->query("SELECT category_id FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$cart['product_id'] . "'");
foreach($query->rows as $cart_data){
//array_push($check,$cart_data['category_id']);
if( in_array($cart_data['category_id'] , $VALIDATE) )
{
$status=false;
}
}
}