Created
September 20, 2024 14:56
-
-
Save xlplugins/a23b5c0c3e72922853695b0ac3956efd to your computer and use it in GitHub Desktop.
Theme lite Compatiblity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WFACP_theme_high_lite { | |
private $fields = []; | |
public function __construct() { | |
//add_filter( 'woocommerce_checkout_fields', [ $this, 'fetch_field' ], - 10 ); | |
add_filter( 'wfacp_checkout_fields', [ $this, 'push_field' ], 100,2 ); | |
} | |
public function fetch_field( $fields ) { | |
$this->fields['billing'] = array_filter( $fields['billing'], function ( $item ) { | |
return '1' == $item['custom']; | |
} ); | |
$this->fields['shipping'] = array_filter( $fields['shipping'], function ( $item ) { | |
return '1' == $item['custom']; | |
} ); | |
$this->fields['advanced'] = array_filter( $fields['advanced'], function ( $item ) { | |
return '1' == $item['custom']; | |
} ); | |
} | |
public function push_field( $fields,$orginal_field ) { | |
if(!wp_doing_ajax()){ | |
return $fields; | |
} | |
$this->fetch_field($orginal_field); | |
$fields['billing'] = array_merge( $fields['billing'], $this->fields['billing'] ); | |
$fields['shipping'] = array_merge( $fields['shipping'], $this->fields['shipping'] ); | |
$fields['advanced'] = array_merge( $fields['advanced'], $this->fields['advanced'] ); | |
return $fields; | |
} | |
} | |
new WFACP_theme_high_lite(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment