Automatic earnings converters
From CashCrusaderWiki
Couple small code snippets and guide for automated points to cash and cash to points converters.
Points to Cash converter
An example for creating 100 points to $0.01 automatic converter to redemption page. You can edit figures to make converter(s) for any amounts.
1. Login to your CashCrusader admin panel
2. Go to Accounting -> Redemption Options
3. Enter following details
Sort Group: [any or according to your site] Qualifying Membership Type: All Description: 100 points to $0.01 Type: Points Amount: 100 Change this account type to: Do not Upgrade expires in: Never Automaticly deduct... : Yes
Special HTML, leave empty
PHP Code, copy and paste following:
// --- START OF CODE --- //------------------------------- // Edit conversion details below //------------------------------- $points_debited = 100; $cash_credited = 0.01; // dollars //------------------------------- // DO NOT EDIT BELOW //------------------------------- $amount = number_format($cash_credited * 100000 * admin_cash_factor,0,,); // Circumvent PHP5 bug http://bugs.php.net/bug.php?id=43053 @mysql_query(" INSERT INTO `".mysql_prefix."accounting` SET unixtime='". unixtime ."', transid='". maketransid($_SESSION['username']) ."', amount='$amount', username='". $_SESSION['username'] ."', type='cash', description='$points_debited converted to \$$cash_credited'"); // --- END OF CODE ---
4. Press Save redemption
Cash to Points converter
An example for creating $0.01 to 100 points automatic converter to redemption page. You can edit figures to make converter(s) for any amounts.
1. Login to your CashCrusader admin panel
2. Go to Accounting -> Redemption Options
3. Enter following details
Sort Group: [any or according to your site] Qualifying Membership Type: All Description: $0.01 to 100 points Type: Cash Amount: 0.01 Change this account type to: Do not Upgrade expires in: Never Automaticly deduct... : Yes
Special HTML, leave empty
PHP Code, copy and paste following:
// --- START OF CODE --- //------------------------------- // Edit conversion details below //------------------------------- $points_credited = 100; $cash_debited = 0.01; // dollars //------------------------------- // DO NOT EDIT BELOW //------------------------------- $amount = number_format($points_credited * 100000,0,,); // Circumvent PHP5 bug http://bugs.php.net/bug.php?id=43053 @mysql_query(" INSERT INTO `".mysql_prefix."accounting` SET unixtime='". unixtime ."', transid='". maketransid($_SESSION['username']) ."', amount='$amount', username='". $_SESSION['username'] ."', type='points', description='\$$cash_debited converted to $points_credited points'"); // --- END OF CODE ---
4. Press Save redemption