Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Sample Miva SearchSpring IntelliSuggest
<mvt:comment>
<!--
Create a <mvt:item name="readytheme" param="contentsection( 'intellisuggest' )" /> and populate it with the following content.
It can then be added to the PROD, BASK, and INVC pages to display & track IntelliSuggest product recommmendations
-->
</mvt:comment>
<mvt:assign name="l.settings:searchspring:site_id" value="'abc123'" />
<mvt:if expr="'PROD' CIN l.settings:page:code">
<div class="intellisuggest" name="Product Recommendations"></div>
<script type="text/javascript" src="//cdn.searchspring.net/intellisuggest/is.min.js"></script>
<script type="text/javascript">
try{
var product_code = "&mvtj:product:code;";
IntelliSuggest.init({
siteId: '&mvt:searchspring:site_id;',
context: 'Product/' + product_code,
seed: [product_code]
});
IntelliSuggest.viewItem({
sku: product_code
});
} catch(err) {}
</script>
<mvt:elseif expr="l.settings:page:code EQ 'BASK'">
<div class="intellisuggest" name="Basket Recommendations"></div>
<script type="text/javascript" src="//cdn.searchspring.net/intellisuggest/is.min.js"></script>
<script type="text/javascript">
try{
IntelliSuggest.init({
siteId: '&mvt:searchspring:site_id;',
context:'Basket/',
seed:[<mvt:foreach iterator="item" array="basket:groups"><mvt:if expr="POS1 GT 1">,</mvt:if>'&mvtj:item:code;'</mvt:foreach>]
});
<mvt:foreach iterator="item" array="basket:groups">
IntelliSuggest.haveItem({
sku: "&mvtj:item:code;",
qty: "&mvtj:item:quantity;",
price: "&mvtj:item:price;"
});
</mvt:foreach>
IntelliSuggest.inBasket();
} catch(err) {}
</script>
<mvt:elseif expr="l.settings:page:code EQ 'INVC'">
<script type="text/javascript" src="//cdn.searchspring.net/intellisuggest/is.min.js"></script>
<script type="text/javascript">
try{
IntelliSuggest.init({
siteId: '&mvt:searchspring:site_id;',
});
<mvt:foreach iterator="item" array="order:groups">
IntelliSuggest.haveItem({
sku: "&mvtj:item:code;",
qty: "&mvtj:item:quantity;",
price: "&mvtj:item:price;"
});
</mvt:foreach>
IntelliSuggest.inSale({
orderId: "&mvtj:order:id;",
total: "&mvtj:order:total;",
city: "&mvtj:order:ship_city;",
state: "&mvtj:order:ship_state;",
country: "&mvtj:order:ship_cntry;"
});
} catch(err) {}
</script>
</mvt:if>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment