Antonio61 Posted September 15, 2010 Share Posted September 15, 2010 Please, could please tell me if there is any way to set minimun order per category?Category 1: minimum order 100€Category 2: minimum order 200€I have check forum, but I was not able to find any solution.Thanks. Link to comment Share on other sites More sharing options...
Zenith Posted September 15, 2010 Share Posted September 15, 2010 Not possible with the default setup, you would need to make modifications for that. Link to comment Share on other sites More sharing options...
Antonio61 Posted September 15, 2010 Author Share Posted September 15, 2010 thanks for your prompt reply.Do you know, what changes I should do?Thsnks Link to comment Share on other sites More sharing options...
Antonio61 Posted September 15, 2010 Author Share Posted September 15, 2010 There is anybody in the forum who knows, what I would need to modify in order to have the option for setting minimun order for different categories?Thanks. Link to comment Share on other sites More sharing options...
ticplanet Posted April 4, 2011 Share Posted April 4, 2011 I need the same, did you finde the solution ? Link to comment Share on other sites More sharing options...
ticplanet Posted April 15, 2011 Share Posted April 15, 2011 Hi there, I have made a modification to get minimum order for one of a category...I copy and modify the function getOrderTotal located in classes/Cart.phpHere you have new function, past it in Cart.php /* Get category cart total */ public function getCatOrderTotal($withTaxes = true, $type = 3, $cat) { if (!$this->id) return 0; $type = intval($type); if (!in_array($type, array(1, 2, 3, 4, 5, 6, 7))) die(Tools::displayError()); // no shipping cost if is a cart with only virtuals products $virtual = $this->isVirtualCart(); if ($virtual AND $type == 5) return 0; if ($virtual AND $type == 3) $type = 4; $shipping_fees = ($type != 4 AND $type != 7) ? $this->getOrderShippingCost(NULL, intval($withTaxes)) : 0; if ($type == 7) $type = 1; $products = $this->getProducts(); $order_total = 0; if (Tax::excludeTaxeOption()) $withTaxes = false; foreach ($products AS $product) { //var_dump($product); $category = new Category( intval($product['id_category_default']), intval($cookie->id_lang) ); //echo $category->id_parent; if($category->id_parent == $cat){ if ($this->_taxCalculationMethod == PS_TAX_EXC) { // Here taxes are computed only once the quantity has been applied to the product price $price = Product::getPriceStatic(intval($product['id_product']), false, intval($product['id_product_attribute']), 2, NULL, false, true, $product['cart_quantity'], false, (intval($this->id_customer) ? intval($this->id_customer) : NULL), intval($this->id), (intval($this->id_address_delivery) ? intval($this->id_address_delivery) : NULL)); $total_price = $price * intval($product['cart_quantity']); if ($withTaxes) $total_price = Tools::ps_round($total_price * (1 + floatval(Tax::getApplicableTax(intval($product['id_tax']), floatval($product['rate']))) / 100), 2); } else { $price = Product::getPriceStatic(intval($product['id_product']), $withTaxes, intval($product['id_product_attribute']), 6, NULL, false, true, $product['cart_quantity'], false, (intval($this->id_customer) ? intval($this->id_customer) : NULL), intval($this->id), (intval($this->id_address_delivery) ? intval($this->id_address_delivery) : NULL)); if (!$withTaxes) $total_price = Tools::ps_round($price * intval($product['cart_quantity']), 2); else $total_price = Tools::ps_round($price, 2) * intval($product['cart_quantity']); } $order_total += $total_price; } } $order_total_products = $order_total; if ($type == 2) $order_total = 0; // Wrapping Fees $wrapping_fees = 0; if ($this->gift) { $wrapping_fees = floatval(Configuration::get('PS_GIFT_WRAPPING_PRICE')); if ($withTaxes) { $wrapping_fees_tax = new Tax(intval(Configuration::get('PS_GIFT_WRAPPING_TAX'))); $wrapping_fees *= 1 + ((floatval($wrapping_fees_tax->rate) / 100)); } $wrapping_fees = Tools::convertPrice(Tools::ps_round($wrapping_fees, 2), new Currency(intval($this->id_currency))); } if ($type != 1) { $discounts = array(); /* Firstly get all discounts, looking for a free shipping one (in order to substract shipping fees to the total amount) */ if ($discountIds = $this->getDiscounts(true)) { foreach ($discountIds AS $id_discount) { $discount = new Discount(intval($id_discount['id_discount'])); if (Validate::isLoadedObject($discount)) { $discounts[] = $discount; if ($discount->id_discount_type == 3) foreach($products AS $product) { $categories = Discount::getCategories($discount->id); if (count($categories) AND Product::idIsOnCategoryId($product['id_product'], $categories)) { if($type == 2) $order_total -= $shipping_fees; $shipping_fees = 0; break; } } } } /* Secondly applying all vouchers to the correct amount */ foreach ($discounts AS $discount) if ($discount->id_discount_type != 3) $order_total -= Tools::ps_round(floatval($discount->getValue(sizeof($discounts), $order_total_products, $shipping_fees, $this->id, intval($withTaxes))), 2); }v } return Tools::ps_round(floatval($order_total), 2); } Next you have to put this: include_once(dirname(__FILE__).'/header.php'); $total_inst = $cart->getCatOrderTotal(true, 5,3); if($total_inst < 60){ echo ' Message!!!! '; } before $smarty->display(_PS_THEME_DIR_.'shopping-cart.tpl'); In order.phpNumbre 3 is ID of category you want minimum order.In my case I put minimum 60€ Link to comment Share on other sites More sharing options...
ticplanet Posted April 15, 2011 Share Posted April 15, 2011 This is complit condition with the style to prevent click on order button. $total_inst = $cart->getCatOrderTotal(true, 5,3); if($total_inst < 60){ echo ' Lo sentimos, pero debido a los requisitos del provedor, pedído minimo en INSTRUMENTAL tiene que superar 60€. Actualmente el total en instrumental es de: '.$total_inst.'€ Faltan: '.(60-$total_inst).'€ <style> p#cart-buttons a.exclusive, p.cart_navigation a.exclusive { display:none;} </style> '; } Link to comment Share on other sites More sharing options...
logan Posted October 4, 2011 Share Posted October 4, 2011 It's very good mod ticplanet, but it doesn't work with 1.4.4.0 . It shows blank page. Can you help us with it please? Thank you very much. Link to comment Share on other sites More sharing options...
editorstefan Posted June 20, 2013 Share Posted June 20, 2013 Does this work for 1.5? How about: Category 1: minimum $50 Category 2: minimum 3 quantity Link to comment Share on other sites More sharing options...
oncle Posted December 12, 2019 Share Posted December 12, 2019 Buenas tardes, esta modificación, es válida para PS 1.7? No me atrevo a modificar nada hasta estar seguro. Gracias!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now