No credits still shows content. Need to check balance and redirect to purchase.

15 years 3 months ago #4810 by producerman1
Hey guys,
I need to know what to add to check Vodes balance and redirect for Vodes purchase. When a user clicks on the link to the page, as of now, if there are credits it will deduct. But if there are "0" credits the link still allows the view to occur. I have tried a few of the "if" examples around the threads but nothing works correctly. I get errors related to the line I tried to code. I am sure it is a simple thing. Any help would be great.

I used the example code from your threads at the top of the target page.:
Code used:
<?php
defined('_JEXEC') or die('Restricted access');
$user = & JFactory::getUser();
$path = JPATH_SITE.DS.'components'.DS.'com_vodes'.DS.'models'.DS.'credits.php';
require_once($path);
$credits =& new VodesModelCredits();
$credits->_user = $user;
$credits->decrease(2);

}

if "WHAT DO I NEED HERE TO CHECK BALANCE and REDIRECT IF 0 BALANCE"

}

else if "WHAT GOES HERE IF BALANCE AVAILABLE TO SHOW CONTENT?"
?>

Thanks so much in advance for your help.

Best wishes,

PM1

Please Log in or Create an account to join the conversation.

15 years 3 months ago - 15 years 3 months ago #4811 by Saka
if ($credits->balance()<=0) {
    // redirect
    global $mainframe;
    $mainframe->redirect('index.php?option=com_vodes', 'Buy credits!');
} else {
    // continue to show content
}

Emir Sakic
www.sakic.net

Please Log in or Create an account to join the conversation.

15 years 3 months ago #4812 by producerman1
Hey Saka,

Thanks so much!

Works as expected.

Best wishes,
PM1

Please Log in or Create an account to join the conversation.

About us

We provide high quality Joomla components created by a co-founder and original core developer of Joomla. For over a decade, our products have been used by more than 20.000 webmasters around the world.

Stay in touch