protected static function renderButtonForUser(int $userId, \DBTech\Credits\Entity\Charge $charge): ?string
{
$visitor = \XF::visitor();
if (!$visitor->user_id)
{
return '
<span>
<input type="button" class="button" value="' . \XF::phrase('dbtech_credits_costs_x_y', [
'param1' => $charge->Currency->getFormattedValue($charge->cost),
'param2' => $charge->Currency->title
]) . '" />
</span>
';
}
elseif (
$userId
&& $userId != $visitor->user_id
&& !$charge->Purchases->offsetExists($visitor->user_id)
) {
return '
<span>
<input
type="button"
class="button"
data-xf-click="overlay"
data-href="' . \XF::app()->router('public')->buildLink('dbtech-credits/currency/buy-content', $charge->Currency, ['content_type' => $charge->content_type, 'content_id' => $charge->content_id, 'content_hash' => $charge->content_hash]) . '"
value="' . \XF::phrase('dbtech_credits_view_for_x_y', [
'param1' => $charge->Currency->getFormattedValue($charge->cost),
'param2' => $charge->Currency->title
]) . '"
/>
</span>
';
}
return null;
}