@@ -9,48 +9,48 @@ discard block |
||
| 9 | 9 | * @var GetPaid_Form_Item $item |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) || exit; |
|
| 12 | +defined('ABSPATH') || exit; |
|
| 13 | 13 | |
| 14 | -do_action( 'getpaid_before_payment_form_cart_item', $form, $item ); |
|
| 14 | +do_action('getpaid_before_payment_form_cart_item', $form, $item); |
|
| 15 | 15 | |
| 16 | 16 | $currency = $form->get_currency(); |
| 17 | 17 | |
| 18 | 18 | ?> |
| 19 | -<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?> border-bottom py-2 px-3'> |
|
| 19 | +<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?> border-bottom py-2 px-3'> |
|
| 20 | 20 | |
| 21 | 21 | <div class="form-row needs-validation"> |
| 22 | 22 | |
| 23 | - <?php foreach ( array_keys( $columns ) as $key ) : ?> |
|
| 23 | + <?php foreach (array_keys($columns) as $key) : ?> |
|
| 24 | 24 | |
| 25 | - <div class="<?php echo 'name' == $key ? 'col-8 col-sm-6' : 'col' ?> <?php echo ( in_array( $key, array( 'subtotal', 'quantity', 'tax_rate' ) ) ) ? 'd-none d-sm-block' : '' ?> position-relative getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?> getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?>-<?php echo $item->get_id(); ?>"> |
|
| 25 | + <div class="<?php echo 'name' == $key ? 'col-8 col-sm-6' : 'col' ?> <?php echo (in_array($key, array('subtotal', 'quantity', 'tax_rate'))) ? 'd-none d-sm-block' : '' ?> position-relative getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?> getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?>-<?php echo $item->get_id(); ?>"> |
|
| 26 | 26 | |
| 27 | 27 | <?php |
| 28 | 28 | |
| 29 | 29 | // Fires before printing a line item column. |
| 30 | - do_action( "getpaid_form_cart_item_before_$key", $item, $form ); |
|
| 30 | + do_action("getpaid_form_cart_item_before_$key", $item, $form); |
|
| 31 | 31 | |
| 32 | 32 | // Item name. |
| 33 | - if ( 'name' == $key ) { |
|
| 33 | + if ('name' == $key) { |
|
| 34 | 34 | |
| 35 | 35 | ob_start(); |
| 36 | 36 | // And an optional description. |
| 37 | 37 | $description = $item->get_description(); |
| 38 | 38 | |
| 39 | - if ( ! empty( $description ) ) { |
|
| 40 | - $description = wp_kses_post( $description ); |
|
| 39 | + if (!empty($description)) { |
|
| 40 | + $description = wp_kses_post($description); |
|
| 41 | 41 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // Price help text. |
| 45 | - $description = getpaid_item_recurring_price_help_text( $item, $currency ); |
|
| 46 | - if ( $description ) { |
|
| 45 | + $description = getpaid_item_recurring_price_help_text($item, $currency); |
|
| 46 | + if ($description) { |
|
| 47 | 47 | echo "<small class='getpaid-form-item-price-desc form-text text-muted pr-2 m-0'>$description</small>"; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if ( wpinv_current_user_can_manage_invoicing() ) { |
|
| 50 | + if (wpinv_current_user_can_manage_invoicing()) { |
|
| 51 | 51 | |
| 52 | 52 | edit_post_link( |
| 53 | - __( 'Edit this item.', 'invoicing' ), |
|
| 53 | + __('Edit this item.', 'invoicing'), |
|
| 54 | 54 | '<small class="form-text text-muted">', |
| 55 | 55 | '</small>', |
| 56 | 56 | $item->get_id(), |
@@ -62,18 +62,18 @@ discard block |
||
| 62 | 62 | $description = ob_get_clean(); |
| 63 | 63 | |
| 64 | 64 | // Display the name. |
| 65 | - $tootip = empty( $description ) ? '' : " " . '<i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>'; |
|
| 66 | - echo '<div class="mb-1">' . esc_html( $item->get_name() ) . $tootip . '</div>'; |
|
| 65 | + $tootip = empty($description) ? '' : " " . '<i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>'; |
|
| 66 | + echo '<div class="mb-1">' . esc_html($item->get_name()) . $tootip . '</div>'; |
|
| 67 | 67 | |
| 68 | - if ( ! empty( $description ) ) { |
|
| 69 | - printf( '<span class="d-none d-sm-block getpaid-item-desc">%s</span>', $description ); |
|
| 68 | + if (!empty($description)) { |
|
| 69 | + printf('<span class="d-none d-sm-block getpaid-item-desc">%s</span>', $description); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if ( $item->allows_quantities() ) { |
|
| 72 | + if ($item->allows_quantities()) { |
|
| 73 | 73 | printf( |
| 74 | 74 | '<small class="d-sm-none text-muted form-text">%s</small>', |
| 75 | 75 | sprintf( |
| 76 | - __( 'Qty %s', 'invoicing' ), |
|
| 76 | + __('Qty %s', 'invoicing'), |
|
| 77 | 77 | sprintf( |
| 78 | 78 | '<input |
| 79 | 79 | type="text" |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | printf( |
| 90 | 90 | '<small class="d-sm-none text-muted form-text">%s</small>', |
| 91 | 91 | sprintf( |
| 92 | - __( 'Qty %s', 'invoicing' ), |
|
| 92 | + __('Qty %s', 'invoicing'), |
|
| 93 | 93 | (float) $item->get_quantity() |
| 94 | 94 | ) |
| 95 | 95 | ); |
@@ -98,56 +98,56 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Item price. |
| 101 | - if ( 'price' == $key ) { |
|
| 101 | + if ('price' == $key) { |
|
| 102 | 102 | |
| 103 | 103 | // Set the currency position. |
| 104 | 104 | $position = wpinv_currency_position(); |
| 105 | 105 | |
| 106 | - if ( $position == 'left_space' ) { |
|
| 106 | + if ($position == 'left_space') { |
|
| 107 | 107 | $position = 'left'; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if ( $position == 'right_space' ) { |
|
| 110 | + if ($position == 'right_space') { |
|
| 111 | 111 | $position = 'right'; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if ( $item->user_can_set_their_price() ) { |
|
| 115 | - $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() ); |
|
| 114 | + if ($item->user_can_set_their_price()) { |
|
| 115 | + $price = max((float) $item->get_price(), (float) $item->get_minimum_price()); |
|
| 116 | 116 | $minimum = (float) $item->get_minimum_price(); |
| 117 | 117 | $validate_minimum = ''; |
| 118 | 118 | $class = ''; |
| 119 | 119 | $data_minimum = ''; |
| 120 | 120 | |
| 121 | - if ( $minimum > 0 ) { |
|
| 121 | + if ($minimum > 0) { |
|
| 122 | 122 | $validate_minimum = sprintf( |
| 123 | - esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ), |
|
| 124 | - strip_tags( wpinv_price( $minimum, $currency ) ) |
|
| 123 | + esc_attr__('The minimum allowed amount is %s', 'invoicing'), |
|
| 124 | + strip_tags(wpinv_price($minimum, $currency)) |
|
| 125 | 125 | ); |
| 126 | 126 | |
| 127 | 127 | $class = 'getpaid-validate-minimum-amount'; |
| 128 | 128 | |
| 129 | - $data_minimum = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'"; |
|
| 129 | + $data_minimum = "data-minimum-amount='" . esc_attr(getpaid_unstandardize_amount($minimum)) . "'"; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | ?> |
| 133 | 133 | <div class="input-group input-group-sm"> |
| 134 | - <?php if( 'left' == $position ) : ?> |
|
| 134 | + <?php if ('left' == $position) : ?> |
|
| 135 | 135 | <div class="input-group-prepend"> |
| 136 | - <span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span> |
|
| 136 | + <span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span> |
|
| 137 | 137 | </div> |
| 138 | 138 | <?php endif; ?> |
| 139 | 139 | |
| 140 | - <input type="text" <?php echo $data_minimum; ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo esc_attr( getpaid_unstandardize_amount( $price ) ); ?>" placeholder="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price() ) ); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo $class; ?>" style="width: 64px; line-height: 1; min-height: 35px;"> |
|
| 140 | + <input type="text" <?php echo $data_minimum; ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo esc_attr(getpaid_unstandardize_amount($price)); ?>" placeholder="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price())); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo $class; ?>" style="width: 64px; line-height: 1; min-height: 35px;"> |
|
| 141 | 141 | |
| 142 | - <?php if ( ! empty( $validate_minimum ) ) : ?> |
|
| 142 | + <?php if (!empty($validate_minimum)) : ?> |
|
| 143 | 143 | <div class="invalid-tooltip"> |
| 144 | 144 | <?php echo $validate_minimum; ?> |
| 145 | 145 | </div> |
| 146 | 146 | <?php endif; ?> |
| 147 | 147 | |
| 148 | - <?php if( 'left' != $position ) : ?> |
|
| 148 | + <?php if ('left' != $position) : ?> |
|
| 149 | 149 | <div class="input-group-append"> |
| 150 | - <span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span> |
|
| 150 | + <span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span> |
|
| 151 | 151 | </div> |
| 152 | 152 | <?php endif; ?> |
| 153 | 153 | </div> |
@@ -155,23 +155,23 @@ discard block |
||
| 155 | 155 | <?php |
| 156 | 156 | |
| 157 | 157 | } else { |
| 158 | - echo wpinv_price( $item->get_price(), $currency ); |
|
| 158 | + echo wpinv_price($item->get_price(), $currency); |
|
| 159 | 159 | |
| 160 | 160 | ?> |
| 161 | - <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'> |
|
| 161 | + <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr($item->get_price()); ?>'> |
|
| 162 | 162 | <?php |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | printf( |
| 166 | 166 | '<small class="d-sm-none text-muted form-text getpaid-mobile-item-subtotal">%s</small>', |
| 167 | - sprintf( __( 'Subtotal: %s', 'invoicing' ), wpinv_price( $item->get_sub_total(), $currency ) ) |
|
| 167 | + sprintf(__('Subtotal: %s', 'invoicing'), wpinv_price($item->get_sub_total(), $currency)) |
|
| 168 | 168 | ); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // Item quantity. |
| 172 | - if ( 'quantity' == $key ) { |
|
| 172 | + if ('quantity' == $key) { |
|
| 173 | 173 | |
| 174 | - if ( $item->allows_quantities() ) { |
|
| 174 | + if ($item->allows_quantities()) { |
|
| 175 | 175 | ?> |
| 176 | 176 | <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type='text' style='width: 64px; line-height: 1; min-height: 35px;' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(); ?>' min='1' required> |
| 177 | 177 | <?php |
@@ -186,11 +186,11 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | // Item sub total. |
| 189 | - if ( 'subtotal' == $key ) { |
|
| 190 | - echo wpinv_price( $item->get_sub_total(), $currency ); |
|
| 189 | + if ('subtotal' == $key) { |
|
| 190 | + echo wpinv_price($item->get_sub_total(), $currency); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - do_action( "getpaid_payment_form_cart_item_$key", $item, $form ); |
|
| 193 | + do_action("getpaid_payment_form_cart_item_$key", $item, $form); |
|
| 194 | 194 | ?> |
| 195 | 195 | |
| 196 | 196 | </div> |
@@ -201,4 +201,4 @@ discard block |
||
| 201 | 201 | |
| 202 | 202 | </div> |
| 203 | 203 | <?php |
| 204 | -do_action( 'getpaid_payment_form_cart_item', $form, $item ); |
|
| 204 | +do_action('getpaid_payment_form_cart_item', $form, $item); |
|
@@ -7,36 +7,36 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // Cart table columns. |
| 13 | 13 | $columns = array( |
| 14 | - 'name' => __( 'Item', 'invoicing' ), |
|
| 15 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 16 | - 'quantity' => __( 'Qty', 'invoicing' ), |
|
| 17 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
| 14 | + 'name' => __('Item', 'invoicing'), |
|
| 15 | + 'price' => __('Price', 'invoicing'), |
|
| 16 | + 'quantity' => __('Qty', 'invoicing'), |
|
| 17 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
| 18 | 18 | ); |
| 19 | 19 | |
| 20 | -if ( ! empty( $form->invoice ) ) { |
|
| 21 | - $columns = getpaid_invoice_item_columns( $form->invoice ); |
|
| 20 | +if (!empty($form->invoice)) { |
|
| 21 | + $columns = getpaid_invoice_item_columns($form->invoice); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | -if ( isset( $columns['tax_rate'] ) ) { |
|
| 25 | - unset( $columns['tax_rate'] ); |
|
| 24 | +if (isset($columns['tax_rate'])) { |
|
| 25 | + unset($columns['tax_rate']); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | -$columns = apply_filters( 'getpaid_payment_form_cart_table_columns', $columns, $form ); |
|
| 28 | +$columns = apply_filters('getpaid_payment_form_cart_table_columns', $columns, $form); |
|
| 29 | 29 | |
| 30 | -do_action( 'getpaid_before_payment_form_cart', $form ); |
|
| 30 | +do_action('getpaid_before_payment_form_cart', $form); |
|
| 31 | 31 | |
| 32 | 32 | ?> |
| 33 | 33 | <div class="getpaid-payment-form-items-cart border form-group"> |
| 34 | 34 | |
| 35 | 35 | <div class="getpaid-payment-form-items-cart-header font-weight-bold bg-light border-bottom py-2 px-3"> |
| 36 | 36 | <div class="form-row"> |
| 37 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
| 38 | - <div class="<?php echo 'name' == $key ? 'col-8 col-sm-6' : 'col' ?> <?php echo ( in_array( $key, array( 'subtotal', 'quantity', 'tax_rate' ) ) ) ? 'd-none d-sm-block' : '' ?> getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?>"> |
|
| 39 | - <span><?php echo esc_html( $label ); ?></span> |
|
| 37 | + <?php foreach ($columns as $key => $label) : ?> |
|
| 38 | + <div class="<?php echo 'name' == $key ? 'col-8 col-sm-6' : 'col' ?> <?php echo (in_array($key, array('subtotal', 'quantity', 'tax_rate'))) ? 'd-none d-sm-block' : '' ?> getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?>"> |
|
| 39 | + <span><?php echo esc_html($label); ?></span> |
|
| 40 | 40 | </div> |
| 41 | 41 | <?php endforeach; ?> |
| 42 | 42 | </div> |
@@ -45,16 +45,16 @@ discard block |
||
| 45 | 45 | <?php |
| 46 | 46 | |
| 47 | 47 | // Display the item totals. |
| 48 | - foreach ( $form->get_items() as $item ) { |
|
| 49 | - wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'columns' ) ); |
|
| 48 | + foreach ($form->get_items() as $item) { |
|
| 49 | + wpinv_get_template('payment-forms/cart-item.php', compact('form', 'item', 'columns')); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Display the cart totals. |
| 53 | - wpinv_get_template( 'payment-forms/cart-totals.php', compact( 'form' ) ); |
|
| 53 | + wpinv_get_template('payment-forms/cart-totals.php', compact('form')); |
|
| 54 | 54 | |
| 55 | 55 | ?> |
| 56 | 56 | </div> |
| 57 | 57 | |
| 58 | 58 | <?php |
| 59 | 59 | |
| 60 | -do_action( 'getpaid_after_payment_form_cart', $form ); |
|
| 60 | +do_action('getpaid_after_payment_form_cart', $form); |
|
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Payment form submission refresh prices class |
@@ -23,24 +23,24 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @param GetPaid_Payment_Form_Submission $submission |
| 25 | 25 | */ |
| 26 | - public function __construct( $submission ) { |
|
| 26 | + public function __construct($submission) { |
|
| 27 | 27 | |
| 28 | 28 | $this->response = array( |
| 29 | 29 | 'submission_id' => $submission->id, |
| 30 | 30 | 'has_recurring' => $submission->has_recurring, |
| 31 | 31 | 'has_subscription_group' => $submission->has_subscription_group(), |
| 32 | 32 | 'has_multiple_subscription_groups' => $submission->has_multiple_subscription_groups(), |
| 33 | - 'is_free' => ! $submission->should_collect_payment_details(), |
|
| 33 | + 'is_free' => !$submission->should_collect_payment_details(), |
|
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | - $this->add_totals( $submission ); |
|
| 37 | - $this->add_texts( $submission ); |
|
| 38 | - $this->add_items( $submission ); |
|
| 39 | - $this->add_fees( $submission ); |
|
| 40 | - $this->add_discounts( $submission ); |
|
| 41 | - $this->add_taxes( $submission ); |
|
| 42 | - $this->add_gateways( $submission ); |
|
| 43 | - $this->add_data( $submission ); |
|
| 36 | + $this->add_totals($submission); |
|
| 37 | + $this->add_texts($submission); |
|
| 38 | + $this->add_items($submission); |
|
| 39 | + $this->add_fees($submission); |
|
| 40 | + $this->add_discounts($submission); |
|
| 41 | + $this->add_taxes($submission); |
|
| 42 | + $this->add_gateways($submission); |
|
| 43 | + $this->add_data($submission); |
|
| 44 | 44 | |
| 45 | 45 | } |
| 46 | 46 | |
@@ -49,30 +49,30 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @param GetPaid_Payment_Form_Submission $submission |
| 51 | 51 | */ |
| 52 | - public function add_totals( $submission ) { |
|
| 52 | + public function add_totals($submission) { |
|
| 53 | 53 | |
| 54 | 54 | $this->response = array_merge( |
| 55 | 55 | $this->response, |
| 56 | 56 | array( |
| 57 | 57 | |
| 58 | 58 | 'totals' => array( |
| 59 | - 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
| 60 | - 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
| 61 | - 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
| 62 | - 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
| 63 | - 'total' => $submission->format_amount( $submission->get_total() ), |
|
| 64 | - 'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ), |
|
| 59 | + 'subtotal' => $submission->format_amount($submission->get_subtotal()), |
|
| 60 | + 'discount' => $submission->format_amount($submission->get_discount()), |
|
| 61 | + 'fees' => $submission->format_amount($submission->get_fee()), |
|
| 62 | + 'tax' => $submission->format_amount($submission->get_tax()), |
|
| 63 | + 'total' => $submission->format_amount($submission->get_total()), |
|
| 64 | + 'raw_total' => html_entity_decode(sanitize_text_field($submission->format_amount($submission->get_total())), ENT_QUOTES), |
|
| 65 | 65 | ), |
| 66 | 66 | |
| 67 | 67 | 'recurring' => array( |
| 68 | - 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
| 69 | - 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
| 70 | - 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
| 71 | - 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
| 72 | - 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
| 68 | + 'subtotal' => $submission->format_amount($submission->get_recurring_subtotal()), |
|
| 69 | + 'discount' => $submission->format_amount($submission->get_recurring_discount()), |
|
| 70 | + 'fees' => $submission->format_amount($submission->get_recurring_fee()), |
|
| 71 | + 'tax' => $submission->format_amount($submission->get_recurring_tax()), |
|
| 72 | + 'total' => $submission->format_amount($submission->get_recurring_total()), |
|
| 73 | 73 | ), |
| 74 | 74 | |
| 75 | - 'initial_amt' => wpinv_round_amount( $submission->get_total(), null, true ), |
|
| 75 | + 'initial_amt' => wpinv_round_amount($submission->get_total(), null, true), |
|
| 76 | 76 | 'currency' => $submission->get_currency(), |
| 77 | 77 | |
| 78 | 78 | ) |
@@ -85,53 +85,53 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @param GetPaid_Payment_Form_Submission $submission |
| 87 | 87 | */ |
| 88 | - public function add_texts( $submission ) { |
|
| 88 | + public function add_texts($submission) { |
|
| 89 | 89 | |
| 90 | - $payable = $submission->format_amount( $submission->get_total() ); |
|
| 91 | - $groups = getpaid_get_subscription_groups( $submission ); |
|
| 90 | + $payable = $submission->format_amount($submission->get_total()); |
|
| 91 | + $groups = getpaid_get_subscription_groups($submission); |
|
| 92 | 92 | |
| 93 | - if ( $submission->has_recurring && 2 > count( $groups ) ) { |
|
| 93 | + if ($submission->has_recurring && 2 > count($groups)) { |
|
| 94 | 94 | |
| 95 | - $recurring = new WPInv_Item( $submission->has_recurring ); |
|
| 96 | - $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
| 97 | - $main_item = reset( $groups ); |
|
| 95 | + $recurring = new WPInv_Item($submission->has_recurring); |
|
| 96 | + $period = getpaid_get_subscription_period_label($recurring->get_recurring_period(true), $recurring->get_recurring_interval(), ''); |
|
| 97 | + $main_item = reset($groups); |
|
| 98 | 98 | |
| 99 | - if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
| 99 | + if ($submission->get_total() == $submission->get_recurring_total()) { |
|
| 100 | 100 | $payable = "$payable / $period"; |
| 101 | - } else if ( $main_item ) { |
|
| 101 | + } else if ($main_item) { |
|
| 102 | 102 | |
| 103 | - $main_item = reset( $main_item ); |
|
| 103 | + $main_item = reset($main_item); |
|
| 104 | 104 | |
| 105 | 105 | // Calculate the next renewal date. |
| 106 | - $_period = $main_item->get_recurring_period( true ); |
|
| 106 | + $_period = $main_item->get_recurring_period(true); |
|
| 107 | 107 | $_interval = $main_item->get_recurring_interval(); |
| 108 | 108 | |
| 109 | 109 | // If the subscription item has a trial period... |
| 110 | - if ( $main_item->has_free_trial() ) { |
|
| 111 | - $_period = $main_item->get_trial_period( true ); |
|
| 110 | + if ($main_item->has_free_trial()) { |
|
| 111 | + $_period = $main_item->get_trial_period(true); |
|
| 112 | 112 | $_interval = $main_item->get_trial_interval(); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $payable = sprintf( |
| 116 | - __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
| 117 | - $submission->format_amount( $submission->get_total() ), |
|
| 118 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
| 116 | + __('%1$s (renews at %2$s / %3$s)', 'invoicing'), |
|
| 117 | + $submission->format_amount($submission->get_total()), |
|
| 118 | + $submission->format_amount($submission->get_recurring_total()), |
|
| 119 | 119 | $period |
| 120 | 120 | ); |
| 121 | 121 | |
| 122 | 122 | $payable .= sprintf( |
| 123 | 123 | '<small class="text-muted form-text">%s</small>', |
| 124 | 124 | sprintf( |
| 125 | - __( 'First renewal on %s', 'invoicing' ), |
|
| 126 | - getpaid_format_date( date( 'Y-m-d H:i:s', strtotime( "+$_interval $_period", current_time( 'timestamp' ) ) ) ) |
|
| 125 | + __('First renewal on %s', 'invoicing'), |
|
| 126 | + getpaid_format_date(date('Y-m-d H:i:s', strtotime("+$_interval $_period", current_time('timestamp')))) |
|
| 127 | 127 | ) |
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | 130 | } else { |
| 131 | 131 | $payable = sprintf( |
| 132 | - __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
| 133 | - $submission->format_amount( $submission->get_total() ), |
|
| 134 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
| 132 | + __('%1$s (renews at %2$s / %3$s)', 'invoicing'), |
|
| 133 | + $submission->format_amount($submission->get_total()), |
|
| 134 | + $submission->format_amount($submission->get_recurring_total()), |
|
| 135 | 135 | $period |
| 136 | 136 | ); |
| 137 | 137 | } |
@@ -142,20 +142,20 @@ discard block |
||
| 142 | 142 | '.getpaid-checkout-total-payable' => $payable, |
| 143 | 143 | ); |
| 144 | 144 | |
| 145 | - foreach ( $submission->get_items() as $item ) { |
|
| 145 | + foreach ($submission->get_items() as $item) { |
|
| 146 | 146 | $item_id = $item->get_id(); |
| 147 | - $initial_price = $submission->format_amount( $item->get_sub_total() - $item->item_discount ); |
|
| 148 | - $recurring_price = $submission->format_amount( $item->get_recurring_sub_total() - $item->recurring_item_discount ); |
|
| 149 | - $texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text( $item, $submission->get_currency(), $initial_price, $recurring_price ); |
|
| 150 | - $texts[".item-$item_id .getpaid-mobile-item-subtotal"] = sprintf( __( 'Subtotal: %s', 'invoicing' ), $submission->format_amount( $item->get_sub_total() ) ); |
|
| 147 | + $initial_price = $submission->format_amount($item->get_sub_total() - $item->item_discount); |
|
| 148 | + $recurring_price = $submission->format_amount($item->get_recurring_sub_total() - $item->recurring_item_discount); |
|
| 149 | + $texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text($item, $submission->get_currency(), $initial_price, $recurring_price); |
|
| 150 | + $texts[".item-$item_id .getpaid-mobile-item-subtotal"] = sprintf(__('Subtotal: %s', 'invoicing'), $submission->format_amount($item->get_sub_total())); |
|
| 151 | 151 | |
| 152 | - if ( $item->get_quantity() == 1 ) { |
|
| 152 | + if ($item->get_quantity() == 1) { |
|
| 153 | 153 | $texts[".item-$item_id .getpaid-mobile-item-subtotal"] = ''; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
| 158 | + $this->response = array_merge($this->response, array('texts' => $texts)); |
|
| 159 | 159 | |
| 160 | 160 | } |
| 161 | 161 | |
@@ -164,19 +164,19 @@ discard block |
||
| 164 | 164 | * |
| 165 | 165 | * @param GetPaid_Payment_Form_Submission $submission |
| 166 | 166 | */ |
| 167 | - public function add_items( $submission ) { |
|
| 167 | + public function add_items($submission) { |
|
| 168 | 168 | |
| 169 | 169 | // Add items. |
| 170 | 170 | $items = array(); |
| 171 | 171 | |
| 172 | - foreach ( $submission->get_items() as $item ) { |
|
| 172 | + foreach ($submission->get_items() as $item) { |
|
| 173 | 173 | $item_id = $item->get_id(); |
| 174 | - $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
| 174 | + $items["$item_id"] = $submission->format_amount($item->get_sub_total()); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | $this->response = array_merge( |
| 178 | 178 | $this->response, |
| 179 | - array( 'items' => $items ) |
|
| 179 | + array('items' => $items) |
|
| 180 | 180 | ); |
| 181 | 181 | |
| 182 | 182 | } |
@@ -186,17 +186,17 @@ discard block |
||
| 186 | 186 | * |
| 187 | 187 | * @param GetPaid_Payment_Form_Submission $submission |
| 188 | 188 | */ |
| 189 | - public function add_fees( $submission ) { |
|
| 189 | + public function add_fees($submission) { |
|
| 190 | 190 | |
| 191 | 191 | $fees = array(); |
| 192 | 192 | |
| 193 | - foreach ( $submission->get_fees() as $name => $data ) { |
|
| 194 | - $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
| 193 | + foreach ($submission->get_fees() as $name => $data) { |
|
| 194 | + $fees[$name] = $submission->format_amount($data['initial_fee']); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | $this->response = array_merge( |
| 198 | 198 | $this->response, |
| 199 | - array( 'fees' => $fees ) |
|
| 199 | + array('fees' => $fees) |
|
| 200 | 200 | ); |
| 201 | 201 | |
| 202 | 202 | } |
@@ -206,17 +206,17 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @param GetPaid_Payment_Form_Submission $submission |
| 208 | 208 | */ |
| 209 | - public function add_discounts( $submission ) { |
|
| 209 | + public function add_discounts($submission) { |
|
| 210 | 210 | |
| 211 | 211 | $discounts = array(); |
| 212 | 212 | |
| 213 | - foreach ( $submission->get_discounts() as $name => $data ) { |
|
| 214 | - $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
| 213 | + foreach ($submission->get_discounts() as $name => $data) { |
|
| 214 | + $discounts[$name] = $submission->format_amount($data['initial_discount']); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | $this->response = array_merge( |
| 218 | 218 | $this->response, |
| 219 | - array( 'discounts' => $discounts ) |
|
| 219 | + array('discounts' => $discounts) |
|
| 220 | 220 | ); |
| 221 | 221 | |
| 222 | 222 | } |
@@ -226,24 +226,24 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @param GetPaid_Payment_Form_Submission $submission |
| 228 | 228 | */ |
| 229 | - public function add_taxes( $submission ) { |
|
| 229 | + public function add_taxes($submission) { |
|
| 230 | 230 | |
| 231 | 231 | $taxes = array(); |
| 232 | 232 | $markup = ''; |
| 233 | - foreach ( $submission->get_taxes() as $name => $data ) { |
|
| 234 | - $name = sanitize_text_field( $name ); |
|
| 235 | - $amount = $submission->format_amount( $data['initial_tax'] ); |
|
| 233 | + foreach ($submission->get_taxes() as $name => $data) { |
|
| 234 | + $name = sanitize_text_field($name); |
|
| 235 | + $amount = $submission->format_amount($data['initial_tax']); |
|
| 236 | 236 | $taxes[$name] = $amount; |
| 237 | 237 | $markup .= "<small class='form-text'>$name : $amount</small>"; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - if ( wpinv_display_individual_tax_rates() && ! empty( $taxes ) ) { |
|
| 240 | + if (wpinv_display_individual_tax_rates() && !empty($taxes)) { |
|
| 241 | 241 | $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup; |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | $this->response = array_merge( |
| 245 | 245 | $this->response, |
| 246 | - array( 'taxes' => $taxes ) |
|
| 246 | + array('taxes' => $taxes) |
|
| 247 | 247 | ); |
| 248 | 248 | |
| 249 | 249 | } |
@@ -253,29 +253,29 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @param GetPaid_Payment_Form_Submission $submission |
| 255 | 255 | */ |
| 256 | - public function add_gateways( $submission ) { |
|
| 256 | + public function add_gateways($submission) { |
|
| 257 | 257 | |
| 258 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
| 258 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
| 259 | 259 | |
| 260 | - if ( $this->response['has_recurring'] ) { |
|
| 260 | + if ($this->response['has_recurring']) { |
|
| 261 | 261 | |
| 262 | - foreach ( $gateways as $i => $gateway ) { |
|
| 262 | + foreach ($gateways as $i => $gateway) { |
|
| 263 | 263 | |
| 264 | 264 | if ( |
| 265 | - ! getpaid_payment_gateway_supports( $gateway, 'subscription' ) |
|
| 266 | - || ( $this->response['has_subscription_group'] && ! getpaid_payment_gateway_supports( $gateway, 'single_subscription_group' ) ) |
|
| 267 | - || ( $this->response['has_multiple_subscription_groups'] && ! getpaid_payment_gateway_supports( $gateway, 'multiple_subscription_groups' ) ) ) { |
|
| 268 | - unset( $gateways[ $i ] ); |
|
| 265 | + !getpaid_payment_gateway_supports($gateway, 'subscription') |
|
| 266 | + || ($this->response['has_subscription_group'] && !getpaid_payment_gateway_supports($gateway, 'single_subscription_group')) |
|
| 267 | + || ($this->response['has_multiple_subscription_groups'] && !getpaid_payment_gateway_supports($gateway, 'multiple_subscription_groups')) ) { |
|
| 268 | + unset($gateways[$i]); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
| 275 | + $gateways = apply_filters('getpaid_submission_gateways', $gateways, $submission); |
|
| 276 | 276 | $this->response = array_merge( |
| 277 | 277 | $this->response, |
| 278 | - array( 'gateways' => $gateways ) |
|
| 278 | + array('gateways' => $gateways) |
|
| 279 | 279 | ); |
| 280 | 280 | |
| 281 | 281 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | * |
| 286 | 286 | * @param GetPaid_Payment_Form_Submission $submission |
| 287 | 287 | */ |
| 288 | - public function add_data( $submission ) { |
|
| 288 | + public function add_data($submission) { |
|
| 289 | 289 | |
| 290 | 290 | $this->response = array_merge( |
| 291 | 291 | $this->response, |