| 1 |
<?php |
| 2 |
|
| 3 |
namespace Better_Payment\Lite\Classes; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
/** |
| 10 |
* Lite's copy of the Payment Form quantity total for Pro layouts 4 and 5. |
| 11 |
* |
| 12 |
* Transitional copy for Better Payment Pro <= 1.4.3; delete when |
| 13 |
* ProCompatibility::MIN_PRO_VERSION >= 1.4.4 (with src/js/payment-form-pro-quantity.js |
| 14 |
* and its Assets entry). |
| 15 |
* Pro copy: better-payment-pro/src/js/payment-form-quantity.js. Slug: `payment_form_pro_scripts`. |
| 16 |
* |
| 17 |
* Only Pro's layouts 4 and 5 render the quantity field |
| 18 |
* (`.bp-custom-payment-amount-quantity`). better-payment.js used to multiply the |
| 19 |
* transaction details total by it on every install. It now writes the plain amount |
| 20 |
* and triggers `better_payment_amount_changed` on the document, and the listener in |
| 21 |
* src/js/payment-form-pro-quantity.js multiplies. That script is a registration-time |
| 22 |
* dependency of `better-payment` (it loads wherever better-payment.js does), added |
| 23 |
* only while ProCompatibility::lite_copy_applies() is true. The event fires after the |
| 24 |
* plain total is written, so load order does not matter. |
| 25 |
* |
| 26 |
* The slug is a Payment Form one rather than a User Dashboard one: the field belongs |
| 27 |
* to the Payment Form widget, and the script loads with the payment form, not with |
| 28 |
* the dashboard. |
| 29 |
* |
| 30 |
* @since 2.4.0 |
| 31 |
*/ |
| 32 |
final class ProPaymentFormScripts { |
| 33 |
|
| 34 |
/** |
| 35 |
* Feature slug Pro declares once it ships the script. |
| 36 |
*/ |
| 37 |
const FEATURE = 'payment_form_pro_scripts'; |
| 38 |
|
| 39 |
/** |
| 40 |
* Lite's script handle (registered in Assets). |
| 41 |
*/ |
| 42 |
const HANDLE = 'better-payment-payment-form-pro-quantity'; |
| 43 |
|
| 44 |
/** |
| 45 |
* Dependencies to add to `better-payment`. |
| 46 |
* |
| 47 |
* @return string[] |
| 48 |
*/ |
| 49 |
public static function script_depends(): array { |
| 50 |
return ProCompatibility::lite_copy_applies( self::FEATURE ) ? array( self::HANDLE ) : array(); |
| 51 |
} |
| 52 |
} |
| 53 |
|