@@ -43,64 +43,64 @@ discard block |
||
43 | 43 | <td class="w-75"> |
44 | 44 | <?php |
45 | 45 | |
46 | - switch ( $key ) { |
|
46 | + switch ( $key ) { |
|
47 | 47 | |
48 | - case 'status': |
|
49 | - echo sanitize_text_field( $subscription->get_status_label() ); |
|
50 | - break; |
|
48 | + case 'status': |
|
49 | + echo sanitize_text_field( $subscription->get_status_label() ); |
|
50 | + break; |
|
51 | 51 | |
52 | - case 'start_date': |
|
53 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
54 | - break; |
|
52 | + case 'start_date': |
|
53 | + echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
54 | + break; |
|
55 | 55 | |
56 | - case 'expiry_date': |
|
57 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) ); |
|
58 | - break; |
|
56 | + case 'expiry_date': |
|
57 | + echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) ); |
|
58 | + break; |
|
59 | 59 | |
60 | - case 'initial_amount': |
|
61 | - echo wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
60 | + case 'initial_amount': |
|
61 | + echo wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
62 | 62 | |
63 | - if ( $subscription->has_trial_period() ) { |
|
63 | + if ( $subscription->has_trial_period() ) { |
|
64 | 64 | |
65 | - echo "<small class='text-muted'> "; |
|
66 | - printf( |
|
67 | - _x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ), |
|
68 | - sanitize_text_field( $subscription->get_trial_period() ) |
|
69 | - ); |
|
70 | - echo '</small>'; |
|
65 | + echo "<small class='text-muted'> "; |
|
66 | + printf( |
|
67 | + _x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ), |
|
68 | + sanitize_text_field( $subscription->get_trial_period() ) |
|
69 | + ); |
|
70 | + echo '</small>'; |
|
71 | 71 | |
72 | - } |
|
72 | + } |
|
73 | 73 | |
74 | - break; |
|
74 | + break; |
|
75 | 75 | |
76 | - case 'recurring_amount': |
|
77 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
78 | - $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
79 | - echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ); |
|
80 | - break; |
|
76 | + case 'recurring_amount': |
|
77 | + $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
78 | + $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
79 | + echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ); |
|
80 | + break; |
|
81 | 81 | |
82 | - case 'item': |
|
83 | - $item = get_post( $subscription->get_product_id() ); |
|
82 | + case 'item': |
|
83 | + $item = get_post( $subscription->get_product_id() ); |
|
84 | 84 | |
85 | - if ( ! empty( $item ) ) { |
|
86 | - echo esc_html( get_the_title( $item ) ); |
|
87 | - } else { |
|
88 | - echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
89 | - } |
|
85 | + if ( ! empty( $item ) ) { |
|
86 | + echo esc_html( get_the_title( $item ) ); |
|
87 | + } else { |
|
88 | + echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
89 | + } |
|
90 | 90 | |
91 | - break; |
|
91 | + break; |
|
92 | 92 | |
93 | - case 'payments': |
|
93 | + case 'payments': |
|
94 | 94 | |
95 | - $max_activations = (int) $subscription->get_bill_times(); |
|
96 | - echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "∞" : $max_activations ); |
|
95 | + $max_activations = (int) $subscription->get_bill_times(); |
|
96 | + echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "∞" : $max_activations ); |
|
97 | 97 | |
98 | - break; |
|
98 | + break; |
|
99 | 99 | |
100 | - } |
|
101 | - do_action( "getpaid_render_single_subscription_column_$key", $subscription ); |
|
100 | + } |
|
101 | + do_action( "getpaid_render_single_subscription_column_$key", $subscription ); |
|
102 | 102 | |
103 | - ?> |
|
103 | + ?> |
|
104 | 104 | </td> |
105 | 105 | |
106 | 106 | </tr> |
@@ -117,17 +117,17 @@ discard block |
||
117 | 117 | <span class="form-text"> |
118 | 118 | |
119 | 119 | <?php |
120 | - if ( $subscription->can_cancel() ) { |
|
121 | - printf( |
|
122 | - '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a> ', |
|
123 | - esc_url( $subscription->get_cancel_url() ), |
|
124 | - esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ), |
|
125 | - __( 'Cancel Subscription', 'invoicing' ) |
|
126 | - ); |
|
127 | - } |
|
128 | - |
|
129 | - do_action( 'getpaid-single-subscription-page-actions', $subscription ); |
|
130 | - ?> |
|
120 | + if ( $subscription->can_cancel() ) { |
|
121 | + printf( |
|
122 | + '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a> ', |
|
123 | + esc_url( $subscription->get_cancel_url() ), |
|
124 | + esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ), |
|
125 | + __( 'Cancel Subscription', 'invoicing' ) |
|
126 | + ); |
|
127 | + } |
|
128 | + |
|
129 | + do_action( 'getpaid-single-subscription-page-actions', $subscription ); |
|
130 | + ?> |
|
131 | 131 | |
132 | 132 | <a href="<?php echo esc_url( getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); ?>" class="btn btn-secondary btn-sm"><?php _e( 'Go Back', 'invoicing' ); ?></a> |
133 | 133 | </span> |
134 | 134 | \ No newline at end of file |
@@ -13,42 +13,42 @@ |
||
13 | 13 | |
14 | 14 | foreach ( array_keys( $widget->get_subscriptions_table_columns() ) as $column ) : |
15 | 15 | |
16 | - $class = sanitize_html_class( $column ); |
|
17 | - echo "<td class='getpaid-subscriptions-table-column-$class'>"; |
|
16 | + $class = sanitize_html_class( $column ); |
|
17 | + echo "<td class='getpaid-subscriptions-table-column-$class'>"; |
|
18 | 18 | |
19 | - do_action( "getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription ); |
|
19 | + do_action( "getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription ); |
|
20 | 20 | |
21 | - switch( $column ) : |
|
21 | + switch( $column ) : |
|
22 | 22 | |
23 | - case 'subscription': |
|
24 | - $subscription_id = (int) $subscription->get_id(); |
|
25 | - $url = esc_url( $subscription->get_view_url() ); |
|
26 | - $id_label = sprintf( |
|
27 | - esc_attr_x( '#%s', 'subscription id', 'invoicing' ), |
|
28 | - $subscription->get_id() |
|
29 | - ); |
|
30 | - echo $widget->add_row_actions( "<a href='$url' class='font-weight-bold text-decoration-none'>$id_label</a>", $subscription ); |
|
31 | - break; |
|
23 | + case 'subscription': |
|
24 | + $subscription_id = (int) $subscription->get_id(); |
|
25 | + $url = esc_url( $subscription->get_view_url() ); |
|
26 | + $id_label = sprintf( |
|
27 | + esc_attr_x( '#%s', 'subscription id', 'invoicing' ), |
|
28 | + $subscription->get_id() |
|
29 | + ); |
|
30 | + echo $widget->add_row_actions( "<a href='$url' class='font-weight-bold text-decoration-none'>$id_label</a>", $subscription ); |
|
31 | + break; |
|
32 | 32 | |
33 | - case 'status': |
|
34 | - echo sanitize_text_field( $subscription->get_status_label() ); |
|
35 | - break; |
|
33 | + case 'status': |
|
34 | + echo sanitize_text_field( $subscription->get_status_label() ); |
|
35 | + break; |
|
36 | 36 | |
37 | - case 'renewal-date': |
|
38 | - $renewal = getpaid_format_date_value( $subscription->get_next_renewal_date() ); |
|
39 | - echo $subscription->is_active() ? sanitize_text_field( $renewal ) : "—"; |
|
40 | - break; |
|
37 | + case 'renewal-date': |
|
38 | + $renewal = getpaid_format_date_value( $subscription->get_next_renewal_date() ); |
|
39 | + echo $subscription->is_active() ? sanitize_text_field( $renewal ) : "—"; |
|
40 | + break; |
|
41 | 41 | |
42 | - case 'amount': |
|
43 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
44 | - $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
45 | - echo wp_kses_post( "<span>$amount</span> / <span class='getpaid-item-recurring-period'>$frequency</span>" ); |
|
46 | - break; |
|
42 | + case 'amount': |
|
43 | + $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
44 | + $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
45 | + echo wp_kses_post( "<span>$amount</span> / <span class='getpaid-item-recurring-period'>$frequency</span>" ); |
|
46 | + break; |
|
47 | 47 | |
48 | - endswitch; |
|
48 | + endswitch; |
|
49 | 49 | |
50 | - do_action( "getpaid_subscriptions_frontend_subscription_table_$column", $subscription ); |
|
50 | + do_action( "getpaid_subscriptions_frontend_subscription_table_$column", $subscription ); |
|
51 | 51 | |
52 | - echo '</td>'; |
|
52 | + echo '</td>'; |
|
53 | 53 | |
54 | 54 | endforeach; |
@@ -12,227 +12,227 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Payment_Form_Submission_Refresh_Prices { |
14 | 14 | |
15 | - /** |
|
16 | - * Contains the response for refreshing prices. |
|
17 | - * @var array |
|
18 | - */ |
|
19 | - public $response = array(); |
|
15 | + /** |
|
16 | + * Contains the response for refreshing prices. |
|
17 | + * @var array |
|
18 | + */ |
|
19 | + public $response = array(); |
|
20 | 20 | |
21 | 21 | /** |
22 | - * Class constructor |
|
23 | - * |
|
24 | - * @param GetPaid_Payment_Form_Submission $submission |
|
25 | - */ |
|
26 | - public function __construct( $submission ) { |
|
27 | - |
|
28 | - $this->response = array( |
|
29 | - 'submission_id' => $submission->id, |
|
22 | + * Class constructor |
|
23 | + * |
|
24 | + * @param GetPaid_Payment_Form_Submission $submission |
|
25 | + */ |
|
26 | + public function __construct( $submission ) { |
|
27 | + |
|
28 | + $this->response = array( |
|
29 | + 'submission_id' => $submission->id, |
|
30 | 30 | 'has_recurring' => $submission->has_recurring, |
31 | 31 | 'is_free' => ! $submission->should_collect_payment_details(), |
32 | - ); |
|
33 | - |
|
34 | - $this->add_totals( $submission ); |
|
35 | - $this->add_texts( $submission ); |
|
36 | - $this->add_items( $submission ); |
|
37 | - $this->add_fees( $submission ); |
|
38 | - $this->add_discounts( $submission ); |
|
39 | - $this->add_taxes( $submission ); |
|
40 | - $this->add_gateways( $submission ); |
|
41 | - |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Adds totals to a response for submission refresh prices. |
|
46 | - * |
|
47 | - * @param GetPaid_Payment_Form_Submission $submission |
|
48 | - */ |
|
49 | - public function add_totals( $submission ) { |
|
50 | - |
|
51 | - $this->response = array_merge( |
|
52 | - $this->response, |
|
53 | - array( |
|
54 | - |
|
55 | - 'totals' => array( |
|
56 | - 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
57 | - 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
58 | - 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
59 | - 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
60 | - 'total' => $submission->format_amount( $submission->get_total() ), |
|
61 | - 'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ), |
|
62 | - ), |
|
63 | - |
|
64 | - 'recurring' => array( |
|
65 | - 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
66 | - 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
67 | - 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
68 | - 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
69 | - 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
70 | - ), |
|
71 | - |
|
72 | - 'initial_amt' => wpinv_round_amount( $submission->get_total(), null, true ), |
|
73 | - 'currency' => $submission->get_currency(), |
|
74 | - |
|
75 | - ) |
|
76 | - ); |
|
77 | - |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Adds texts to a response for submission refresh prices. |
|
82 | - * |
|
83 | - * @param GetPaid_Payment_Form_Submission $submission |
|
84 | - */ |
|
85 | - public function add_texts( $submission ) { |
|
86 | - |
|
87 | - $payable = $submission->format_amount( $submission->get_total() ); |
|
88 | - |
|
89 | - if ( $submission->has_recurring != 0 ) { |
|
90 | - |
|
91 | - $recurring = new WPInv_Item( $submission->has_recurring ); |
|
92 | - $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
93 | - |
|
94 | - if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
95 | - $payable = "$payable / $period"; |
|
96 | - } else { |
|
97 | - $payable = sprintf( |
|
98 | - __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
99 | - $submission->format_amount( $submission->get_total() ), |
|
100 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
101 | - $period |
|
102 | - ); |
|
103 | - } |
|
104 | - |
|
105 | - } |
|
106 | - |
|
107 | - $texts = array( |
|
108 | - '.getpaid-checkout-total-payable' => $payable, |
|
109 | - ); |
|
110 | - |
|
111 | - foreach ( $submission->get_items() as $item_id => $item ) { |
|
112 | - $texts[".item-$item_id .getpaid-item-initial-price"] = $submission->format_amount( $item->get_sub_total() ); |
|
113 | - $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() ); |
|
114 | - } |
|
115 | - |
|
116 | - $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
117 | - |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Adds items to a response for submission refresh prices. |
|
122 | - * |
|
123 | - * @param GetPaid_Payment_Form_Submission $submission |
|
124 | - */ |
|
125 | - public function add_items( $submission ) { |
|
126 | - |
|
127 | - // Add items. |
|
128 | - $items = array(); |
|
32 | + ); |
|
33 | + |
|
34 | + $this->add_totals( $submission ); |
|
35 | + $this->add_texts( $submission ); |
|
36 | + $this->add_items( $submission ); |
|
37 | + $this->add_fees( $submission ); |
|
38 | + $this->add_discounts( $submission ); |
|
39 | + $this->add_taxes( $submission ); |
|
40 | + $this->add_gateways( $submission ); |
|
41 | + |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Adds totals to a response for submission refresh prices. |
|
46 | + * |
|
47 | + * @param GetPaid_Payment_Form_Submission $submission |
|
48 | + */ |
|
49 | + public function add_totals( $submission ) { |
|
50 | + |
|
51 | + $this->response = array_merge( |
|
52 | + $this->response, |
|
53 | + array( |
|
54 | + |
|
55 | + 'totals' => array( |
|
56 | + 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
57 | + 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
58 | + 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
59 | + 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
60 | + 'total' => $submission->format_amount( $submission->get_total() ), |
|
61 | + 'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ), |
|
62 | + ), |
|
63 | + |
|
64 | + 'recurring' => array( |
|
65 | + 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
66 | + 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
67 | + 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
68 | + 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
69 | + 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
70 | + ), |
|
71 | + |
|
72 | + 'initial_amt' => wpinv_round_amount( $submission->get_total(), null, true ), |
|
73 | + 'currency' => $submission->get_currency(), |
|
74 | + |
|
75 | + ) |
|
76 | + ); |
|
77 | + |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Adds texts to a response for submission refresh prices. |
|
82 | + * |
|
83 | + * @param GetPaid_Payment_Form_Submission $submission |
|
84 | + */ |
|
85 | + public function add_texts( $submission ) { |
|
86 | + |
|
87 | + $payable = $submission->format_amount( $submission->get_total() ); |
|
88 | + |
|
89 | + if ( $submission->has_recurring != 0 ) { |
|
90 | + |
|
91 | + $recurring = new WPInv_Item( $submission->has_recurring ); |
|
92 | + $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
93 | + |
|
94 | + if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
95 | + $payable = "$payable / $period"; |
|
96 | + } else { |
|
97 | + $payable = sprintf( |
|
98 | + __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
99 | + $submission->format_amount( $submission->get_total() ), |
|
100 | + $submission->format_amount( $submission->get_recurring_total() ), |
|
101 | + $period |
|
102 | + ); |
|
103 | + } |
|
104 | + |
|
105 | + } |
|
106 | + |
|
107 | + $texts = array( |
|
108 | + '.getpaid-checkout-total-payable' => $payable, |
|
109 | + ); |
|
129 | 110 | |
130 | 111 | foreach ( $submission->get_items() as $item_id => $item ) { |
131 | - $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
132 | - } |
|
112 | + $texts[".item-$item_id .getpaid-item-initial-price"] = $submission->format_amount( $item->get_sub_total() ); |
|
113 | + $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() ); |
|
114 | + } |
|
133 | 115 | |
134 | - $this->response = array_merge( |
|
135 | - $this->response, |
|
136 | - array( 'items' => $items ) |
|
137 | - ); |
|
116 | + $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
138 | 117 | |
139 | - } |
|
118 | + } |
|
140 | 119 | |
141 | - /** |
|
142 | - * Adds fees to a response for submission refresh prices. |
|
143 | - * |
|
144 | - * @param GetPaid_Payment_Form_Submission $submission |
|
145 | - */ |
|
146 | - public function add_fees( $submission ) { |
|
120 | + /** |
|
121 | + * Adds items to a response for submission refresh prices. |
|
122 | + * |
|
123 | + * @param GetPaid_Payment_Form_Submission $submission |
|
124 | + */ |
|
125 | + public function add_items( $submission ) { |
|
126 | + |
|
127 | + // Add items. |
|
128 | + $items = array(); |
|
129 | + |
|
130 | + foreach ( $submission->get_items() as $item_id => $item ) { |
|
131 | + $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
132 | + } |
|
133 | + |
|
134 | + $this->response = array_merge( |
|
135 | + $this->response, |
|
136 | + array( 'items' => $items ) |
|
137 | + ); |
|
138 | + |
|
139 | + } |
|
147 | 140 | |
148 | - $fees = array(); |
|
141 | + /** |
|
142 | + * Adds fees to a response for submission refresh prices. |
|
143 | + * |
|
144 | + * @param GetPaid_Payment_Form_Submission $submission |
|
145 | + */ |
|
146 | + public function add_fees( $submission ) { |
|
147 | + |
|
148 | + $fees = array(); |
|
149 | 149 | |
150 | 150 | foreach ( $submission->get_fees() as $name => $data ) { |
151 | - $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
152 | - } |
|
151 | + $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
152 | + } |
|
153 | 153 | |
154 | - $this->response = array_merge( |
|
155 | - $this->response, |
|
156 | - array( 'fees' => $fees ) |
|
157 | - ); |
|
154 | + $this->response = array_merge( |
|
155 | + $this->response, |
|
156 | + array( 'fees' => $fees ) |
|
157 | + ); |
|
158 | 158 | |
159 | - } |
|
159 | + } |
|
160 | 160 | |
161 | - /** |
|
162 | - * Adds discounts to a response for submission refresh prices. |
|
163 | - * |
|
164 | - * @param GetPaid_Payment_Form_Submission $submission |
|
165 | - */ |
|
166 | - public function add_discounts( $submission ) { |
|
161 | + /** |
|
162 | + * Adds discounts to a response for submission refresh prices. |
|
163 | + * |
|
164 | + * @param GetPaid_Payment_Form_Submission $submission |
|
165 | + */ |
|
166 | + public function add_discounts( $submission ) { |
|
167 | 167 | |
168 | - $discounts = array(); |
|
168 | + $discounts = array(); |
|
169 | 169 | |
170 | 170 | foreach ( $submission->get_discounts() as $name => $data ) { |
171 | - $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
172 | - } |
|
171 | + $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
172 | + } |
|
173 | 173 | |
174 | - $this->response = array_merge( |
|
175 | - $this->response, |
|
176 | - array( 'discounts' => $discounts ) |
|
177 | - ); |
|
174 | + $this->response = array_merge( |
|
175 | + $this->response, |
|
176 | + array( 'discounts' => $discounts ) |
|
177 | + ); |
|
178 | 178 | |
179 | - } |
|
179 | + } |
|
180 | 180 | |
181 | - /** |
|
182 | - * Adds taxes to a response for submission refresh prices. |
|
183 | - * |
|
184 | - * @param GetPaid_Payment_Form_Submission $submission |
|
185 | - */ |
|
186 | - public function add_taxes( $submission ) { |
|
187 | - |
|
188 | - $taxes = array(); |
|
189 | - $markup = ''; |
|
181 | + /** |
|
182 | + * Adds taxes to a response for submission refresh prices. |
|
183 | + * |
|
184 | + * @param GetPaid_Payment_Form_Submission $submission |
|
185 | + */ |
|
186 | + public function add_taxes( $submission ) { |
|
187 | + |
|
188 | + $taxes = array(); |
|
189 | + $markup = ''; |
|
190 | 190 | foreach ( $submission->get_taxes() as $name => $data ) { |
191 | - $name = sanitize_text_field( $name ); |
|
192 | - $amount = $submission->format_amount( $data['initial_tax'] ); |
|
193 | - $taxes[$name] = $amount; |
|
194 | - $markup .= "<small class='form-text'>$name : $amount</small>"; |
|
195 | - } |
|
191 | + $name = sanitize_text_field( $name ); |
|
192 | + $amount = $submission->format_amount( $data['initial_tax'] ); |
|
193 | + $taxes[$name] = $amount; |
|
194 | + $markup .= "<small class='form-text'>$name : $amount</small>"; |
|
195 | + } |
|
196 | 196 | |
197 | - if ( wpinv_display_individual_tax_rates() ) { |
|
198 | - $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup; |
|
199 | - } |
|
197 | + if ( wpinv_display_individual_tax_rates() ) { |
|
198 | + $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup; |
|
199 | + } |
|
200 | 200 | |
201 | - $this->response = array_merge( |
|
202 | - $this->response, |
|
203 | - array( 'taxes' => $taxes ) |
|
204 | - ); |
|
201 | + $this->response = array_merge( |
|
202 | + $this->response, |
|
203 | + array( 'taxes' => $taxes ) |
|
204 | + ); |
|
205 | 205 | |
206 | - } |
|
206 | + } |
|
207 | 207 | |
208 | - /** |
|
209 | - * Adds gateways to a response for submission refresh prices. |
|
210 | - * |
|
211 | - * @param GetPaid_Payment_Form_Submission $submission |
|
212 | - */ |
|
213 | - public function add_gateways( $submission ) { |
|
208 | + /** |
|
209 | + * Adds gateways to a response for submission refresh prices. |
|
210 | + * |
|
211 | + * @param GetPaid_Payment_Form_Submission $submission |
|
212 | + */ |
|
213 | + public function add_gateways( $submission ) { |
|
214 | 214 | |
215 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
215 | + $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
216 | 216 | |
217 | - if ( $this->response['has_recurring'] ) { |
|
217 | + if ( $this->response['has_recurring'] ) { |
|
218 | 218 | |
219 | - foreach ( $gateways as $i => $gateway ) { |
|
219 | + foreach ( $gateways as $i => $gateway ) { |
|
220 | 220 | |
221 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
222 | - unset( $gateways[ $i ] ); |
|
223 | - } |
|
221 | + if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
222 | + unset( $gateways[ $i ] ); |
|
223 | + } |
|
224 | 224 | |
225 | - } |
|
225 | + } |
|
226 | 226 | |
227 | - } |
|
227 | + } |
|
228 | 228 | |
229 | 229 | |
230 | - $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
231 | - $this->response = array_merge( |
|
232 | - $this->response, |
|
233 | - array( 'gateways' => $gateways ) |
|
234 | - ); |
|
230 | + $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
231 | + $this->response = array_merge( |
|
232 | + $this->response, |
|
233 | + array( 'gateways' => $gateways ) |
|
234 | + ); |
|
235 | 235 | |
236 | - } |
|
236 | + } |
|
237 | 237 | |
238 | 238 | } |