• No replies
43 Posts

Pinned topic How to get promotion code that was applied to an order?

‏2013-02-13T04:49:55Z |
We have bunch of single use and unique promotion codes, but having trouble when trying to display applied code to customer in the shopping cart.

I saw following code that's used to get promo information for a regular/public/multi-use promotion code, but it's not working for a single use & unique system generated code.

PromotionKey promokey = (PromotionKey)PersistenceManagerRegistry.getInstance().getPromotionPersistenceManager().reverseLookup(PX_PROMOTION.PX_PROMOTION_ID);
Promotion promoObj = PersistenceManagerRegistry.getInstance().getPromotionPersistenceManager().load(promokey);

This is because of NULL value in PX_PROMOTION.CODE column for all system generated unique codes.

Is there another API to get promotion code that was applied to a order?

I know I can write a SQL to get data from PX_CDUSAGE as a last option, but would like to know if there is any out of box class for doing the same.