Miva Merchant

Integration with Miva Merchant involves adding Fanplayr script to your template files.

Adding the Script to your Template

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 ISO 4217 of your store currency.

You can find the footer in your admin by going to:

  • User Interface

  • Settings

  • Then scroll down to Global Header & Footer

<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>

Session Offers

You can enable Session Offers by uncommenting (removing the // before each line) in the "OPTIONAL Session Offers" section as seen above. For example:

m.sessionOffersPrefix = 'fp_';
m.sessionOffersSelector = '#l-bask-coupon';

The values you will need to set:

sessionOffersPrefix

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.

sessionOffersSelector

This needs to be the jQuery selector to your coupon entry field. If you need any help, please contact your Fanplayr representative.

Last updated