DEDUCTING A "REGISTRATION FEE" FROM THE FIRST PAYMENT ONLY - Feb 18th, 2011
|
My client wants to charge a registration fee to create a database record for new potential students. Then she wants to refund the registration fee (only once) if a student signs up and pays for a class.
Here’s the logic and the code required:
1) When the parent of a potential student wants to register, they first pay a small registration fee. (The registration fee value is pulled from a field in a single record editor called “common_information”) On submission of the application, a checkbox in the accounts database called “ registration fee refund” is automatically set to ‘1" with this code which is added to the series of mysql querys in the signup form, under “mysql_query("INSERT INTO `{$TABLE_PREFIX}accounts` SET”:
registration_fee_refund = '1',
2) When a parent goes to the pay tuition page, if the “registration_fee_refund” checkbox =1, the tuition fee displayed reflects the refund using this code:
First, a note telling the parent that their registration fee will be deducted from their tuition price.
<?PHP if ($CURRENT_USER['registration_fee_refund'] == 1): ?><br /> *** Your ONE TIME registration fee refund is reflected in the tuition prices below. ***<br /> <?PHP endif ?>
Then deduct the registration fee from the normal tuition fee with this code:
Step A) define a variable for the deposit amount using a 2 decimal place number format:
<?php $deposit_amount = number_format($common_informationRecord['deposit_amount'],2); ?>
Step B) If applicable, subtract the deposit amount from the normal tuition amount (pulled from a field in a multi record editor called “tuition_fees”.
<?php foreach ($tuition_feesRecords as $record): ?> <?PHP if ($CURRENT_USER['registration_fee_refund'] == 1): ?><?php echo number_format(($record['normal_tuition_amount'] - $deposit_amount),2) ?><?php else:?><?php echo number_format($record['normal_tuition_amount'] ,2) ?> <?PHP endif ?> <?php endforeach ?>
3) After payment, the parent is automatically redirected to a “thank you” page. When the “thank you” page loads, if value of the refund registration fee field value is “1", the field is automatically reset to “0"
<?php if ($CURRENT_USER ['registration_fee_refund'] == 1): ?> <?php mysqlStrictMode(false); $query = "UPDATE `{$TABLE_PREFIX}accounts` SET registration_fee_refund = 0 WHERE num = '".mysql_escape( $CURRENT_USER['num'] )."'"; mysql_query($query) or die("MySQL Error:<br />\n". htmlspecialchars(mysql_error()) . "\n"); $userNum = mysql_insert_id(); ?> <?php endif ?>
|
The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact
Interactive Tools for information on the downloading of the software or the purchasing of licenses.