Page 1 of 1

checking items in cart

Posted: Mon Mar 21, 2011 1:29 pm
by clevername
I am designing something to allow a link if there are items in the cart. I am wondering, is there an easy way to check if there are at least 1 item in there? Maybe NVelocity in the scriplet?

Re: checking items in cart

Posted: Tue Mar 22, 2011 6:44 am
by mazhar
Try this in your scriptlet

Code: Select all

#if($Token.Instance.User.Basket.Items.Count > 0)
Your Link here
#end

Re: checking items in cart

Posted: Tue Mar 22, 2011 10:33 am
by clevername
The thing I am designing is just a different way to show the minibasket. I, since Iposted this question, redid the Minibasket and an alternate control. Do you think it would be better to do it using the conlib? or using the scriplet?

The alternate control, I found only changes the display for the cart, either its hidden or its visible, but it does not stop it from loading all of the conlib parts. And I know using the NVelocity is not good practice because it will slow the site down, which do you think would be a little faster or better? because I know if I use that NVelocity it will only show what passes the IF/ELSE

Code: Select all

#if($Token.Instance.User.Basket.Items.Count > 0)
       [[ConLib:Custom/MiniBasketQuickCart]]
#else
       <div>link link content content</div>
#end
or

Code: Select all

[[ConLib:Custom/MiniBasketPopUp AlternateControl="EmptyCartLinks.ascx"]]
But remember this one will load both the "MiniBasketQuickCart" AND the "EmptyCartLinks.ascx" regardless if anything if is the cart.

Re: checking items in cart

Posted: Tue Mar 22, 2011 11:08 am
by clevername
actually this doesn't work

Code: Select all

#if($Token.Instance.User.Basket.Items.Count > 0)
is there a variable dictionary somewhere for Nvelocity Variables available in AbleCommerce?

Re: checking items in cart

Posted: Wed Mar 23, 2011 3:23 am
by mazhar
Try it like this

Code: Select all

#if($User.Basket.Items.Count > 0)
Have a look at this topic for NVelocity parameters http://wiki.ablecommerce.com/index.php/ ... scriptlets

Re: checking items in cart

Posted: Wed Mar 23, 2011 8:24 am
by clevername
Yea I have been to that page plenty of times in search of a more indepth look at the Nvelocity variables but those are really just the top level parts. The only way I could drill down the correct variable string would be trail and error and I would hope there is a better way.

Re: checking items in cart

Posted: Wed Mar 23, 2011 8:30 am
by clevername
That Nvelocity was correct, and thank you for helping me with that. However, it will not work as effciently as the alternate content because that conlib is built in ajax and will automatically switch it to that alternate content without having to refresh the page.