Show # of items in the cart on the "Cart" menu button

198 views
Skip to first unread message

Yale Schachter

unread,
Aug 20, 2017, 1:30:10 AM8/20/17
to XMPie Interest Group
Hi Again,

Has anyone ever been able to show the # of items in the cart (not the total quantity - just the # of individual items) on the "Cart" menu button?

Thanks,

Yale

Wayne

unread,
Aug 22, 2017, 5:15:57 AM8/22/17
to XMPie Interest Group
Hi Yale

You can add the following code to the End of the Master Pages (ThemedPage.Master and ThemedPageFullWidth.Master)
This will allow you to use the xmp.sdk.storeFrontParams.currentUser.itemsInCar value to display the number of items in the cart.



<%
int cartCount = 0;
if(!uStore.Common.BLL.CustomerInfo.Current.IsAnonymous){
try{
cartCount = uStoreAPI.OrderProduct.GetOrderProductList(uStoreAPI.Order.GetUserCartId(uStore.GenParams.StoreID ,uStore.Common.BLL.CustomerInfo.Current.UserID),false).Length;
} catch(Exception e){
// Error Here
}              
Response.Write("<script language=javascript>\n");
Response.Write("xmp.sdk.storeFrontParams.currentUser.itemsInCart  = " + cartCount+ "\n");
Response.Write("</script>\n");  
}
%>

Yale Schachter

unread,
Aug 22, 2017, 2:32:52 PM8/22/17
to xmpie...@googlegroups.com
Hi Wayne,

Thanks for the reply. Do I not need to have the A{PI license in order to use the API / SDK calls?

Yale

--
You received this message because you are subscribed to a topic in the Google Groups "XMPie Interest Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/xmpie-users/GM84RW1ow9k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to xmpie-users+unsubscribe@googlegroups.com.
To post to this group, send email to xmpie...@googlegroups.com.
Visit this group at https://groups.google.com/group/xmpie-users.
For more options, visit https://groups.google.com/d/optout.

Kate

unread,
Sep 14, 2017, 9:14:01 AM9/14/17
to XMPie Interest Group
Could you expand more on how to display the value?

Wayne

unread,
Sep 14, 2017, 7:56:20 PM9/14/17
to XMPie Interest Group
Many different ways
This should give you some idea's and can be added to the Store Front JavaScript section

$("document").ready(function() {
if(xmp.sdk.storeFrontParams.currentUser.itemsInCart > 0 ){
    $('#Cart a').append('<div class="numberCircle" style="border-radius: 50%;float: right;display: block;position: relative;width: 36px;top: -5px;left: 12px;height: 36px;padding: 8px;background: #fff;border: 2px solid #666;color: #666;text-align: center;font: 32px Arial, sans-serif;">' + xmp.sdk.storeFrontParams.currentUser.itemsInCart +  '</div>');}
}); 


Regards,
Wayne

Yale Schachter

unread,
Sep 14, 2017, 11:14:54 PM9/14/17
to xmpie...@googlegroups.com
Hi Wayne,

In the line "if(xmp.sdk.storeFrontParams" etc., does that mean I need to have a license to use the uStore API?

Thanks,

Yale

--

Wayne

unread,
Sep 14, 2017, 11:41:00 PM9/14/17
to XMPie Interest Group
The xmp.sdk is a JavaScript object and is part of uStore and not really related to the uStore API, it is my understanding that you don't need a license to use.
However couch would be better suited to comment on this.

Regards,
Wayne

Kate

unread,
Sep 15, 2017, 2:49:00 PM9/15/17
to XMPie Interest Group
Got it working. Thanks for your help!

Jon Chan

unread,
Oct 5, 2017, 11:42:12 PM10/5/17
to XMPie Interest Group
Hi Wayne,

What other details can we get from: xmp.sdk.storeFrontParams.currentUser ?
I know we can get things like storeID, user email, user first name / last name, user company,

but i didn't know about the shopping cart

is there documentation somewhere?

Wayne

unread,
Oct 6, 2017, 12:26:16 AM10/6/17
to XMPie Interest Group
Jon,
shopping cart information is not normally found in the xmp object.
The code I sent just adds an "itemsInCart" Property.
Use your Browser Dev tool to look at the xmp object


Jon Chan

unread,
Oct 6, 2017, 1:25:48 AM10/6/17
to xmpie...@googlegroups.com
Thanks wayne!
Reply all
Reply to author
Forward
0 new messages