Skip to content

Instantly share code, notes, and snippets.

@xlplugins
Created September 20, 2024 14:56
Show Gist options
  • Save xlplugins/a23b5c0c3e72922853695b0ac3956efd to your computer and use it in GitHub Desktop.
Save xlplugins/a23b5c0c3e72922853695b0ac3956efd to your computer and use it in GitHub Desktop.
Theme lite Compatiblity
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