Pull 'Order Id' and 'Order Date' from Kentico shopping cart

Dcode warner asked on June 29, 2017 20:16

Hey there. (posting as a new question).

Is there a work around to display the 'Order number' and 'Order date' for guests (not signed in) Im able to generate for price/total shipping and payment option but not for the ID. I understand these are not generated until the order is placed? Is this correct?

What's a good work around so I can get the ID number since it's displaying right there on the page.ugh: [screenshot] http://prntscr.com/fpodxy

All the following works except when checking out as guest where it displays as blank.

order number: {%ECommerceContext.CurrentShoppingCart.ShoppingCartCustomer.AllOrders.IDs #%} {%ECommerceContext.CurrentShoppingCart.ShoppingCartCustomer.Orders #%} {%ECommerceContext.CurrentShoppingCart.ShoppingCartCustomer.AllOrders.FirstItem.OrderInvoiceNumber#%} {%ECommerceContext.CurrentShoppingCart.ShoppingCartCustomer.AllOrders.FirstItem.OrderDate#%} {%ECommerceContext.CurrentShoppingCart.ShoppingCartUser.Orders.LastItem.OrderInvoiceNumber #%} {%ECommerceContext.CurrentShoppingCart.ShoppingCartUser.Orders.Where("OrderID="+OrderID).FristItem.OrderInvoiceNumber #%}

order date: {% ECommerceContext.CurrentShoppingCart.ShoppingCartCustomer.Orders.LastItem.OrderDate #%} {% EcommerceContext.CurrentCustomer.AllOrders.FirstItem.OrderDate #%}

Recent Answers

Trevor Fayas answered on June 30, 2017 17:05

Correct that the Order object does not get created until you come to the Payment Screen (then an order is 'created' and marked as unpaid until payment is made).

Guest checkouts can be tricky because there's no UserID attached to them, and the CurrentShoppingCartCustomer may be getting lost after the shopping cart is converted to an order.

There is probably a better way to do this, but short on time so at minimum you can look to do a catch on the Ecommerce global event hook for the order creation, and then either set a custom Macro value (using MacroContext.CurrentResolver.SetNamedSourceData(String, Object, Boolean) ) to store the OrderID that was just created for this user, then you can reference that when looking up orders.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.