Page 1 of 1

How is unique orderNumber generated

Posted: Mon Feb 25, 2013 12:08 pm
by skala
Hello,

I have plans to extend DiscreteOrderItem to have my custom ECertOrderItem. The intention is to generate unique eCertNumber (just like orderNumber) each time a certificate (my sku) is added to the cart or when checkout is performed. For this I have added an attribute to ECertOrderItem called eCertNumber.

My question are:
1) When and how is orderNumber generated
2) Should I use hibernate to generate uniqueID for ECertOrderItem as primary key and then have some algorithm (just like orderNumber) to get eCertNumber and expose it to customers.

As I am implementing this requirement for the first time, wanted to know if this approach is okay? I would appreciate if someone can help me on the ways unique IDs, that can be shared with users, are generated.

Thanks
Skala

Re: How is unique orderNumber generated

Posted: Mon Feb 25, 2013 12:55 pm
by skala
I have answer to my first question so I need help with #2. Here is the answer to #1

1) OrderNumber is generated in BroadleafCheckoutController during order initialization process. Below is the snippet:

Code: Select all

    protected void initializeOrderForCheckout(Order order) {
        order.setOrderNumber(new SimpleDateFormat("yyyyMMddHHmmssS").format(SystemTime.asDate()));
        order.setStatus(OrderStatus.SUBMITTED);
        order.setSubmitDate(Calendar.getInstance().getTime());
    }