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.

  • Do you want to show coupon code on product detail page or once customer add the product then on checkout page you want to show? Commented Oct 23, 2018 at 12:55
  • no not on the checkout or even add to cart, yes on the detail page i need to show like a message or drop down, once you purchase this washer you will benefit 10% discount on all washers available on the store. thanks shubham for the great support and fast reply.
    – Marcos
    Commented Oct 23, 2018 at 13:06
  • so we can do one thing why dont we show a simple message on product detail page that if you buy this product then you will get 10% discount using this coupon code. for showing this message create a cms block and then call that block on your product detail page by checking the categories id like if you selected x category only then this block message will show.hope this approach help. Commented Oct 23, 2018 at 13:15
  • we can show this as message of course and as block like you are saying but, effectively, how this end user will benefit from a promo next time on the dryers? i mean we need a validation for the promo code, i need to set a rule for the promo code if this user made a purchase on the washer then this promo code will be valid, how can we do that? online shopping cart already checked and dead end!
    – Marcos
    Commented Oct 23, 2018 at 13:49
  • Yes exactly we need to create a rule for that and as far as in my knowledge we can set number of time single user can use that code what i understand by your above comment is that user can only use this promo code only on washers is it? If its like this then it can be done by the rule which you will create where we can restrict this promo code for specific category or product. Commented Oct 23, 2018 at 17:48

1 Answer 1


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.

  • i hope i give a proper information if you have any other query you can ask here. Commented Oct 24, 2018 at 9:28
  • hello dear thanks for the great answer; just need to ask you the attribute what type should it be? yes/no or what? and as for the promo code 10% discount everything is clean and clear except point 5 ; what do you mean by loading the customer ID? shall i write a code like the link saying in the customer.phtml? there is many answers in the link can you be more specific since i am testing this right now as we speak.
    – Marcos
    Commented Oct 24, 2018 at 11:30
  • dear kindly note i created a promo code 10% for dryers and i created a promo_code attribute for customer but i'm still missing the message in the product details page, i couldn't make it by CMS BLOCK please help! also i need the validation of the promo_code how to display or valid the promo code?
    – Marcos
    Commented Oct 24, 2018 at 11:48
  • ok so we will go one by one 1. we can take it as yes/no because we just need to identity one value. 2 . loading customer id means if you want to update the value of promo_code for that you need to load the customer then only you can set the value of promo_code. Commented Oct 24, 2018 at 12:13
  • for showing message on product detail page you have to call a cms block on it and you have to put the pormo code(which you generate by rule) statically in message.and about validation when you were creating promo code you can see one option says like "Uses per Customer" by this you can validate that one customer can use this promo code only once not next time. i hope i cleared all your query's. :) Commented Oct 24, 2018 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.