@@ -723,8 +723,19 @@ function kkd_pff_paystack_form_shortcode($atts) {
723723 $ useagreement = get_post_meta ($ id ,'_useagreement ' ,true );
724724 $ agreementlink = get_post_meta ($ id ,'_agreementlink ' ,true );
725725 $ minimum = get_post_meta ($ id ,'_minimum ' ,true );
726- if ($ minimum == "" ) {$ minimum = 0 ;}
727-
726+ $ variableamount = get_post_meta ($ id ,'_variableamount ' ,true );
727+ $ usevariableamount = get_post_meta ($ id ,'_usevariableamount ' ,true );
728+ if ($ minimum == "" ) {$ minimum = 0 ;}
729+ if ($ usevariableamount == "" ) {$ usevariableamount = 0 ;}
730+
731+ if ($ usevariableamount == 1 ) {
732+ // $variableamount = '3GB Etisalat:10000';
733+ $ paymentoptions = explode (', ' , $ variableamount );
734+ echo "<pre> " ;
735+ print_r ($ paymentoptions );
736+ echo "</pre> " ;
737+ // die();
738+ }
728739 $ showbtn = true ;
729740 $ planerrorcode = 'Input Correct Recurring Plan Code ' ;
730741 if ($ recur == 'plan ' ) {
@@ -740,12 +751,10 @@ function kkd_pff_paystack_form_shortcode($atts) {
740751 }
741752
742753 }
743- // print_r($loggedin);
744754 if ((($ user_id != 0 ) && ($ loggedin == 'yes ' )) || $ loggedin == 'no ' ) {
745755
746756 echo "<h1 id='pf-form " .$ id ."'> " .$ obj ->post_title ."</h1> " ;
747- // echo get_site_url().'/paystackinvoice/?code=ddddddd';
748- echo '<form version="2.0.7" enctype="multipart/form-data" action=" ' . admin_url ('admin-ajax.php ' ) . '" url=" ' . admin_url () . '" method="post" class="paystack-form j-forms" novalidate>
757+ echo '<form version="2.0.8" enctype="multipart/form-data" action=" ' . admin_url ('admin-ajax.php ' ) . '" url=" ' . admin_url () . '" method="post" class="paystack-form j-forms" novalidate>
749758 <div class="j-row"> ' ;
750759 echo '<input type="hidden" name="action" value="kkd_pff_paystack_submit_action"> ' ;
751760 echo '<input type="hidden" name="pf-id" value=" ' . $ id . '" /> ' ;
@@ -756,9 +765,6 @@ function kkd_pff_paystack_form_shortcode($atts) {
756765 <div class="input">
757766 <input type="text" name="pf-fname" placeholder="First & Last Name" value=" ' . $ fullname . '"
758767 ' ;
759- // if($loggedin == 'yes'){
760- // echo 'readonly ';
761- // }
762768
763769 echo ' required>
764770 </div>
@@ -778,36 +784,55 @@ function kkd_pff_paystack_form_shortcode($atts) {
778784 echo '<div class="span12 unit">
779785 <label class="label">Amount ( ' .$ currency .') <span>*</span></label>
780786 <div class="input"> ' ;
781- // echo "<pre>".$minimum. "</pre>";
782- if ($ minimum == 1 ) {
783- echo '<small> Minimum payable amount <b style="font-size:87% !important;"> ' .$ currency .' ' .number_format ($ amount ).'</b></small> ' ;
784- }
785- if ($ recur == 'plan ' ) {
786- if ($ showbtn ) {
787- echo '<input type="text" name="pf-amount" value=" ' .$ planamount .'" id="pf-amount" readonly required/> ' ;
788- }else {
789- echo '<div class="span12 unit">
790- <label class="label" style="font-size:18px;font-weight:600;line-height: 20px;"> ' .$ planerrorcode .'</label>
791- </div> ' ;
792- }
793- }elseif ($ recur == 'optional ' ){
794- echo '<input type="text" name="pf-amount" class="pf-number" id="pf-amount" value="0" required/> ' ;
795- }else {
796- if ($ amount == 0 ) {
797- echo '<input type="text" name="pf-amount" class="pf-number" value="0" id="pf-amount" required/> ' ;
798- }elseif ($ amount != 0 && $ minimum == 1 ){
799- echo '<input type="text" name="pf-amount" value=" ' .$ amount .'" id="pf-amount" required/> ' ;
800- }else {
801- echo '<input type="text" name="pf-amount" value=" ' .$ amount .'" id="pf-amount" readonly required/> ' ;
787+ if ($ usevariableamount == 0 ) {
788+ if ($ minimum == 1 ) {
789+ echo '<small> Minimum payable amount <b style="font-size:87% !important;"> ' .$ currency .' ' .number_format ($ amount ).'</b></small> ' ;
790+ }
791+ if ($ recur == 'plan ' ) {
792+ if ($ showbtn ) {
793+ echo '<input type="text" name="pf-amount" value=" ' .$ planamount .'" id="pf-amount" readonly required/> ' ;
794+ }else {
795+ echo '<div class="span12 unit">
796+ <label class="label" style="font-size:18px;font-weight:600;line-height: 20px;"> ' .$ planerrorcode .'</label>
797+ </div> ' ;
798+ }
799+ }elseif ($ recur == 'optional ' ){
800+ echo '<input type="text" name="pf-amount" class="pf-number" id="pf-amount" value="0" required/> ' ;
801+ }else {
802+ if ($ amount == 0 ) {
803+ echo '<input type="text" name="pf-amount" class="pf-number" value="0" id="pf-amount" required/> ' ;
804+ }elseif ($ amount != 0 && $ minimum == 1 ){
805+ echo '<input type="text" name="pf-amount" value=" ' .$ amount .'" id="pf-amount" required/> ' ;
806+ }else {
807+ echo '<input type="text" name="pf-amount" value=" ' .$ amount .'" id="pf-amount" readonly required/> ' ;
808+ }
809+ }
810+ }else {
811+ if ($ usevariableamount == "" ) {
812+ echo "Form Error, set variable amount string " ;
813+ }else {
814+ if (count ($ paymentoptions ) > 0 ) {
815+ echo '<div class="select">
816+ <input type="hidden" id="pf-vname" />
817+ <select class="form-control" id="pf-vamount" name="pf-amount"> ' ;
818+ $ max = $ quantity +1 ;
819+ foreach ($ paymentoptions as $ key => $ paymentoption ) {
820+ list ($ a ,$ b ) = explode (': ' , $ paymentoption );
821+ echo '<option value=" ' .$ b .'" data-name=" ' .$ a .'"> ' .$ a .'( ' .number_format ($ b ).')</option> ' ;
822+
823+ }
824+ echo '</select> <i></i> </div> ' ;
825+
802826 }
803- }
804- if ($ txncharge != 'merchant ' && $ recur != 'plan ' ) {
805- echo '<small>Transaction Charge: <b class="pf-txncharge">NGN1000</b>, Total:<b class="pf-txntotal">NGN1000</b></small> ' ;
806- }
827+ }
828+ }
829+ if ($ txncharge != 'merchant ' && $ recur != 'plan ' ) {
830+ echo '<small>Transaction Charge: <b class="pf-txncharge"></b>, Total:<b class="pf-txntotal"></b></small> ' ;
831+ }
807832
808833 echo '</div>
809834 </div> ' ;
810- if ($ recur == 'no ' && $ usequantity == 'yes ' ) {
835+ if ($ recur == 'no ' && $ usequantity == 'yes ' && $ amount != 0 ) {
811836 echo '<div class="span12 unit">
812837 <label class="label">Quantity</label>
813838 <div class="select">
@@ -1115,6 +1140,8 @@ function kkd_pff_paystack_submit_action() {
11151140
11161141 $ txncharge = get_post_meta ($ _POST ["pf-id " ],'_txncharge ' ,true );
11171142 $ minimum = get_post_meta ($ _POST ["pf-id " ],'_minimum ' ,true );
1143+ $ variableamount = get_post_meta ($ _POST ["pf-id " ],'_variableamount ' ,true );
1144+ $ usevariableamount = get_post_meta ($ _POST ["pf-id " ],'_usevariableamount ' ,true );
11181145 $ amount = (int )str_replace (' ' , '' , $ _POST ["pf-amount " ]);//User input
11191146 $ originalamount = $ amount ;
11201147 $ quantity = 1 ;
0 commit comments