I am trying to figure out how to set the localization of a script based on a billing field setting. The bt_field in the below code needs to be set to a field name that is chosen in the billing field settings. Can this be retrieved in the scripts method or via a custom method like I am attempting?
public function scripts() {
$scripts = [];
if( $settings = $this->get_plugin_settings() ) {
[
'handle' => 'braintree_data_processing',
'src' => $this->get_base_url() . '/../assets/js/braintree-data-processing.js',
'version' => $this->_version,
'deps' => ['jquery'],
'strings' => [
'bt_magic' => $settings['tokenization-key'],
'bt_field' => $this->get_device_data_field_value()
],
'enqueue' => [
[$this, 'aft_enabled']
]
],
];
}
return array_merge(parent::scripts(), $scripts);
}