| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
/** |
| 7 |
* Woo Payments plugin compatibility layer |
| 8 |
*/ |
| 9 |
if ( ! class_exists( 'Merchant_Woo_Payments_Plugin' ) ) { |
| 10 |
class Merchant_Woo_Payments_Plugin { |
| 11 |
|
| 12 |
/** |
| 13 |
* Constructor. |
| 14 |
*/ |
| 15 |
public function __construct() { |
| 16 |
add_action( 'merchant_before_extra_checkouts_init', array( $this, 'checkout_remove_form_field_email_filter' ) ); |
| 17 |
add_filter( 'merchant_one_step_checkout_billing_fields', array( $this, 'checkout_add_email_field_class' ) ); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Remove Woo Payments email field filter which is causing the email field not to be displayed. |
| 22 |
* Issue: Email field is not being displayed with Merchant extra checkouts. |
| 23 |
* |
| 24 |
* @return void |
| 25 |
*/ |
| 26 |
function checkout_remove_form_field_email_filter() { |
| 27 |
remove_filter( 'woocommerce_form_field_email', array( 'WC_Payments', 'filter_woocommerce_form_field_woopay_email' ), 20 ); |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Add Woo Payments class to the email field. |
| 32 |
* Issue: Email field is not being displayed with Merchant extra checkouts. |
| 33 |
* |
| 34 |
* @return void |
| 35 |
*/ |
| 36 |
function checkout_add_email_field_class( $billing_fields ) { |
| 37 |
$billing_fields['billing_email']['class'][] = 'woopay-billing-email'; |
| 38 |
|
| 39 |
return $billing_fields; |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* The class object can be accessed with "global $merchant_woo_payments_compatibility", to allow removing actions. |
| 45 |
* Improving Third-party integrations. |
| 46 |
*/ |
| 47 |
$merchant_woo_payments_compatibility = new Merchant_Woo_Payments_Plugin(); |
| 48 |
} |
| 49 |
|