@@ -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)'), |
|
| 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)'), |
|
| 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 | } |
@@ -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,21 +23,21 @@ 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 | - 'is_free' => ! $submission->should_collect_payment_details(), |
|
| 31 | + 'is_free' => !$submission->should_collect_payment_details(), |
|
| 32 | 32 | ); |
| 33 | 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 ); |
|
| 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 | 41 | |
| 42 | 42 | } |
| 43 | 43 | |
@@ -46,30 +46,30 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @param GetPaid_Payment_Form_Submission $submission |
| 48 | 48 | */ |
| 49 | - public function add_totals( $submission ) { |
|
| 49 | + public function add_totals($submission) { |
|
| 50 | 50 | |
| 51 | 51 | $this->response = array_merge( |
| 52 | 52 | $this->response, |
| 53 | 53 | array( |
| 54 | 54 | |
| 55 | 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 ), |
|
| 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 | 62 | ), |
| 63 | 63 | |
| 64 | 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() ), |
|
| 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 | 70 | ), |
| 71 | 71 | |
| 72 | - 'initial_amt' => wpinv_round_amount( $submission->get_total(), null, true ), |
|
| 72 | + 'initial_amt' => wpinv_round_amount($submission->get_total(), null, true), |
|
| 73 | 73 | 'currency' => $submission->get_currency(), |
| 74 | 74 | |
| 75 | 75 | ) |
@@ -82,22 +82,22 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @param GetPaid_Payment_Form_Submission $submission |
| 84 | 84 | */ |
| 85 | - public function add_texts( $submission ) { |
|
| 85 | + public function add_texts($submission) { |
|
| 86 | 86 | |
| 87 | - $payable = $submission->format_amount( $submission->get_total() ); |
|
| 87 | + $payable = $submission->format_amount($submission->get_total()); |
|
| 88 | 88 | |
| 89 | - if ( $submission->has_recurring != 0 ) { |
|
| 89 | + if ($submission->has_recurring != 0) { |
|
| 90 | 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(), '' ); |
|
| 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 | 93 | |
| 94 | - if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
| 94 | + if ($submission->get_total() == $submission->get_recurring_total()) { |
|
| 95 | 95 | $payable = "$payable / $period"; |
| 96 | 96 | } else { |
| 97 | 97 | $payable = sprintf( |
| 98 | - __( '%1$s (renews at %2$s / %3$s)'), |
|
| 99 | - $submission->format_amount( $submission->get_total() ), |
|
| 100 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
| 98 | + __('%1$s (renews at %2$s / %3$s)'), |
|
| 99 | + $submission->format_amount($submission->get_total()), |
|
| 100 | + $submission->format_amount($submission->get_recurring_total()), |
|
| 101 | 101 | $period |
| 102 | 102 | ); |
| 103 | 103 | } |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | '.getpaid-checkout-total-payable' => $payable, |
| 109 | 109 | ); |
| 110 | 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() ); |
|
| 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 | 114 | } |
| 115 | 115 | |
| 116 | - $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
| 116 | + $this->response = array_merge($this->response, array('texts' => $texts)); |
|
| 117 | 117 | |
| 118 | 118 | } |
| 119 | 119 | |
@@ -122,18 +122,18 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @param GetPaid_Payment_Form_Submission $submission |
| 124 | 124 | */ |
| 125 | - public function add_items( $submission ) { |
|
| 125 | + public function add_items($submission) { |
|
| 126 | 126 | |
| 127 | 127 | // Add items. |
| 128 | 128 | $items = array(); |
| 129 | 129 | |
| 130 | - foreach ( $submission->get_items() as $item_id => $item ) { |
|
| 131 | - $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
| 130 | + foreach ($submission->get_items() as $item_id => $item) { |
|
| 131 | + $items["$item_id"] = $submission->format_amount($item->get_sub_total()); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | $this->response = array_merge( |
| 135 | 135 | $this->response, |
| 136 | - array( 'items' => $items ) |
|
| 136 | + array('items' => $items) |
|
| 137 | 137 | ); |
| 138 | 138 | |
| 139 | 139 | } |
@@ -143,17 +143,17 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @param GetPaid_Payment_Form_Submission $submission |
| 145 | 145 | */ |
| 146 | - public function add_fees( $submission ) { |
|
| 146 | + public function add_fees($submission) { |
|
| 147 | 147 | |
| 148 | 148 | $fees = array(); |
| 149 | 149 | |
| 150 | - foreach ( $submission->get_fees() as $name => $data ) { |
|
| 151 | - $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
| 150 | + foreach ($submission->get_fees() as $name => $data) { |
|
| 151 | + $fees[$name] = $submission->format_amount($data['initial_fee']); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | $this->response = array_merge( |
| 155 | 155 | $this->response, |
| 156 | - array( 'fees' => $fees ) |
|
| 156 | + array('fees' => $fees) |
|
| 157 | 157 | ); |
| 158 | 158 | |
| 159 | 159 | } |
@@ -163,17 +163,17 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @param GetPaid_Payment_Form_Submission $submission |
| 165 | 165 | */ |
| 166 | - public function add_discounts( $submission ) { |
|
| 166 | + public function add_discounts($submission) { |
|
| 167 | 167 | |
| 168 | 168 | $discounts = array(); |
| 169 | 169 | |
| 170 | - foreach ( $submission->get_discounts() as $name => $data ) { |
|
| 171 | - $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
| 170 | + foreach ($submission->get_discounts() as $name => $data) { |
|
| 171 | + $discounts[$name] = $submission->format_amount($data['initial_discount']); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $this->response = array_merge( |
| 175 | 175 | $this->response, |
| 176 | - array( 'discounts' => $discounts ) |
|
| 176 | + array('discounts' => $discounts) |
|
| 177 | 177 | ); |
| 178 | 178 | |
| 179 | 179 | } |
@@ -183,24 +183,24 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @param GetPaid_Payment_Form_Submission $submission |
| 185 | 185 | */ |
| 186 | - public function add_taxes( $submission ) { |
|
| 186 | + public function add_taxes($submission) { |
|
| 187 | 187 | |
| 188 | 188 | $taxes = array(); |
| 189 | 189 | $markup = ''; |
| 190 | - foreach ( $submission->get_taxes() as $name => $data ) { |
|
| 191 | - $name = sanitize_text_field( $name ); |
|
| 192 | - $amount = $submission->format_amount( $data['initial_tax'] ); |
|
| 190 | + foreach ($submission->get_taxes() as $name => $data) { |
|
| 191 | + $name = sanitize_text_field($name); |
|
| 192 | + $amount = $submission->format_amount($data['initial_tax']); |
|
| 193 | 193 | $taxes[$name] = $amount; |
| 194 | 194 | $markup .= "<small class='form-text'>$name : $amount</small>"; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - if ( wpinv_display_individual_tax_rates() ) { |
|
| 197 | + if (wpinv_display_individual_tax_rates()) { |
|
| 198 | 198 | $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | $this->response = array_merge( |
| 202 | 202 | $this->response, |
| 203 | - array( 'taxes' => $taxes ) |
|
| 203 | + array('taxes' => $taxes) |
|
| 204 | 204 | ); |
| 205 | 205 | |
| 206 | 206 | } |
@@ -210,16 +210,16 @@ discard block |
||
| 210 | 210 | * |
| 211 | 211 | * @param GetPaid_Payment_Form_Submission $submission |
| 212 | 212 | */ |
| 213 | - public function add_gateways( $submission ) { |
|
| 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 ] ); |
|
| 221 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
| 222 | + unset($gateways[$i]); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | } |
@@ -227,10 +227,10 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | |
| 230 | - $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
| 230 | + $gateways = apply_filters('getpaid_submission_gateways', $gateways, $submission); |
|
| 231 | 231 | $this->response = array_merge( |
| 232 | 232 | $this->response, |
| 233 | - array( 'gateways' => $gateways ) |
|
| 233 | + array('gateways' => $gateways) |
|
| 234 | 234 | ); |
| 235 | 235 | |
| 236 | 236 | } |
@@ -7,35 +7,35 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | $value = ''; |
| 13 | 13 | $class = ''; |
| 14 | 14 | |
| 15 | -if ( ! empty( $form->invoice ) ) { |
|
| 16 | - $value = sanitize_email( $form->invoice->get_email() ); |
|
| 17 | -} else if ( is_user_logged_in() ) { |
|
| 15 | +if (!empty($form->invoice)) { |
|
| 16 | + $value = sanitize_email($form->invoice->get_email()); |
|
| 17 | +} else if (is_user_logged_in()) { |
|
| 18 | 18 | $user = wp_get_current_user(); |
| 19 | - $value = sanitize_email( $user->user_email ); |
|
| 19 | + $value = sanitize_email($user->user_email); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -if ( ! empty( $value ) && ! empty( $hide_billing_email ) ) { |
|
| 22 | +if (!empty($value) && !empty($hide_billing_email)) { |
|
| 23 | 23 | $class = 'd-none'; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | -do_action( 'getpaid_before_payment_form_billing_email', $form ); |
|
| 26 | +do_action('getpaid_before_payment_form_billing_email', $form); |
|
| 27 | 27 | |
| 28 | 28 | echo "<span class='$class'>"; |
| 29 | 29 | |
| 30 | 30 | echo aui()->input( |
| 31 | 31 | array( |
| 32 | 32 | 'name' => 'billing_email', |
| 33 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
| 34 | - 'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
| 35 | - 'required' => ! empty( $required ), |
|
| 36 | - 'label' => empty( $label ) ? '' : wp_kses_post( $label ) . '<span class="text-danger"> *</span>', |
|
| 33 | + 'id' => esc_attr($id) . uniqid('_'), |
|
| 34 | + 'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder), |
|
| 35 | + 'required' => !empty($required), |
|
| 36 | + 'label' => empty($label) ? '' : wp_kses_post($label) . '<span class="text-danger"> *</span>', |
|
| 37 | 37 | 'label_type' => 'vertical', |
| 38 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 38 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
| 39 | 39 | 'type' => 'email', |
| 40 | 40 | 'value' => $value, |
| 41 | 41 | 'class' => 'wpinv_billing_email', |
@@ -47,4 +47,4 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | echo '</span>'; |
| 49 | 49 | |
| 50 | -do_action( 'getpaid_after_payment_form_billing_email', $form ); |
|
| 50 | +do_action('getpaid_after_payment_form_billing_email', $form); |
|