Magento – Minimum order subtotal for customer group

customer-groupmagento-1.8orders

Whats the best way to set a minimum subtotal for customer group? Is this even possible in native Magento?

Best Answer

it is possible but you need some customization.

Magento check the min Order amount from validateMinimumAmount function of checkout address object means Sales quote addess object (class Mage_Sales_Model_Quote_Address). You can rewrite the class and override the method

You need fetch quote Customer group and put minimum amount according to customer group.

and logic should be like that

class Your_Module_Model_Quote_Address extends Mage_Sales_Model_Quote_Address
{

 public function validateMinimumAmount()
 {
     $result = parent::validateMinimumAmount();
     if (!$result) {
         return false;
     }

    $customergroupId=$this->getQuote()->getCustomerGroupId();


    $CustomGroupMinprice=array(1=>100,2=>500,3=>200);

    if(!is_null($customergroupId) && array_key_exists($customergroupId,$CustomGroupMinprice)){
        foreach($CustomGroupMinprice as $key=>$value):
        if($customergroupId==$key && $this->getBaseSubtotalWithDiscount() < $value):
        return false;
        break;
        endif;
        endforeach;


    }elseif($this->getBaseSubtotalWithDiscount() < $amount) {
        return false;
    }

    return true;
}

}

in $CustomGroupMinprice=array(1=>100,2=>500,3=>200), 1,2,3 mean customer group id and 100,300,200 its respective minimum amount

Related Topic