Skip to content

Commit d0b35d7

Browse files
kimcolemanideadude
authored andcommitted
Hiding couponamount field (not used); added filter 'pmpro_orders_show_coupon_amounts' to reenable this field on order edit and export to csv.
Conflicts: adminpages/orders.php
1 parent 12edb8e commit d0b35d7

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
lines changed

CHANGELOG.txt

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* BUG FIX/ENHANCEMENT: Now detecting when a Stripe webhook is set up for an older version of the Stripe API and showing a notice with a link to update.
1818
* BUG FIX/ENHANCEMENT: Adding MAXFAILEDPAYMENTS=1 to PayPal add subscription requests. This tells PayPal to cancel a subscription after the first failed payment. In our experience, the automatic retries rarely worked well. This change fixes issues with subscriptions going out of sync or users retaining access to your site when their payment has failed. Members still receive the payment failed email, which prompts users to return to the site to renew.
1919
* BUG FIX/ENHANCEMENT: Fixing some issues where we are adding extra break tags into the password reset email. There are still some issues like this when using certain plugins. We are working on a general fix.
20+
* BUG FIX/ENHANCEMENT: Removed the "coupon amount" field from the edit order page. These were hold outs from the 2007! ecommerce plugin PMPro was forked from. You can set the pmpro_orders_show_coupon_amounts filter to __return_true to show these fields again if you were using them for tracking things in your custom code.
2021
* BUG FIX: Fixed MMPU compatibility when using discount codes.
2122
* BUG FIX: No longer filtering the wp login url when on wp-login.php. This fixes issues with iThemes Security 2FA.
2223
* BUG FIX: Fixed issues where the Stripe webhook was not being updated sometimes when clicking the button to update.

adminpages/orders-csv.php

+8
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,14 @@
330330
array( "discount_code", "code" )
331331
);
332332

333+
// Hiding couponamount by default.
334+
$coupons = apply_filters( 'pmpro_orders_show_coupon_amounts', false );
335+
if ( empty( $coupons ) ) {
336+
$csv_file_header_array = array_diff( $csv_file_header_array, array( 'couponamount' ) );
337+
$couponamount_array_key = array_keys( $default_columns, array( 'order', 'couponamount' ) );
338+
unset( $default_columns[ $couponamount_array_key[0] ] );
339+
}
340+
333341
$default_columns = apply_filters( "pmpro_order_list_csv_default_columns", $default_columns );
334342

335343
$csv_file_header_array = apply_filters( "pmpro_order_list_csv_export_header_array", $csv_file_header_array );

adminpages/orders.php

+28-14
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,15 @@
230230
if ( ! in_array( 'tax', $read_only_fields ) && isset( $_POST['tax'] ) ) {
231231
$order->tax = sanitize_text_field( $_POST['tax'] );
232232
}
233-
if ( ! in_array( 'couponamount', $read_only_fields ) && isset( $_POST['couponamount'] ) ) {
234-
$order->couponamount = sanitize_text_field( $_POST['couponamount'] );
233+
234+
// Hiding couponamount by default.
235+
$coupons = apply_filters( 'pmpro_orders_show_coupon_amounts', false );
236+
if ( ! empty( $coupons ) ) {
237+
if ( ! in_array( 'couponamount', $read_only_fields ) && isset( $_POST['couponamount'] ) ) {
238+
$order->couponamount = sanitize_text_field( $_POST['couponamount'] );
239+
}
235240
}
241+
236242
if ( ! in_array( 'total', $read_only_fields ) && isset( $_POST['total'] ) ) {
237243
$order->total = sanitize_text_field( $_POST['total'] );
238244
}
@@ -611,19 +617,28 @@
611617
<?php } ?>
612618
</td>
613619
</tr>
614-
<tr>
615-
<th scope="row" valign="top"><label for="couponamount"><?php esc_html_e( 'Coupon Amount', 'paid-memberships-pro' ); ?>:</label>
616-
</th>
617-
<td>
620+
<?php
621+
// Hiding couponamount by default.
622+
$coupons = apply_filters( 'pmpro_orders_show_coupon_amounts', false );
623+
if ( ! empty( $coupons ) ) { ?>
624+
<tr>
625+
<th scope="row" valign="top"><label for="couponamount"><?php esc_html_e( 'Coupon Amount', 'paid-memberships-pro' ); ?>:</label>
626+
</th>
627+
<td>
618628
<?php
619-
if ( in_array( 'couponamount', $read_only_fields ) && $order_id > 0 ) {
620-
echo esc_html( $order->couponamount );
621-
} else {
629+
if ( in_array( 'couponamount', $read_only_fields ) && $order_id > 0 ) {
630+
echo $order->couponamount;
631+
} else {
632+
?>
633+
<input id="couponamount" name="couponamount" type="text" size="10" value="<?php echo esc_attr( $order->couponamount ); ?>"/>
634+
<?php
635+
}
622636
?>
623-
<input id="couponamount" name="couponamount" type="text" size="10" value="<?php echo esc_attr( $order->couponamount ); ?>"/>
624-
<?php } ?>
625-
</td>
626-
</tr>
637+
</td>
638+
</tr>
639+
<?php
640+
}
641+
?>
627642
<tr>
628643
<th scope="row" valign="top"><label for="total"><?php esc_html_e( 'Total', 'paid-memberships-pro' ); ?>:</label></th>
629644
<td>
@@ -635,7 +650,6 @@
635650
<input id="total" name="total" type="text" size="10"
636651
value="<?php echo esc_attr( $order->total ); ?>"/>
637652
<?php } ?>
638-
<p class="description"><?php esc_html_e( 'Should be subtotal + tax - couponamount.', 'paid-memberships-pro' ); ?></p>
639653
</td>
640654
</tr>
641655

readme.txt

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ Not sure? You can find out by doing a bit a research.
171171
* BUG FIX/ENHANCEMENT: Now detecting when a Stripe webhook is set up for an older version of the Stripe API and showing a notice with a link to update.
172172
* BUG FIX/ENHANCEMENT: Adding MAXFAILEDPAYMENTS=1 to PayPal add subscription requests. This tells PayPal to cancel a subscription after the first failed payment. In our experience, the automatic retries rarely worked well. This change fixes issues with subscriptions going out of sync or users retaining access to your site when their payment has failed. Members still receive the payment failed email, which prompts users to return to the site to renew.
173173
* BUG FIX/ENHANCEMENT: Fixing some issues where we are adding extra break tags into the password reset email. There are still some issues like this when using certain plugins. We are working on a general fix.
174+
* BUG FIX/ENHANCEMENT: Removed the "coupon amount" field from the edit order page. These were hold outs from the 2007! ecommerce plugin PMPro was forked from. You can set the pmpro_orders_show_coupon_amounts filter to __return_true to show these fields again if you were using them for tracking things in your custom code.
174175
* BUG FIX: Fixed MMPU compatibility when using discount codes.
175176
* BUG FIX: No longer filtering the wp login url when on wp-login.php. This fixes issues with iThemes Security 2FA.
176177
* BUG FIX: Fixed issues where the Stripe webhook was not being updated sometimes when clicking the button to update.

0 commit comments

Comments
 (0)