<?php
/*
Plugin Name: edd-addons
Plugin URI:
Description:
Version:
Author:
Author URI:
License:
License URI:
*/
/**
*
* Outputs Custom fields
*
*/
function pippin_edd_custom_checkout_fields() {
?>
<p>Please indicate your membership:</p>
<table>
<tr>
<td>
<input name="membertype" type="radio" value="new_pract" id="new_pract" />
</td>
<td>
<label for="new_pract">New Practioner</label>
</td>
</tr>
<tr>
<td>
<input name="membertype" type="radio" value="renew_prac" id="renew_prac" />
</td>
<td>
<label for="renew_prac">Renewing Practioner</label>
</td>
</tr>
<tr>
<td>
<input name="membertype" type="radio" value="renew_updated" id="renew_prac_updated" />
</td>
<td>
<label for="renew_prac_updated">Renewing Practioner with Updated Contact Information</label>
</td>
</tr>
<tr>
<td>
<input name="membertype" type="radio" value="friend" id="friend" />
</td>
<td>
<label for="friend">Renewing Friend without updated contact information</label>
</td>
</tr>
<tr>
<td>
<input name="membertype" type="radio" value="new-friend" id="new-friend" />
</td>
<td>
<label for="new-friend">New or Renewing Friend with updated contact information</label>
</td>
</tr>
<tr>
<td>
<input name="membertype" type="radio" value="student" id="student" />
</td>
<td>
<label for="student">Student</label>
</td>
</tr>
</table>
<div id="contact_data">
<p>
<label class="edd-label" for="edd-phone">
<?php _e('Phone Number', 'edd'); ?>
</label>
<input class="edd-input required" type="text" name="edd_phone" id="edd-phone" placeholder="<?php _e('Phone Number', 'edd'); ?>" value=""/>
<label class="edd-label" for="edd-address">
<?php _e('Address', 'edd'); ?>
</label>
<input class="edd-input required" type="text" name="edd_address" id="edd-address" placeholder="<?php _e('Address', 'edd'); ?>" value=""/>
<label class="edd-label" for="edd-city">
<?php _e('City', 'edd'); ?>
</label>
<input class="edd-input required" type="text" name="edd_city" id="edd-city" placeholder="<?php _e('City', 'edd'); ?>" value=""/>
<label class="edd-label" for="edd-state">
<?php _e('State', 'edd'); ?>
</label>
<input class="edd-input required" type="text" name="edd_state" id="edd-state" placeholder="<?php _e('State', 'edd'); ?>" value=""/>
<label class="edd-label" for="edd-zip">
<?php _e('Zip', 'edd'); ?>
</label>
<input class="edd-input required" type="text" name="edd_zip" id="edd-zip" placeholder="<?php _e('Zip', 'edd'); ?>" value=""/>
</p>
</div>
<div id="new_pract_fields">
<label>Name of Instructor and Feng Shui School or Program</label><input type="text" placeholder="<?php _e('Progarm Complete', 'edd'); ?>" name="edd_program_complete" id="edd-program_complete" />
<label>Program Completion Date</label><input type="text" placeholder="<?php _e('Progarm Complete Date', 'edd'); ?>" name="edd_program_complete_date" id="edd-program_complete_date" />
<label>Total Program hours</label><input type="text" placeholder="<?php _e('Progarm Total Hours', 'edd'); ?>" name="edd_program_total_hours" id="edd-program_total_hours" />
</div>
<div id="new-renew_pract_fields">
<label class="edd-label" for="edd-business">
<?php _e('Business Name', 'edd'); ?>
</label>
<input class="edd-input" type="text" name="edd_business" id="edd-business" placeholder="<?php _e('Business Name', 'edd'); ?>" value=""/>
<strong>Feng Shui Speciality</strong>
<table class="hours" border="0">
<tr>
<td><input type="radio" class="edd-input" name="edd_speciality" value="Residential"></td>
<td><label>Residential</label></td>
</tr>
<tr>
<td><input type="radio" name="edd_speciality" class="edd-input" value="Business/Commercial" style="float:left;"></td>
<td><label>Business/Commercial</label></td>
</tr>
</table>
<label class="edd-label" for="edd-description">
<?php _e('Business description for website directory', 'edd'); ?>
</label>
<textarea class="edd-input" rows="4" cols="50" name="edd_description" id="edd-description"><?php _e('Business description', 'edd'); ?>
</textarea>
</div>
<div id="edd_credits">
<p>6 hours of continuing education credits are required for practitioner membership renewal. Please list CEUs below. <a href="http://fsim.org.s2956.gridserver.com/membership-info/renewal-forms/" target="_blank"><br>
<em>See Continuing Education Requirements for course eligibility requirements</em></a>.</p>
<p>
<label class="edd-label" for="edd-meetings">
<?php _e('FSIM Membership Meetings attended in 2012', 'edd'); ?>
</label>
<table class="hours" width="70%" border="0">
<tr>
<td colspan="2"><strong>Continuing Education Units (CEUs)</strong></td>
</tr>
<tr>
<td><input type="checkbox" name="edd_meetings[]" class="edd-meetings" value="January 10 2012 1.5" <?php
if ($_POST && in_array('January 10, 2012 1.5', $_POST['edd_meetings'])) {
echo 'checked';
} ?>>
January 10, 2012</td>
<td>1.5 hours</td>
</tr>
<tr>
<td><input type="checkbox" name="edd_meetings[]" class="edd-meetings" value="April 10 2012 1.5" <?php
if ($_POST && in_array('April 10, 2012 1.5', $_POST['edd_meetings'])) {
echo 'checked';
} ?>>
April 10, 2012</td>
<td>1.5 hours</td>
</tr>
<tr>
<td><input type="checkbox" name="edd_meetings[]" class="edd-meetings" value="July 10 2012 1.5"<?php
if ($_POST && in_array('July 10, 2012 1.5', $_POST['edd_meetings'])) {
echo 'checked';
} ?>>
July 10, 2012</td>
<td>1.5 hours</td>
</tr>
<tr>
<td><input type="checkbox" name="edd_meetings[]" class="edd-meetings" value="November 3 2012 Field Trip 1.5" <?php
if ($_POST && in_array('November 3, 2012 Field Trip 1.5', $_POST['edd_meetings'])) {
echo 'checked';
} ?>>
November 3, 2012 Field Trip</td>
<td>1.5 hours</td>
</tr>
<tr>
<td colspan="3"><input type="checkbox" id="additional_edd" style="float:left;" />
<label>Check if you attended a session other than the ones listed above</label></td>
</tr>
</table>
<div id="additional_edd_fields">
<table>
<tr>
<td> Date </td>
<td> Course </td>
<td> Hours </td>
</tr>
<tr>
<td><input type="text" class="edd_date" id="ed_date-text-1" name="ed_date-text-1" /></td>
<td><input type="text" class="edd_course" id="ed_course-text-1" name="ed_course-text-1" /></td>
<td><input type="text" class="edd_hours" id="ed_hours-text-1" name="ed_hours-text-1" /></td>
</tr>
<tr>
<td><input type="text" class="edd_date" id="ed_date-text-2" name="ed_date-text-2" /></td>
<td><input type="text" class="edd_course" id="ed_course-text-2" name="ed_course-text-2" /></td>
<td><input type="text" class="edd_hours" id="ed_hours-text-2" name="ed_hours-text-2" /></td>
</tr>
<tr>
<td><input type="text" class="edd_date" id="ed_date-text-3" name="ed_date-text-3" /></td>
<td><input type="text" class="edd_course" id="ed_course-text-3" name="ed_course-text-3" /></td>
<td><input type="text" class="edd_hours" id="ed_hours-text-3" name="ed_hours-text-3" /></td>
</tr>
</table>
<table>
<tr>
<td>
<input type="text" name="edd-meetings_total" id="edd-meetings_total" style="display:none;" value="" /></td>
</tr>
</table>
</p>
</div>
</div>
<?php
}
add_action('edd_purchase_form_user_info', 'pippin_edd_custom_checkout_fields');
// check for errors with out custom fields
function pippin_edd_validate_custom_fields($data) {
if(!isset($data['edd_phone']) || $data['edd_phone'] == '') {
// check for a phone number
edd_set_error( 'invalid_phone', __('Please provide your phone number.', 'pippin_edd') );
}
if(!isset($data['edd_address']) || $data['edd_address'] == '') {
// check for an address
edd_set_error( 'invalid_address', __('Please provide your mailing address.', 'pippin_edd') );
}
if(!isset($data['edd_city']) || $data['edd_city'] == '') {
// check for a city
edd_set_error( 'invalid_city', __('Please provide your city.', 'pippin_edd') );
}
if(!isset($data['edd_state']) || $data['edd_state'] == '') {
// check for a state
edd_set_error( 'invalid_state', __('Please provide your state.', 'pippin_edd') );
}
if(!isset($data['edd_zip']) || $data['edd_zip'] == '') {
// check for a zip
edd_set_error( 'invalid_zip', __('Please provide your zip code.', 'pippin_edd') );
}
}
add_action('edd_checkout_error_checks', 'pippin_edd_validate_custom_fields');
//print data for edd-meeting array
//if(is_array ($_POST['edd_meetings'])) {
//foreach ($_POST['edd_meetings'] as $meeting) {
//print "$meeting <br />\n";
//}
//};
// store the custom field data in the payment meta
function pippin_edd_store_custom_fields($payment_meta) {
$payment_meta['firstName'] = isset($_POST['edd_first']) ? $_POST['edd_first'] : '';
$payment_meta['lastName'] = isset($_POST['edd_last']) ? $_POST['edd_last'] : '';
$payment_meta['address'] = isset($_POST['edd_address']) ? $_POST['edd_address'] : '';
$payment_meta['city'] = isset($_POST['edd_city']) ? $_POST['edd_city'] : '';
$payment_meta['state'] = isset($_POST['edd_state']) ? $_POST['edd_state'] : '';
$payment_meta['zip'] = isset($_POST['edd_zip']) ? $_POST['edd_zip'] : '';
$payment_meta['email'] = isset($_POST['edd_email']) ? $_POST['edd_email'] : '';
$payment_meta['phone'] = isset($_POST['edd_phone']) ? $_POST['edd_phone'] : '';
$payment_meta['edd_program_complete'] = isset($_POST['edd_program_complete']) ? $_POST['edd_program_complete'] : '';
$payment_meta['edd_program_complete_date'] = isset($_POST['edd_program_complete_date']) ? $_POST['edd_program_complete_date'] : '';
$payment_meta['edd_program_total_hours'] = isset($_POST['edd_program_total_hours']) ? $_POST['edd_program_total_hours'] : '';
$payment_meta['business'] = isset($_POST['edd_business']) ? $_POST['edd_business'] : '';
$payment_meta['speciality'] = isset($_POST['edd_speciality']) ? $_POST['edd_speciality'] : '';
$payment_meta['description'] = isset($_POST['edd_description']) ? $_POST['edd_description'] : '';
$payment_meta['meetings'] = isset($_POST['edd_meetings']) ? $_POST['edd_meetings'] : '';
$payment_meta['addCreditsDateField1'] = isset($_POST['ed_date-text-1']) ? $_POST['ed_date-text-1'] : '';
$payment_meta['addCreditsCourseField1'] = isset($_POST['ed_course-text-1']) ? $_POST['ed_course-text-1'] : '';
$payment_meta['addCreditsHoursField1'] = isset($_POST['ed_hours-text-1']) ? $_POST['ed_hours-text-1'] : '';
$payment_meta['addCreditsDateField2'] = isset($_POST['ed_date-text-2']) ? $_POST['ed_date-text-2'] : '';
$payment_meta['addCreditsCourseField2'] = isset($_POST['ed_course-text-2']) ? $_POST['ed_course-text-2'] : '';
$payment_meta['addCreditsHoursField2'] = isset($_POST['ed_hours-text-2']) ? $_POST['ed_hours-text-2'] : '';
$payment_meta['addCreditsDateField3'] = isset($_POST['ed_date-text-3']) ? $_POST['ed_date-text-3'] : '';
$payment_meta['addCreditsCourseField3'] = isset($_POST['ed_course-text-3']) ? $_POST['ed_course-text-3'] : '';
$payment_meta['addCreditsHoursField3'] = isset($_POST['ed_hours-text-3']) ? $_POST['ed_hours-text-3'] : '';
return $payment_meta;
}
add_filter('edd_payment_meta', 'pippin_edd_store_custom_fields');
// show the custom fields in the "View Order Details" popup
function pippin_edd_purchase_details($payment_meta, $user_info) {
$firstName = isset($payment_meta['firstName']) ? $payment_meta['firstName'] : 'none';
$lastName = isset($payment_meta['lastName']) ? $payment_meta['lastName'] : 'none';
$address = isset($payment_meta['address']) ? $payment_meta['address'] : 'none';
$city = isset($payment_meta['city']) ? $payment_meta['city'] : 'none';
$state = isset($payment_meta['state']) ? $payment_meta['state'] : 'none';
$zip = isset($payment_meta['zip']) ? $payment_meta['zip'] : 'none';
$email = isset($payment_meta['email']) ? $payment_meta['email'] : 'none';
$phone = isset($payment_meta['phone']) ? $payment_meta['phone'] : 'none';
$edd_program_complete = isset($payment_meta['edd_program_complete']) ? $payment_meta['edd_program_complete'] : 'none';
$edd_program_complete_date = isset($payment_meta['edd_program_complete_date']) ? $payment_meta['edd_program_complete_date'] : 'none';
$edd_program_total_hours = isset($payment_meta['edd_program_total_hours']) ? $payment_meta['edd_program_total_hours'] : 'none';
$business = isset($payment_meta['business']) ? $payment_meta['business'] : 'none';
$speciality = isset($payment_meta['speciality']) ? $payment_meta['speciality'] : 'none';
$description = isset($payment_meta['description']) ? $payment_meta['description'] : 'none';
$meetings = isset($payment_meta['meetings']) ? $payment_meta['meetings'] : 'none';
$addCreditsDateField1 = isset($payment_meta['addCreditsDateField1']) ? $payment_meta['addCreditsDateField1'] : 'none';
$addCreditsDateField2 = isset($payment_meta['addCreditsDateField2']) ? $payment_meta['addCreditsDateField2'] : 'none';
$addCreditsDateField3 = isset($payment_meta['addCreditsDateField3']) ? $payment_meta['addCreditsDateField3'] : 'none';
$addCreditsCourseField1 = isset($payment_meta['addCreditsCourseField1']) ? $payment_meta['addCreditsCourseField1'] : 'none';
$addCreditsCourseField2 = isset($payment_meta['addCreditsCourseField2']) ? $payment_meta['addCreditsCourseField2'] : 'none';
$addCreditsCourseField3 = isset($payment_meta['addCreditsCourseField3']) ? $payment_meta['addCreditsCourseField3'] : 'none';
$addCreditsHoursField1 = isset($payment_meta['addCreditsHoursField1']) ? $payment_meta['addCreditsHoursField1'] : 'none';
$addCreditsHoursField2 = isset($payment_meta['addCreditsHoursField2']) ? $payment_meta['addCreditsHoursField2'] : 'none';
$addCreditsHoursField3 = isset($payment_meta['addCreditsHoursField3']) ? $payment_meta['addCreditsHoursField3'] : 'none';
?>
<li><?php echo __('First Name:', 'pippin') . ' ' . $firstName; ?></li>
<li><?php echo __('Last Name:', 'pippin') . ' ' . $lastName; ?></li>
<li><?php echo __('Address:', 'pippin') . ' ' . $address; ?></li>
<li><?php echo __('City:', 'pippin') . ' ' . $city; ?></li>
<li><?php echo __('State:', 'pippin') . ' ' . $state; ?></li>
<li><?php echo __('Zip:', 'pippin') . ' ' . $zip; ?></li>
<li><?php echo __('Email:', 'pippin') . ' ' . $email; ?></li>
<li><?php echo __('Phone:', 'pippin') . ' ' . $phone; ?></li>
<li><?php echo __('Program Completed:', 'pippin') . ' ' . $edd_program_complete; ?></li>
<li><?php echo __('Program Completion Date:', 'pippin') . ' ' . $edd_program_complete_date; ?></li>
<li><?php echo __('Total Hours:', 'pippin') . ' ' . $edd_program_total_hours; ?></li>
<li><?php echo __('Business:', 'pippin') . ' ' . $business; ?></li>
<li><?php echo __('Feng Shui Speciality:', 'pippin') . ' ' . $speciality; ?></li>
<li><?php echo __('Business description:', 'pippin') . ' ' . $description; ?></li>
<li><?php echo __('Meetings attended:', 'pippin') . '' . $meetings; ?></li>
<li><?php echo __('Meetings attended:', 'pippin') . ' ' . $meetings; ?></li>
<li><?php echo __('Meetings attended:', 'pippin') . ' ' . $meetings; ?></li>
<li><?php echo __('Additional Meetings 1:', 'pippin') . ' ' . $addCreditsDateField1; ?></li>
<li><?php echo __('Additional Meetings 1:', 'pippin') . ' ' . $addCreditsCourseField1; ?></li>
<li><?php echo __('Additional Meetings 1:', 'pippin') . ' ' . $addCreditsHoursField1; ?></li>
<li><?php echo __('Additional Meetings 2:', 'pippin') . ' ' . $addCreditsDateField2; ?></li>
<li><?php echo __('Additional Meetings 2:', 'pippin') . ' ' . $addCreditsCourseField2; ?></li>
<li><?php echo __('Additional Meetings 2:', 'pippin') . ' ' . $addCreditsHoursField2; ?></li>
<li><?php echo __('Additional Meetings 3:', 'pippin') . ' ' . $addCreditsDateField3; ?></li>
<li><?php echo __('Additional Meetings 3:', 'pippin') . ' ' . $addCreditsCourseField3; ?></li>
<li><?php echo __('Additional Meetings 3:', 'pippin') . ' ' . $addCreditsHoursField3; ?></li>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<?php
}
add_action('edd_payment_personal_details_list', 'pippin_edd_purchase_details', 10, 2);