Difference between revisions of "Customising MarketConnect Promotions and Upsells"

From WHMCS Documentation

(Created page with "MarketConnect Promotions and Upsells content can be manipulated and modified using hooks. An example of such a hook is provided below. ==Installing the hook== To install th...")
 
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
MarketConnect Promotions and Upsells content can be manipulated and modified using hooks.
+
==Landing Pages==
  
An example of such a hook is provided below.
+
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.
  
==Installing the hook==
+
==Promotions and Upsells==
 +
 
 +
<div class="docs-alert-warning">
 +
<span class="title">Note:</span><br />
 +
This documentation apples only to WHMCS version 7.5 and earlier. For version 7.6 and later refer to [https://marketplace.whmcs.com/help/connect/kb/overview/general/customisation_and_localisation_of_promotions these instructions].
 +
</div>
 +
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.
 
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.
Line 20: Line 30:
  
 
$(document).ready(function() {
 
$(document).ready(function() {
     $('.promo-banner').each(function( index ) {
+
     $('.promo-banner,.addon-promo-container').each(function( index ) {
 
         var banner = $(this);
 
         var banner = $(this);
 
         $.each(hashtable, function( index, value ) {
 
         $.each(hashtable, function( index, value ) {
Line 33: Line 43:
 
</source>
 
</source>
  
==How it works==
+
===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.
 
The hook works by looping through each promotional banner displayed on the page and replacing all the given phrases with their replacement values.
Line 41: Line 51:
 
<source lang="php">
 
<source lang="php">
 
hashtable['Phrase to look for'] = 'Phrase to replace with';
 
hashtable['Phrase to look for'] = 'Phrase to replace with';
 +
</source>
 +
 +
==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.
 +
 +
<source lang="php">
 +
<?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);
 +
 +
    }
 +
});
 
</source>
 
</source>

Latest revision as of 09:59, 30 August 2018

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

    }
});