mutemercy
Forum Replies Created
-
Hi Zubair,
I’ve fixed my plugin like the following code to prevent the error. Hope this help someone for the same error.
B.R.
'label_class' => (is_string($this->label_class)) ? [$this->label_class] : $this->label_class,
Hi,
Thanks for your replay. I’ve just applied the fix to my code. Anyway, the actual code on that wc file could lead to a fatal error in the condition I’ve mentioned.
BR
Marco
Hi Zubair,
I get a fatal error when placing the classic checkout shortcode on a page AND using the woocommerce_checkout_fields filter hook AND use the filter for
'label_class' => 'myclass'AND for
'required' => truewell, I’ve investigated a little more.
try to use this filter hook: woocommerce_checkout_fields
filter the args with as exemple this func
function showCheckoutField( $fields ){
$fields[$this->target_hooks][$this->cf_name] = array(
'label' => __($this->label, 'wptravelandtour-txt' ),
'placeholder' => $this->placeholder,
'required' => $this->required,
'clear' => true,
'type' => $this->type,
'class' => array('form-row-wide', $this->wrapper_class ),
'label_class' => $this->label_class,
'options' => $this->checkout_options,
);
if ( $this->priority != 10 ){
$fields[$this->target_hooks][$this->cf_name]['priority'] = $this->priority;
}
return $fields;
}if ‘label_class’ is a string && required is true … you’ll get the fatal error
on the woo file wc-template-functions.php (starting @ line 3021)
$args = wp_parse_args( $args, $defaults );
$args = apply_filters( 'woocommerce_form_field_args', $args, $key, $value );
if ( is_string( $args['class'] ) ) {
$args['class'] = array( $args['class'] );
}
if ( $args['required'] ) {
// hidden inputs are the only kind of inputs that don't need anaria-requiredattribute.
// checkboxes apply thecustom_attributesto the label - we need to apply the attribute on the input itself, instead.
if ( ! in_array( $args['type'], array( 'hidden', 'checkbox' ), true ) ) {
$args['custom_attributes']['aria-required'] = 'true';
$args['label_class'][] = 'required_field';
}
$args['class'][] = 'validate-required';
$required_indicator = ' <span class="required" aria-hidden="true">*</span>';
} else {
$required_indicator = ' <span class="optional">(' . esc_html__( 'optional', 'woocommerce' ) . ')</span>';
}
if ( is_string( $args['label_class'] ) ) {
$args['label_class'] = array( $args['label_class'] );
}as I wrote: on wc-template-functions.php seems line 3042 should be called before 3033 (or better at 3028) to prevent the error.
Have a nice day!
Forum: Plugins
In reply to: [Smart Cookie Kit] Richiesta js defer o asyncUp