I have had some help. This code below will show the message.
Need to add this:
setcookie('added_prod', $productId, time() + 60*60*24*30, '/'); // set cookie
in my snippet before this line:
$url = $modx->makeUrl($redirectTo, '', '', $redirectScheme);
and then create snippet [[!product_added]]
<?php
if (isset($_COOKIE) && isset($_COOKIE['added_prod']) && !empty($_COOKIE['added_prod'])) {
$id_prod = (int) $_COOKIE['added_prod'];
$resource = $modx->getObject('modResource',$id_prod);
setcookie("added_prod", "", time()-3600); // unset cookie
return '<div class="message">The product "'.$resource->get('pagetitle').'" is added to the basket</div>';
}
The problem now is, when a product is added it reloads the page, the message pops up, but it won't disappear when I go to an other page.