Integration with Miva Merchant involves adding Fanplayr script to your template files.
The tracking script needs to be put on each page. It's best to put it in the footer . Note that you have to replace the < ACCOUNT_KEY > with the value given to you by your Fanplayr representative and < CURRENCY > with the of your store currency.
Copy <script>
(function(d, w, s) {
var f = w.fanplayr = w.fanplayr || { _i:[] };
var m = f.miva = f.miva || {};
m.currency = '< CURRENCY >';
m.accountKey = '< ACCOUNT_KEY >';
m.pageSnip = '&mvte:page:code;';
// disable on specific pages
if (m.pageSnip === 'ORDL' || m.pageSnip === 'ACAD' || m.pageSnip === 'OCST') {
return;
}
var numOf = function(s) {
return parseFloat((s + '').replace(/[^0-9\.]/g, '') || 0);
}
m.products = [];
m.baseUrl = '&mvt:global:baseurl;';
m.cartUrl = '&mvt:urls:bask:rr;';
// OPTIONAL Session Offers
// m.sessionOffersPrefix = 'fp_';
// m.sessionOffersSelector = '#l-coupon-code';
if ( m.pageSnip !== 'INVC' ) {
<mvt:foreach iterator="item" array="global_minibasket:items">
m.products.push({
id: '&mvt:item:product:code',
sku: '&mvt:item:product:sku',
price: numOf('&mvt:item:formatted_subtotal_base_price') / numOf('&mvt:item:quantity'),
quantity: numOf('&mvt:item:quantity'),
name: '&mvt:item:product:name',
image: '&mvte:item:imagetypes:main' || '&mvt:item:product:image',
url: '&mvte:item:link;'
});
</mvt:foreach>
m.lineItemCount = '&mvt:global_minibasket:basketitemsonly_count';
m.numItems = '&mvt:global_minibasket:basket_count';
m.categoryId = '&mvt:cattree_categories[1]:code;';
m.categoryName = '&mvt:cattree_categories[1]:name;';
m.productId = '&mvt:item:code;';
m.productName = '&mvt:item:name;';
m.productSku = '&mvt:item:parts[1]:sku;';
m.productPrice = '&mvt:item:base_price;';
m.productUrl = '&mvt:product:link;';
m.productImage = '&mvt:product:image;';
m.discount = numOf('&mvt:global_minibasket:coupons[1]:total');
m.discountCode = '&mvt:global_minibasket:coupons[1]:code';
} else {
<mvt:foreach iterator="item" array="order:groups">
m.products.push({
id: '&mvt:item:product:code;',
sku: '&mvt:item:product:sku;',
price: numOf('&mvt:item:formatted_subtotal_base_price') / numOf('&mvt:item:quantity'),
quantity: numOf('&mvt:item:quantity'),
name: '&mvt:item:product:name;',
image: '&mvte:item:imagetypes:main' || '&mvt:item:product:image;',
url: '&mvte:item:link;'
});
</mvt:foreach>
m.order = {};
m.order.id = '&mvt:order:id;';
m.order.discount = numOf('&mvt:coupon:total;');
m.order.discountCode = '&mvt:coupon:code;';
m.order.shipping = numOf('&mvt:order:charges[1]:amount;');
m.order.tax = numOf('&mvt:ga_tracking:total_tax;');
m.order.email = '&mvt:order:bill_email;';
m.order.firstName = '&mvt:order:bill_fname;';
m.order.lastName = '&mvt:order:bill_lname;';
m.order.customerEmail = '&mvt:store:email;';
m.order.customerId = '&mvt:order:cust_id;';
}
var js = d.createElement(s);
var fjs = d.getElementsByTagName(s)[0];
js.async = true;
js.src = 'https://cdn.fanplayr.com/customers/miva/adaptor/adaptor.js';
fjs.parentNode.insertBefore(js, fjs);
})(document, window, 'script');
</script>
You can enable Session Offers by uncommenting (removing the // before each line) in the "OPTIONAL Session Offers" section as seen above. For example:
Copy m.sessionOffersPrefix = 'fp_';
m.sessionOffersSelector = '#l-bask-coupon';
This should be set as the prefix you are going to use for your Fanplayr specific coupons. It can be any value, but needs to only appear at the beginning of Fanplayr coupons.