cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Voucher codes from the order

Former Member
0 Kudos

I have a requirement that I need to send the vouchers applied for an order to an external system through a web service call. If the user applies the voucher to the cnd did't place the order then the web service call should not happen. So the web service call should be done at the end of the submit order strategy.

My approach is to write a listener that looks for the OrderCompletedEvent. As soon as this event occurs the REST call will be triggered. Now the issue I am facing is I am not able to get the Voucher Code applied to the Order form the Order model. All I can get are the Voucher code (3 bytes id), voucher name, discount value etc. but not the actual voucher(AC3-MX23-HKHH-FK82). I have tried to use the VoucherService's - voucherService.getAppliedVoucherCodes(orderModel); and VoucherFacade's - voucherFacade.getVouchersForCart() methods, but none of these are working.

Can anybody help me how to get the voucher code from the Order. Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

former_member357259
Active Contributor
0 Kudos

Hi Sainadh,

The actual applied code is stored in the attribute AbstractOrder.appliedVoucherCodes which stores applied codes as a collection of strings. You can retrieve the value from there. Its possible that that the getAppliedVoucherCodes() or getVouchersForCart() are not correctly implemented to return this value.

By the way, all these issues will be fixed by the new Coupons (v6.1) that are going to replace the legacy vouchers.

Answers (0)