|
230 | 230 | if ( ! in_array( 'tax', $read_only_fields ) && isset( $_POST['tax'] ) ) {
|
231 | 231 | $order->tax = sanitize_text_field( $_POST['tax'] );
|
232 | 232 | }
|
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 | + } |
235 | 240 | }
|
| 241 | + |
236 | 242 | if ( ! in_array( 'total', $read_only_fields ) && isset( $_POST['total'] ) ) {
|
237 | 243 | $order->total = sanitize_text_field( $_POST['total'] );
|
238 | 244 | }
|
|
611 | 617 | <?php } ?>
|
612 | 618 | </td>
|
613 | 619 | </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> |
618 | 628 | <?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 | + } |
622 | 636 | ?>
|
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 | + ?> |
627 | 642 | <tr>
|
628 | 643 | <th scope="row" valign="top"><label for="total"><?php esc_html_e( 'Total', 'paid-memberships-pro' ); ?>:</label></th>
|
629 | 644 | <td>
|
|
635 | 650 | <input id="total" name="total" type="text" size="10"
|
636 | 651 | value="<?php echo esc_attr( $order->total ); ?>"/>
|
637 | 652 | <?php } ?>
|
638 |
| - <p class="description"><?php esc_html_e( 'Should be subtotal + tax - couponamount.', 'paid-memberships-pro' ); ?></p> |
639 | 653 | </td>
|
640 | 654 | </tr>
|
641 | 655 |
|
|
0 commit comments