Skip to content

Commit 902637a

Browse files
committed
v2.1.9 - Fix JS bug associated with variable amount, checkbox to hide form title
1 parent 3d7499e commit 902637a

File tree

5 files changed

+46
-20
lines changed

5 files changed

+46
-20
lines changed

README.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Contributors: kendysond
33
Donate link: https://paystack.com/demo
44
Tags: paystack, recurrent payments, nigeria, mastercard, visa, target,Naira,payments,verve,donation,church,NGO,form,contact form 7, form,
55
Requires at least: 3.1
6-
Tested up to: 4.7
7-
Stable tag: 2.1.8
6+
Tested up to: 4.8.1
7+
Stable tag: 2.1.9
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -84,6 +84,9 @@ You can also follow us on Twitter! **[@paystack](http://twitter.com/paystack)**
8484

8585

8686
== Changelog ==
87+
= 2.1.9 =
88+
* Fix JS bug associated with variable amount
89+
* Added checkbox to hide form title
8790
= 2.1.8 =
8891
* Fix datepicker shortcode addition bug (Courtesy of [Dane Medussa](https://github.com/blackmunk))
8992
= 2.1.7 =

admin/class-paystack-forms-admin.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ function kkd_pff_paystack_editor_add_form_data() {
290290
$minimum = get_post_meta($post->ID, '_minimum', true);
291291
$usevariableamount = get_post_meta($post->ID, '_usevariableamount', true);
292292
$variableamount = get_post_meta($post->ID, '_variableamount', true);
293+
$hidetitle = get_post_meta($post->ID, '_hidetitle', true);
293294

294295
if ($amount == "") {$amount = 0;}
295296
if ($filelimit == "") {$filelimit = 2;}
@@ -299,11 +300,18 @@ function kkd_pff_paystack_editor_add_form_data() {
299300
if ($txncharge == "") {$txncharge = 'merchant';}
300301
if ($minimum == "") {$minimum = 0;}
301302
if ($uservariableamount == "") {$uservariableamount = 0;}
303+
if ($hidetitle == "") {$hidetitle = 0;}
302304
if ($variableamount == "") {$variableamount = '';}
303305
// Echo out the field
304306

305307

306-
echo '<p>Currency:</p>';
308+
if ($hidetitle == 1) {
309+
echo '<label><input name="_hidetitle" type="checkbox" value="1" checked> Hide the form title </label>';
310+
}else{
311+
echo '<label><input name="_hidetitle" type="checkbox" value="1" > Hide the form title </label>';
312+
}
313+
echo "<br>";
314+
echo '<p>Currency:</p>';
307315
echo '<input type="text" name="_currency" value="' . $currency . '" class="widefat" />
308316
<small>We currently support only payments in Naira(NGN).</small>';
309317
echo '<p>Amount to be paid(Set 0 for customer input):</p>';
@@ -515,6 +523,7 @@ function kkd_pff_paystack_save_data($post_id, $post) {
515523
}
516524

517525
$form_meta['_amount'] = $_POST['_amount'];
526+
$form_meta['_hidetitle'] = $_POST['_hidetitle'];
518527
$form_meta['_minimum'] = $_POST['_minimum'];
519528

520529
$form_meta['_variableamount'] = $_POST['_variableamount'];

paystack-forms.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Payment forms for Paystack
44
Plugin URI: https://github.com/Kendysond/Wordpress-paystack-forms
55
Description: Payment forms for Paystack allows you create forms that will be used to bill clients for goods and services via Paystack.
6-
Version: 2.1.8
6+
Version: 2.1.9
77
Author: Douglas Kendyson
88
Author URI: http://kendyson.com
99
License: GPL-2.0+
@@ -15,7 +15,7 @@
1515
}
1616
define( 'KKD_PFF_PAYSTACK_PLUGIN_PATH', plugins_url( __FILE__ ) );
1717
define( 'KKD_PFF_PAYSTACK_MAIN_FILE', __FILE__ );
18-
define( 'KKD_PFF_PAYSTACK_VERSION', '2.1.8' );
18+
define( 'KKD_PFF_PAYSTACK_VERSION', '2.1.9' );
1919
define( 'KKD_PFF_PAYSTACK_TABLE', 'paystack_forms_payments' );
2020

2121

public/class-paystack-forms-public.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ function kkd_pff_paystack_form_shortcode($atts) {
732732
$minimum = get_post_meta($id,'_minimum',true);
733733
$variableamount = get_post_meta($id,'_variableamount',true);
734734
$usevariableamount = get_post_meta($id,'_usevariableamount',true);
735+
$hidetitle = get_post_meta($id,'_hidetitle',true);
735736
if ($minimum == "") {$minimum = 0;}
736737
if ($usevariableamount == "") {$usevariableamount = 0;}
737738

@@ -758,8 +759,10 @@ function kkd_pff_paystack_form_shortcode($atts) {
758759

759760
}
760761
if ((($user_id != 0) && ($loggedin == 'yes')) || $loggedin == 'no') {
761-
762+
if ($hidetitle != 1) {
762763
echo "<h1 id='pf-form".$id."'>".$obj->post_title."</h1>";
764+
765+
}
763766
echo '<form version="'.KKD_PFF_PAYSTACK_VERSION.'" enctype="multipart/form-data" action="' . admin_url('admin-ajax.php') . '" url="' . admin_url() . '" method="post" class="paystack-form j-forms" novalidate>
764767
<div class="j-row">';
765768
echo '<input type="hidden" name="action" value="kkd_pff_paystack_submit_action">';
@@ -826,6 +829,7 @@ function kkd_pff_paystack_form_shortcode($atts) {
826829
if (count($paymentoptions) > 0) {
827830
echo '<div class="select">
828831
<input type="hidden" id="pf-vname" name="pf-vname" />
832+
<input type="hidden" id="pf-amount" />
829833
<select class="form-control" id="pf-vamount" name="pf-amount">';
830834
$max = $quantity+1;
831835
foreach ($paymentoptions as $key => $paymentoption) {

public/js/paystack-forms-public.js

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
var international_card = false;
1616
if( $('#pf-vamount').length ){
1717
var amountField = $('#pf-vamount');
18+
calculateTotal();
1819

1920
}else{
2021
var amountField = $('#pf-amount');
@@ -58,6 +59,23 @@
5859
$(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") );
5960
})
6061
}
62+
function calculateTotal(){
63+
if( $('#pf-vamount').length ){
64+
var amountField = $('#pf-vamount');
65+
66+
}else{
67+
var amountField = $('#pf-qamount');
68+
69+
}
70+
var unit = amountField.val();
71+
var quant = $('#pf-quantity').val();
72+
73+
if (quant == '' || quant == null) {
74+
quant = 1;
75+
}
76+
var newvalue = unit * quant;
77+
$('#pf-amount').val(newvalue);
78+
}
6179
function calculateFees(transaction_amount) {
6280
setTimeout(function() {
6381
transaction_amount = transaction_amount || parseInt(amountField.val());
@@ -99,17 +117,9 @@
99117
}
100118
});
101119
$('#pf-quantity,#pf-vamount').on('change', function() {
102-
if( $('#pf-vamount').length ){
103-
var amountField = $('#pf-vamount');
104-
105-
}else{
106-
var amountField = $('#pf-qamount');
107-
108-
}
109-
var unit = amountField.val();
110-
var quant = $('#pf-quantity').val();
111-
var newvalue = unit * quant;
112-
$('#pf-amount').val(newvalue);
120+
121+
calculateTotal();
122+
113123
calculateFees(newvalue);
114124
});
115125
function validateEmail(email) {
@@ -118,7 +128,8 @@
118128
}
119129
$('.paystack-form').on('submit', function(e) {
120130
var stop = false;
121-
131+
e.preventDefault();
132+
122133
$("#pf-agreementicon").removeClass('rerror');
123134

124135
$(this).find("input,select, textarea").each(function() {
@@ -128,7 +139,7 @@
128139
var amount = $(this).find("#pf-amount").val();
129140
if (Number(amount) > 0) {
130141
}else{
131-
$(this).find("#pf-amount").addClass('rerror');// css({ "border-color":"red" });
142+
$(this).find("#pf-amount,#pf-vamount").addClass('rerror');// css({ "border-color":"red" });
132143
$('html,body').animate({ scrollTop: $('.rerror').offset().top - 110 }, 500);
133144
return false;
134145
}
@@ -161,7 +172,6 @@
161172

162173
var self = $(this);
163174
var $form = $(this);
164-
e.preventDefault();
165175

166176
$.blockUI({ message: 'Please wait...' });
167177

0 commit comments

Comments
 (0)