Question

kindly note i need to display a coupon code worth 10% for selection of products to all clients once they checkout any product from my store; i.e. I made a transaction for a washer worth 500$, i need to show this user a promo code near the product description, you will benefit a 10% discount on all dryers lets say with a promo code or coupon code.

Was it helpful?

Solution

Hey You have to do Following things to achieve this:

  1. Create a customer attribute let's say promo_code for creating this you can use this link.

  2. once you created a customer code and customer bought a washer for your site at that time you need to update this attribute value which is a simple task like if customer make transaction then from using customer session you can load customer and can update the promo_code attribute value.

  3. Once we updated the value of promo_code attribute and customer come back again to your site then on Product detail page you can show the promo code which you create for 10% off so that customer can apply it there is also a good thing which is we can set that how many times customer can use the same promo code.for showing the message i would recommend you to create a cms block and on product detail page check if promo_code value is updated then only show this message else no.

  4. Create Promo code for 10% discount.

  5. For getting customer data you have to load the customer by id you can go through this link.

  6. Now if you want user only use promo_code once then you can again update the value of promo_code once customer used it so that next time that message won't appear on your product detail page.

Get promo_code value using below code:

if(Mage::getSingleton('customer/session')->isLoggedIn()) {
     $customerData = Mage::getSingleton('customer/session')->getCustomer();
     $customer_promo_code = $customerData->getPromoCode();
 }
?>

Now $customer_promo_code using this variable you can find out the value of promo code which you created.

once you have this you can now use this variable for showing message like:

if($customer_promo_code == 1){//check what value you get if yes (1 or 0)
//call the cms block
}

Hope this approach help.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top