Portal | Homepage | Blog

Nitrosell code conditions documentations


Where can I find the Nitrosell code conditions documentation?

For example: How can can use != in Nitrosell portal? and what is the meaning of the nsIf, ns, eq. What other conditions we can use?


Phil you can find some documentation on Nitroscript linked in this forum post.


“Not equal to” in NitroScript looks like this:

{if (product['product_id'] ne '1234')}
    // This product's ID is NOT 1234
    // ne here is "not equal"

Equal on the other hand is:

{if (product['product_id'] eq '1234')}
    // This product ID is 1234
    // eq here is "equal"

Think of nsIf: as a NitroScript “If” statement function:

// Is the predefined function that checks if the Promotion Panel is set to "enabled" in the site's settings

ns functions are usually “snippets” that insert something like the predefined Quantity input on the Product Page:

// Outputs/returns the HTML that makes up NitroSell's predefined <select> element and enclosed <option>'s that allow user to select their desired quantity

Essentially, you are limited to NitroSell’s predefined snippets/functions with the exception of being able to create custom “if” statements using the “Available Fields” in each template (see first examples at the top of this post).

There are odd-ball functions like isLoggedIn() that work all over (mostly):

{if (isNotLoggedIn())}
    // HTML for logged in users here

The best that you can do is review each template’s predefined source, and extract each function used, then reuse them when you implement your changes. NitroScript is nothing like server-side languages (PHP, ASP.NET, etc.). It is essentially programming for the non-programmer. The functions output HTML with NitroSell’s desired classes & id’s (which if you change, will usually brak the page), and the output of the functions are non-editable. What it outputs is what it outputs, no exceptions. There are no ways to pass vars or anything like that.

If you are going to make your own templates, then get ready for a ton of trial and error. Like a lot.


I forgot to mention that the little “Fields” like this one make up the majority of your custom statements:


Simply wrap them with the curly brackets and use some logic to create your statements:

{if (product['product_pricea'] gt product['product_priceb'])}
    // Checks if 'Price A' is greater than 'Price B'

{if (product['product_stock'] lte 0)}
    // Checks if 'Stock' is less than or equal to 0 (out of stock)

I also forgot to list gt, gte, lt, lte operators which mean greater than, greater than or equal to, less than, and less than or equal to respectively…

Other Stuff:
And operator:

{if (product['product_stock'] gt 0 && product['product_price'] gt 0)}
    // Product is in stock and has a price greater than zero

Or operator

{if (product['product_promotion'] eq true || product['product_specialoffer'] eq true)}
    // This product is either set as a Promotion or as a Special Offer

Just review the templates and see what is used. And always retain the listed “Available Fields” in your templates. If there are none, simply “Revert” the template to the original state, and usually these listings will reappear :slight_smile:


thanks man, it’s very help full.