Customising MarketConnect Promotions and Upsells

From WHMCS Documentation

Landing Pages

The MarketConnect landing pages are controlled by template files and can be customised by editing the files located within the store directory of your active WHMCS template.

Promotions and Upsells

Note:
This documentation apples only to WHMCS version 7.5 and earlier. For version 7.6 and later refer to these instructions.

MarketConnect Promotions and Upsells displayed within the client area and shopping content can be manipulated and modified using hooks.

An example of such a hook for modifying the text of promotions is provided below.

Installing the hook

To install the hook, copy and paste the code below into a new file and save and upload it to the includes/hooks/ directory of your WHMCS installation.

<?php

add_hook('ClientAreaFooterOutput', 1, function() {
    return <<<EOF
<script>

var hashtable = {};
hashtable['Protect your website'] = 'Protect your domain';
hashtable['Included with your SSL certificate'] = 'What you get with your SSL Certificate';
hashtable['Display a security seal on your site'] = 'Display a site seal to add trust';

$(document).ready(function() {
    $('.promo-banner,.addon-promo-container').each(function( index ) {
        var banner = $(this);
        $.each(hashtable, function( index, value ) {
            banner.html(banner.html().replace(index, value));
        });
    });
});
</script>
EOF;
});

How it works

The hook works by looping through each promotional banner displayed on the page and replacing all the given phrases with their replacement values.

You can add as many different search and replace values as you wish, simply by adding additional hashtable lines. Their format is as follows:

hashtable['Phrase to look for'] = 'Phrase to replace with';

Sidebar Promotions

Sidebar promotions such as the one for the Weebly Website Builder can be manipulated using hooks in the normal way.

An example of such a hook that modifies the title, content and link of the Weebly Site Builder promotion is provided below.

<?php

add_hook('ClientAreaSidebars', 1, function() {

    $secondarySidebar = Menu::secondarySidebar();

    $websiteBuilderPromo = $secondarySidebar->getChild('Website Builder Promo');
    if (!is_null($websiteBuilderPromo)) {

        $title = 'Add Website Builder';

        $bodyHtml = 'Add the Weebly Website Builder to your site';

        $footerHtml = '<a href="' . routePath('store-websitebuilder-index') . '">
                <i class="fa fa-shopping-cart fa-fw"></i>
                Get started from just $5
            </a>';

        $websiteBuilderPromo->setLabel($title)
            ->setBodyHtml($bodyHtml)
            ->setFooterHtml($footerHtml);

    }
});