activation-tracker.php
1 week ago
display-options.php
1 week ago
field-type-settings.php
1 week ago
field.php
1 week ago
filed-validation.php
1 week ago
myaccount-edit-address.php
1 week ago
myaccount-field-processor.php
1 week ago
plugin.php
1 week ago
settings.php
1 week ago
tracker.php
1 week ago
user-meta-checkout.php
1 week ago
user-meta.php
1 week ago
user-profile.php
1 week ago
myaccount-edit-address.php
50 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Class Flexible_Checkout_Fields_Myaccount_Edit_Address |
| 5 | */ |
| 6 | class Flexible_Checkout_Fields_Myaccount_Edit_Address { |
| 7 | |
| 8 | /** |
| 9 | * Plugin. |
| 10 | * |
| 11 | * @var Flexible_Checkout_Fields_Plugin |
| 12 | */ |
| 13 | protected $plugin; |
| 14 | |
| 15 | /** |
| 16 | * Flexible_Checkout_Fields_Myaccount_Edit_Address constructor. |
| 17 | * |
| 18 | * @param Flexible_Checkout_Fields_Plugin $plugin Plugin. |
| 19 | */ |
| 20 | public function __construct( $plugin ) { |
| 21 | $this->plugin = $plugin; |
| 22 | } |
| 23 | |
| 24 | |
| 25 | /** |
| 26 | * Hooks. |
| 27 | */ |
| 28 | public function hooks() { |
| 29 | add_filter( 'woocommerce_address_to_edit', [ $this, 'filter_edit_address_fields' ], 10, 2 ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Filter edit address fields. |
| 34 | * |
| 35 | * @param array $fields Fields. |
| 36 | * @param string $section Section. |
| 37 | * |
| 38 | * @return array |
| 39 | */ |
| 40 | public function filter_edit_address_fields( array $fields, $section ) { |
| 41 | foreach ( $fields as $key => $field ) { |
| 42 | $fcf_field = new Flexible_Checkout_Fields_Field( $field, $this->plugin ); |
| 43 | if ( $fcf_field->is_field_excluded_for_user() ) { |
| 44 | unset( $fields[ $key ] ); |
| 45 | } |
| 46 | } |
| 47 | return $fields; |
| 48 | } |
| 49 | } |
| 50 |