cancel
Showing results for 
Search instead for 
Did you mean: 

Can we increase the voucher code length ?

Former Member
0 Kudos

Currently when creating a serial / promotional voucher code through HMC, user can enter the code as maximum of 3 character alphanumeric.

We can change it by modifying the hmc.xml of the voucher extension. But is it advisable to do so ? Why the code length is restricted to 3 characters ?

Former Member
0 Kudos

Hi ,

Could you please help us how you extended the Promo Code length for Serial Voucher.

For Serial VOucher I Extended the Jalo class and overridden the CreateItem(), but still am getting the below exception,

ERROR [hybrisHTTP27] [GenericItemCreateAction] create(...): Exception occured during creation process! de.hybris.platform.servicelayer.exceptions.ModelSavingException: You need to provide exactly 3 characters for the promotion code.

Could you please help me how can I extend the Promo Code length for Serial Voucher.

Thank you. Regards, .M

0 Kudos

Hi ,

Did you get the solution for this issue?

Thanks, .

Accepted Solutions (0)

Answers (4)

Answers (4)

haythem_jaiech
Explorer
0 Kudos

Hello,

For SerialVoucher you have to override the jalo class 'SerialVoucher' to remove the condition to check the size of the attribute.

Best Regards,

0 Kudos

Hi,

Did anyone got a solution for this?

Thanks in advance.

Former Member
0 Kudos

hi Vova,

Thanks for the response. Yes we tested the same and it works for Promotional vouchers and not for Serial ones.

Do you have an idea that for Promotional vouchers if we increase the code length, what are the implications of that? We tested the voucher redeem and release functionality and it works.

Not sure why Hybris has put this restriction if nothing gets broken by increasing the code length.

Thanks.

Former Member
0 Kudos

Sorry, but I can't tell that. This functionality will require extensive testing in order to verify that the change has no impact.

Former Member
0 Kudos

When you have removed the maxlength for Voucher identifier, if you click on generate voucher code, it is no longer of 15 characters. It picks up the identifier of the voucher and adds 12 more characters to it to generate the voucher code.

Former Member
0 Kudos

Hi Bhaskar,

According to Generating Voucher Codes section voucher code will be used as the first group of generated voucher code XXX-YYYY-YYYY-YYYY.

Nothing stops you from overriding hmc restriction, just add following snippet into hmc.xml from your core extension

     <type name="PromotionVoucher" icon="ext/voucher/images/e_voucher.gif" mode="append">
        <organizer>
           <editor>
              <essentials mode="replace">
                 <listlayout>
                    <text name="text.promotionvoucher.common" width="353"/>
                    <attribute name="code"/>
                    <attribute name="name"/>
                 </listlayout>
              </essentials>
           </editor>
        </organizer>
     </type>
     <type name="SerialVoucher" icon="ext/voucher/images/e_serialvoucher.gif" mode="append">
        <organizer>
           <editor>
              <essentials mode="replace">
                 <listlayout>
                    <text name="text.serialvoucher.common" width="353"/>
                    <attribute name="code"/>
                    <attribute name="name"/>
                 </listlayout>
              </essentials>
           </editor>
        </organizer>
     </type>

However, there's also server side validation during item creation de.hybris.platform.voucher.jalo.SerialVoucher.createItem(SessionContext, ComposedType, ItemAttributeMap), I'm not sure why but the behavior is different for de.hybris.platform.voucher.jalo.PromotionVoucher.createItem(SessionContext, ComposedType, ItemAttributeMap).

Anyway you would also need to override this logic as well if you want to get rid of this restriction.