Your plugin broke fields for other plugins
-
Howdy, I’ve found one bug inside your plugin related to fields on a checkout page that was added via the
woocommerce_field
function.woocommerce_form_field( 'custom-select', [ 'type' => 'select', 'label' => esc_html__( 'Custom Select', 'great-plugin' ), 'options' => [ 'key' => esc_html__( 'Value', 'great-plugin' ), 'another-key' => esc_html__( 'Another Value', 'great-plugin' ), ], 'default' => 'another-key', ] );
The default WooCommerce behavior for this function should prepare next markup:
<option value="key">Value</option> <option value="another-key">Another Value</option>
But your plugin’s filter changes it to the:
<option value="Value">Value</option> <option value="Another Value">Another Value</option>
The problem located inside the
woocommerce-checkout-manager/includes/view/frontend/class-wooccm-fields-filters.php
file in 110 line:$field .= '<option value="' . esc_attr($option_text) . '" ' . selected($value, $option_text, false) . '>' . esc_attr($option_text) . '</option>';
It should be:
$field .= '<option value="' . esc_attr($option_key) . '" ' . selected($value, $option_key, false) . '>' . esc_attr($option_text) . '</option>';
instead.So, please pay attention that we should use the value of the option’s key and choose selected elements based on the option’s value.
Also, I left the link to the related code in WooCommerce.
I’ll appreciate it if you can fix it as soon as possible.
- The topic ‘Your plugin broke fields for other plugins’ is closed to new replies.