Marco Expressions for eCommerce Shopping cart For Guests

Dcode warner asked on April 26, 2017 18:45

Below is a macro expression which is used to get the Order Date of the current user in the shopping cart. However, if you check out as a guest it displays nothing.

How can I adjust the script, so that it functions the same way but also get the information for those users who completes check out as a guest? Currently, it returns blank for guests whereas for registered users it displays the date correctly.

{%ECommerceContext.CurrentShoppingCart.ShoppingCartCustomer.AllOrders.FirstItem.OrderDate#%}

Recent Answers


Brenden Kehren answered on April 28, 2017 18:38

For a guest, they will not have that customer information until they provide it in the shipping area. For a cart customer, they may be forced through the registration process so you'll have that but earlier on. It's all timing and you may not get it for a guest customer.

0 votesVote for this answer Mark as a Correct answer

Dcode warner answered on April 28, 2017 18:50

Yes, guests do provide shipping and billing information in order to continue to check out.
And I have this macro on the master page (for testing purposes) so even up to "Step 6 of 6 - Payment", I can view source but it's empty.

So are you saying, even up to this last step, it still wont' get the information even if they provided in the billing and shipping step since they are 'guests'?

{% CMSContext.CurrentUser #%} returns "Public Anonymous User"

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 28, 2017 19:03

When they provide shipping/billing info they then become a customer so you should be grabbing the customer data and not the shopping cart data. So the macro would be something like this:

{% EcommerceContext.CurrentCustomer.AllOrders.FirstItem.OrderDate %}

So you'd have to determine if the current user is anonymous or not and then choose one or the other macros. I haven't tested this, just going off of what "should" work.

0 votesVote for this answer Mark as a Correct answer

Dcode warner answered on April 28, 2017 20:41

I've tried all variables of the expression. Unfortunately with no luck.

<!--Date: {% EcommerceContext.CurrentCustomer.AllOrders.FirstItem.OrderDate #%}-->
<!--Date: {% ECommerceContext.ShoppingCartCustomer.AllOrders.FirstItem.OrderDate #%}-->
<!--Date: {% ECommerceContext.CurrentShoppingCart.AllOrders.FirstItem.OrderDate #%}-->
<!--Date: {% ECommerceContext.CurrentShoppingCart.AllOrders.LastItem.OrderDate #%}-->
<!--Date: {%ECommerceContext.CurrentShoppingCart.ShoppingCartCustomer.AllOrders.FirstItem.OrderDate#%} -->
0 votesVote for this answer Mark as a Correct answer

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