Skip to content

Commit 335ed60

Browse files
committed
Added agreement checkbox.
1 parent 183b94d commit 335ed60

File tree

5 files changed

+112
-16
lines changed

5 files changed

+112
-16
lines changed

admin/class-paystack-forms-admin.php

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ function kkd_pff_paystack_editor_add_extra_metaboxes() {
259259
add_meta_box('kkd_pff_paystack_editor_add_recur_data', 'Recurring Payment', 'kkd_pff_paystack_editor_add_recur_data', 'paystack_form', 'side', 'default');
260260
add_meta_box('kkd_pff_paystack_editor_add_email_data', 'Email Receipt Settings', 'kkd_pff_paystack_editor_add_email_data', 'paystack_form', 'normal', 'default');
261261
add_meta_box('kkd_pff_paystack_editor_add_quantity_data', 'Quantity Payment', 'kkd_pff_paystack_editor_add_quantity_data', 'paystack_form', 'side', 'default');
262+
add_meta_box('kkd_pff_paystack_editor_add_agreement_data', 'Agreement checkbox', 'kkd_pff_paystack_editor_add_agreement_data', 'paystack_form', 'side', 'default');
262263

263264
}
264265

@@ -388,6 +389,29 @@ function kkd_pff_paystack_editor_add_quantity_data() {
388389
echo '<input type="number" name="_quantity" value="' . $quantity . '" class="widefat pf-number" />
389390
<small>Your users only get to pay in quantities if the from amount is not set to zero and recur is set to none.</small>';
390391

392+
}
393+
function kkd_pff_paystack_editor_add_agreement_data() {
394+
global $post;
395+
396+
// Noncename needed to verify where the data originated
397+
echo '<input type="hidden" name="eventmeta_noncename" id="eventmeta_noncename" value="' .
398+
wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
399+
400+
// Get the location data if its already been entered
401+
$useagreement = get_post_meta($post->ID, '_useagreement', true);
402+
$agreementlink = get_post_meta($post->ID, '_agreementlink', true);
403+
404+
if ($useagreement == "") {$useagreement = 'no';}
405+
if ($agreementlink == "") {$agreementlink = '';}
406+
// Echo out the field
407+
echo '<small>Allow your users pay in multiple quantity</small><p>Use agreement checkbox:</p>';
408+
echo '<select class="form-control" name="_useagreement" style="width:100%;">
409+
<option value="no" '.kkd_pff_paystack_txncheck('no',$useagreement).'>No</option>
410+
<option value="yes" '.kkd_pff_paystack_txncheck('yes',$useagreement).'>Yes</option>
411+
</select>';
412+
echo '<p>Agreement Page Link:</p>';
413+
echo '<input type="text" name="_agreementlink" value="' . $agreementlink . '" class="widefat" />';
414+
391415
}
392416
function kkd_pff_paystack_save_data($post_id, $post) {
393417

@@ -418,6 +442,9 @@ function kkd_pff_paystack_save_data($post_id, $post) {
418442
$form_meta['_usequantity'] = $_POST['_usequantity'];
419443
$form_meta['_quantity'] = $_POST['_quantity'];
420444

445+
$form_meta['_useagreement'] = $_POST['_useagreement'];
446+
$form_meta['_agreementlink'] = $_POST['_agreementlink'];
447+
421448
// Add values of $form_meta as custom fields
422449

423450
foreach ($form_meta as $key => $value) { // Cycle through the $form_meta array!
@@ -467,6 +494,7 @@ function kkd_pff_paystack_payment_submissions(){
467494
$loggedin = get_post_meta($id,'_loggedin',true);
468495
$txncharge = get_post_meta($id,'_txncharge',true);
469496

497+
echo "<title>".$obj->post_title." Payments </title>";
470498
echo "<h1>".$obj->post_title." Payments</h1>";
471499
$exampleListTable = new Kkd_Pff_Paystack_Payments_List_Table();
472500
$exampleListTable->prepare_items();
@@ -483,17 +511,17 @@ class Kkd_Pff_Paystack_Wp_List_Table{
483511
public function __construct(){
484512
add_action( 'admin_menu', array($this, 'add_menu_example_list_table_page' ));
485513
}
486-
public function add_menu_example_list_table_page(){
514+
public function add_menu_example_list_table_page(){
487515
add_menu_page( '', '', 'manage_options', 'example-list-table.php', array($this, 'list_table_page') );
488516
}
489-
public function list_table_page(){
517+
public function list_table_page(){
490518
$exampleListTable = new Example_List_Table();
491519
$exampleListTable->prepare_items($data);
492520
?>
493-
<div class="wrap">
494-
<div id="icon-users" class="icon32"></div>
495-
<?php $exampleListTable->display(); ?>
496-
</div>
521+
<div class="wrap">
522+
<div id="icon-users" class="icon32"></div>
523+
<?php $exampleListTable->display(); ?>
524+
</div>
497525
<?php
498526
}
499527
}
@@ -508,17 +536,17 @@ function format_data($data){
508536
if (array_key_exists("0", $new)) {
509537
foreach ($new as $key => $item) {
510538
if ($item->type == 'text') {
511-
$text.= '<b>'.$item->display_name."</b> :".$item->value."<br />";
539+
$text.= '<b>'.$item->display_name.": </b> ".$item->value."<br />";
512540
}else{
513-
$text.= '<b>'.$item->display_name."</b> : <a target='_blank' href='".$item->value."'>link</a><br />";
541+
$text.= '<b>'.$item->display_name.": </b> <a target='_blank' href='".$item->value."'>link</a><br />";
514542
}
515543

516544
}
517545
}else{
518546
$text = '';
519547
if (count($new) > 0) {
520548
foreach ($new as $key => $item) {
521-
$text.= '<b>'.$key."</b> :".$item."<br />";
549+
$text.= '<b>'.$key.": </b> ".$item."<br />";
522550
}
523551
}
524552
}

paystack-forms.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,15 @@ function insertTextarea(){
109109
insertSelectb
110110
);
111111
function insertSelectb(){
112-
QTags.insertContent('[select name="Text Title" options="option 1,option 2,option 2"]');
112+
QTags.insertContent('[select name="Text Title" options="option 1,option 2,option 3"]');
113+
}
114+
QTags.addButton(
115+
"r_shortcode",
116+
"Insert Radio Options",
117+
insertRadiob
118+
);
119+
function insertRadiob(){
120+
QTags.insertContent('[radio name="Text Title" options="option 1,option 2,option 3"]');
113121
}
114122
QTags.addButton(
115123
"i_shortcode",

public/class-paystack-forms-public.php

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,8 @@ function kkd_pff_paystack_form_shortcode($atts) {
591591
$recurplan = get_post_meta($id,'_recurplan',true);
592592
$usequantity = get_post_meta($id,'_usequantity',true);
593593
$quantity = get_post_meta($id,'_quantity',true);
594+
$useagreement = get_post_meta($id,'_useagreement',true);
595+
$agreementlink = get_post_meta($id,'_agreementlink',true);
594596
$showbtn = true;
595597
$planerrorcode = 'Input Correct Recurring Plan Code';
596598
if ($recur == 'plan') {
@@ -714,10 +716,17 @@ function kkd_pff_paystack_form_shortcode($atts) {
714716

715717
// echo '<br /><p>Transaction charge:'.$currency.'<b class="txn_charge">13,000</b></p>';
716718
// echo '<p>Total charge:'.$currency.'<b class="total_charge">13,000</b></p>';
717-
718-
// echo '</form>';
719+
if ($useagreement == 'yes'){
720+
echo '<div class="span12 unit">
721+
<label class="checkbox">
722+
<input type="checkbox" name="agreement" id="pf-agreement" required value="yes">
723+
<i id="pf-agreementicon" ></i>
724+
Accept terms <a target="_blank" href="'.$agreementlink.'">Link </a>
725+
</label>
726+
</div><br>';
727+
}
719728
echo '<div class="span12 unit">
720-
<small><span style="color: red;">*</span> are compulsory</small><br />
729+
<small><span style="color: red;">*</span> are compulsory</small><br />
721730
<img src="'. plugins_url( '../images/[email protected]' , __FILE__ ) .'" alt="cardlogos" class="paystack-cardlogos size-full wp-image-1096" />
722731
723732
<button type="reset" class="secondary-btn">Reset</button>';
@@ -790,6 +799,48 @@ function kkd_pff_paystack_select_shortcode($atts) {
790799
return $code;
791800
}
792801
add_shortcode('select', 'kkd_pff_paystack_select_shortcode');
802+
function kkd_pff_paystack_radio_shortcode($atts) {
803+
extract(shortcode_atts(array(
804+
'name' => 'Title',
805+
'options' => '',
806+
'required' => '0',
807+
), $atts));
808+
$code = '<div class="span12 unit">
809+
<label class="label">'.$name;
810+
if ($required == 'required') {
811+
$code.= ' <span>*</span>';
812+
}
813+
$code.= '</label>
814+
<div class="inline-group">
815+
';
816+
// if ($required == 'required') {
817+
// $code.= ' required="required" ';
818+
// }
819+
// $code.=">";
820+
821+
$soptions = explode(',', $options);
822+
if (count($soptions) > 0) {
823+
foreach ($soptions as $key => $option) {
824+
// $code.= '<option value="'.$option.'" >'.$option.'</option>';
825+
$code.= '<label class="radio">
826+
<input type="radio" name="'.$name.'" value="'.$option.'"';
827+
if ($key == 0) {
828+
$code.= ' checked';
829+
if ($required == 'required') {
830+
$code.= ' required="required"';
831+
}
832+
}
833+
834+
$code.= '/>
835+
<i></i>
836+
'.$option.'
837+
</label>';
838+
}
839+
}
840+
$code.= '</div></div>';
841+
return $code;
842+
}
843+
add_shortcode('radio', 'kkd_pff_paystack_radio_shortcode');
793844
function kkd_pff_paystack_textarea_shortcode($atts) {
794845
extract(shortcode_atts(array(
795846
'name' => 'Title',

public/css/pff-paystack-style.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,4 +1785,7 @@
17851785
.j-forms .input .rerror {
17861786
border-color: red !important;
17871787
}
1788+
.j-forms i.rerror {
1789+
border-color: red !important;
1790+
}
17881791
/*#3676c8*/

public/js/paystack-forms-public.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
}
9595
$('.paystack-form').on('submit', function(e) {
9696
var stop = false;
97+
$("#pf-agreementicon").removeClass('rerror');
98+
9799
$(this).find("input,select, textarea").each(function() {
98100
$(this).removeClass('rerror');//.css({ "border-color":"#d1d1d1" });
99101
});
@@ -109,10 +111,14 @@
109111
stop = true;
110112
}
111113
$(this).find("input, select, textarea").filter("[required]").filter(function() { return this.value == ''; }).each(function() {
112-
$(this).addClass('rerror');///.css({ "border-color":"red" });
113-
stop = true;
114-
114+
$(this).addClass('rerror');
115+
116+
stop = true;
115117
});
118+
if($("#pf-agreement").prop('checked') == false){
119+
$("#pf-agreementicon").addClass('rerror');
120+
stop = true;
121+
}
116122
if (stop) {
117123
$('html,body').animate({ scrollTop: $('.rerror').offset().top - 110 }, 500);
118124
return false;

0 commit comments

Comments
 (0)