| @@ -6,9 +6,8 @@ | ||
| 6 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | 7 | exit( 'This script cannot be accessed directly.' ); |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | -use PhpParser\Node\Expr\Empty_; | |
| 11 | 10 | use RadiusTheme\SB\Traits\SingletonTrait; |
| 12 | 11 | |
| 13 | 12 | /** |
| 14 | 13 | * CheckoutEditorInit |
| @@ -25,8 +24,25 @@ | ||
| 25 | 24 | private function __construct() { |
| 26 | 25 | parent::__construct(); |
| 27 | 26 | add_filter( 'woocommerce_get_country_locale', [ $this, 'get_country_locale' ] ); |
| 28 | 27 | add_filter( 'woocommerce_default_address_fields', [ $this, 'default_address_fields' ], 9999 ); |
| 28 | + add_filter( 'woocommerce_form_field_args', [ $this, 'customize_billing_state' ], 10, 3 ); // The hook will work for initial page load. | |
| 29 | + } | |
| 30 | + /** | |
| 31 | + * Customize the billing state field arguments on the initial page load. | |
| 32 | + * | |
| 33 | + * @param array $args The field arguments. | |
| 34 | + * @param string $key The field key. | |
| 35 | + * @param mixed $value The field value. | |
| 36 | + * @return array Modified field arguments. | |
| 37 | + */ | |
| 38 | + public function customize_billing_state( $args, $key, $value ) { | |
| 39 | + if ( 'billing_state' !== $key ) { | |
| 40 | + return $args; | |
| 41 | + } | |
| 42 | + $args['label'] = $this->billing_settings['billing_state']['label'] ?? esc_html__( 'State / Region', 'shopbuilder' ); | |
| 43 | + $args['placeholder'] = $this->billing_settings['billing_state']['placeholder'] ?? esc_html__( 'State / Region', 'shopbuilder' ); | |
| 44 | + return $args; | |
| 29 | 45 | } |
| 30 | 46 | /** |
| 31 | 47 | * @param array $fields fields. |
| 32 | 48 | * @return array |