• Resolved Piotr Po

    (@potreb)


    Hello,

    I have blank page in dashboard.

    After load data from: wp-json/awcfe/v1/fields/

    Uncaught (in promise) TypeError: t.options is undefined backend.js:1:341829

    How to testing? Paste this code.

    add_filter( ‘woocommerce_billing_fields’, ‘custom_woocommerce_billing_fields’, 20 );

    function custom_woocommerce_billing_fields( $fields ) {
    $fields[‘custom_field’] = array(
    ‘label’ => ‘Scary Field’,
    ‘type’ => ‘checkbox’,
    ‘priority’ => 90
    );

    return $fields;
    }

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Sanesh Acowebs

    (@saneshacodez)

    Hi, Can you please change your code as given below. You need to use the “woocommerce_checkout_fields” hook to work with our plugin. Also you must add an options empty array to work in the case of checkbox field type. Our Pro version of plugin has options to add checkbox field type and many other field types. You can try this if you interested.

    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
    
    function custom_override_checkout_fields( $fields ) {
    		$fields['billing']['custom_field'] = array(
    			'type'      => 'checkbox',
    			'label'     => __('Scary Field', 'woocommerce'),
    			'class'     => array('form-row-wide'),
    			'clear'     => true,
    			'priority' => 90,
    			'options'     => array(),
    		);
    
         return $fields;
    }
    Thread Starter Piotr Po

    (@potreb)

    In my opinion this is not a solution, there are many plugins that use woocommerce_billing_fields. Why can’t I use woocommerce_billing_fields?

    • This reply was modified 4 years, 2 months ago by Piotr Po.
    Plugin Contributor Sanesh Acowebs

    (@saneshacodez)

    Hi, you can follow both ways, but we followed this hook for woocommerce documentation ( https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/#section-6 ) and altered with our plugin accordingly.

    Plugin Contributor Sanesh Acowebs

    (@saneshacodez)

    If you want that specific hook, then use like this:

    add_filter( 'woocommerce_billing_fields', 'custom_woocommerce_billing_fields', 20 );
    
    function custom_woocommerce_billing_fields( $fields ) {
    	$fields['custom_field'] = array(
    		'label' => 'Scary Field',
    		'type' => 'checkbox',
    		'class'     => array('form-row-wide'),
    		'priority' => 90,
    		'options'     => array(),
    	);
    
    	return $fields;
    }
    Plugin Contributor Sanesh Acowebs

    (@saneshacodez)

    As we haven’t heard back from you further, we assume that this issue has been resolved at your end and considering this ticket as closed. Please don’t hesitate to get back to us if you require any further assistance or clarifications from our end in the future. Thanks!

    Hello @potreb,
    Your error is related to REST API.
    The solution is to go to WordPress settings/Permalink, under Common Settings just choose any option but the default Plain.
    Hope this will be helpful to others who have the same issue.
    Regards

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Blank page in dashboard’ is closed to new replies.