Hi,
Indeed, the way you had the code placed there meant that the pixel was also added for each paypal transaction since the paypal payment method also uses the "end" view before the redirection to add its form to it through the $this->html variable.
Placing it in the if is indeed a good solution.
To avoid your code running several times if the customer reload the page, you should set a variable in the user session and check against it.
Something like that:
if(!isset($_SESSION['pixel_displayed'])) {
$_SESSION['pixel_displayed'] = true;
// your code
}
Note also that since the view files of HikaShop are in HikaShop, HikaShop is already loaded.
So the code
if(!defined('DS'))
define('DS', DIRECTORY_SEPARATOR); if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true;
is not necessary in the view files of HikaShop or in the plugins of the group "hikashop", "hikashoppayment" or "hikashopshipping".
Note also that the code:
$app =JFactory::getApplication();
$order_id = $app->getUserState('com_hikashop.order_id');
$orderClass = hikashop_get('class.order');
$order = $orderClass->get($order_id);
should also not be necessary as the order data is already available in $this->order in the "end" and the "after_end" view files.