Different discount for each customer


1) Create one custom customer attribute name it.”Discount”.
2) Add event to config file to perform this discount

<events>
			<catalog_product_get_final_price>
				<observers>
					<Pnk_Customerdiscount_price_observer>
						<type>singleton</type>
						<class>Pnk_Customerdiscount_Model_Observer</class>
						<method>get_final_price</method>
					</Pnk_Customerdiscount_price_observer>
				</observers>
			</catalog_product_get_final_price>
		</events>

3) Create observer at model folder to listen event.

 public function get_final_price($observer)
	 {
		  if(Mage::getSingleton('customer/session')->isLoggedIn())
		  {
			$customer_id = Mage::getSingleton('customer/session')->getCustomerId();
			$customer = Mage::getModel('customer/customer')->load($customer_id);
			$customerDiscount = (int)$customer->getDiscount();
		  	if(round($customerDiscount)>0){
				$discount = number_format($customer->getDiscount(),0);
				$event = $observer->getEvent();
				$product = $event->getProduct();
				$product->original_price = $product->getPrice();   
				$totalDiscount = ($product->original_price * $discount)/100;
				$product->setFinalPrice($product->original_price - $totalDiscount);
				return $this;
			}
		  }
	 }

4) give discount for particulate customer from admin manage customer section.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s