Forum Replies Created

Viewing 15 replies - 1 through 15 (of 20 total)
  • Thread Starter aidba55

    (@aidba55)

    Hi Kris,

    Great, thanks.

    I have tried the latest code. It results in the text\”$default_val\” autofilling the fields unfortunately.

    I’ve pasted my code below just to ensure it’s correct.

    <?php 
    
    add_action( 'forminator_before_form_render', 'wpmudev_generate_acf_field_data', 10, 5 );
    function wpmudev_generate_acf_field_data( $id, $form_type, $post_id, $form_fields, $form_settings ){
    	if( $id == 114 ){
    		add_filter( 'forminator_field_text_markup', 'wpmudev_get_acf_field_prefilled', 10, 2 );
    	}
    }
    function wpmudev_get_acf_field_prefilled( $html, $field ){
    	if( !is_user_logged_in() ){
    		return $html;
    	}
    	$user_id = get_current_user_id();
    	$slug = $field['element_id'];
        $map_fields = array( 'text-7' => 'billing_city', 'text-8' => 'billing_state', 'text-9' => 'billing_postcode', 'text-10'=> 'billing_country', 'text-2' => 'billing_company', 'text-6' => 'billing_address_1', 'text-11' => 'billing_address_2' );
    	foreach( $map_fields as $key => $value ){
    		if( $slug == $key ){
    			if( strpos( $html, 'value=""' ) !== false ){
    				$default_val = get_user_meta( $user_id, $value, true );
    				if( $default_val ){
    					$html = str_replace( 'value=""', 'value=\"$default_val\"', $html );
    				}
    			}
    		}
    	}
    
    	return $html;
    }  

    Regards.

    Thread Starter aidba55

    (@aidba55)

    Thanks Patrick,

    Perfect, I can confirm it is working now. There is, however, still one small issue with regards to apostrophes in the field.

    The apostrophe causes the autofill to abruptly stop:

    e.g.
    billing_company: Mike’s Autoworks
    Autofill result: Mike

    <?php 
    
    add_action( 'forminator_before_form_render', 'wpmudev_generate_acf_field_data', 10, 5 );
    function wpmudev_generate_acf_field_data( $id, $form_type, $post_id, $form_fields, $form_settings ){
    	if( $id == 114 ){
    		add_filter( 'forminator_field_text_markup', 'wpmudev_get_acf_field_prefilled', 10, 2 );
    	}
    }
    function wpmudev_get_acf_field_prefilled( $html, $field ){
    	if( !is_user_logged_in() ){
    		return $html;
    	}
    	$user_id = get_current_user_id();
    	$slug = $field['element_id'];
        $map_fields = array( 'text-7' => 'billing_city', 'text-8' => 'billing_state', 'text-9' => 'billing_postcode', 'text-10'=> 'billing_country', 'text-2' => 'billing_company', 'text-6' => 'billing_address_1', 'text-11' => 'billing_address_2' );
    	foreach( $map_fields as $key => $value ){
    		if( $slug == $key ){
    			if( strpos( $html, 'value=""' ) !== false ){
    				$default_val = get_user_meta( $user_id, $value, true );
    				if( $default_val ){
    					$html = str_replace( 'value=""', "value='$default_val'", $html );
    				}
    			}
    		}
    	}
    
    	return $html;
    }                 
    
    
    Thread Starter aidba55

    (@aidba55)

    <?php 
    
    add_action( 'forminator_before_form_render', 'wpmudev_generate_acf_field_data', 10, 5 );
    function wpmudev_generate_acf_field_data( $id, $form_type, $post_id, $form_fields, $form_settings ){
    	if( $id == 114 ){
    		add_filter( 'forminator_field_text_markup', 'wpmudev_get_acf_field_prefilled', 10, 2 );
    	}
    }
    function wpmudev_get_acf_field_prefilled( $html, $field ){
    	if( !is_user_logged_in() ){
    		return $html;
    	}
    	$user_id = get_current_user_id();
    	$slug = $field['element_id'];
        $map_fields = array( 'text-7' => 'billing_city', 'text-8' => 'billing_state', 'text-9' => 'billing_postcode', 'text-10'=> 'billing_country', 'text-2' => 'billing_company', 'text-6' => 'billing_address_1', 'text-11' => 'billing_address_2' );
    	foreach( $map_fields as $key => $value ){
    		if( $slug == $key ){
    			if( strpos( $html, 'value=""' ) !== false ){
    				$default_val = get_user_meta( $user_id, $value, true );
    				if( $default_val ){
    					$html = str_replace( 'value=""', "value=$default_val", $html );
    				}
    			}
    		}
    	}
    
    	return $html;
    }                 
    
    Thread Starter aidba55

    (@aidba55)

    Hi Adam,

    I’ve just picked up one small bug. The autofill appears to only display one word.

    For example:

    billing_company: Mike’s Autoworks
    Autofill: Mike’s

    Only the first word appears in the field.

    Regards.

    Thread Starter aidba55

    (@aidba55)

    Hi Adam,

    I tracked the issue down to a bit of unrelated custom code that was causing a conflict.

    I can confirm all is working 100% now.

    Thanks again for your time and effort with this!

    Regards.

    Thread Starter aidba55

    (@aidba55)

    Hey Adam,

    Thank you very much for the time and effort put into this custom code.

    I have spent some time incorporating this code and it’s instructions. I am unable to get the autofill to work at this point in time. Currently the text field still sits empty.

    I do have some experience with Must-use plugins and can confirm that I have followed these instructions to the letter and ensured that all IDs and meta data are correctly setup. I have also made sure that the logged-in test user has these billing details already stored to ensure it works.

    Just to confirm, under the form’s “Behavior” and “Autofill” settings – the text fields in question have “Disable Autofill” as they’re default setting (not sure if this has any role to play in the autofill not working).

    Any further help would be appreciated.

    Thanks

    Thread Starter aidba55

    (@aidba55)

    Hi Patrick,

    Thanks for getting back to me.

    That’s correct – I am making use of regular text fields.

    The full list of WooCommerce data I’d like to have the ability to autofill:
    billing_company
    billing_address_1
    billing_address_2
    billing_city
    billing_postcode
    billing_country
    billing_state
    billing_email
    billing_phone

    Thank you.

    Thread Starter aidba55

    (@aidba55)

    Hi Kris,

    Perfect, thank you very much.

    Thread Starter aidba55

    (@aidba55)

    I’ve added an example below to better explain the issue.

    _____
    FIELD GROUP

    – Dropdown
    – – Option 1
    – – Option 2

    – Option 1 Field (Visibility Rule: if Dropdown is Option 1 – then display this)

    – Option 2 Field (Visibility Rule: if Dropdown is Option 2 – the display this)
    ______
    (Add item)

    If the user clicks on “Add Item” and a additional Field Group is added, the visibility rules from the first Field Group break the 2nd Field Group.

    For example – If I choose Option 2 from the Dropdown in the 1st Field Group, it will display correctly, however, once I’ve clicked “Add Item” and select Option 1 from the dropwdown in the 2nd Field Group the rule will not work and it is broken.

    Thread Starter aidba55

    (@aidba55)

    Hi Mikko,

    Thanks for the reply.

    Managed to resolve this issue. It was caused by some outdated CSS and not the plugin itself.

    Thanks

    Thread Starter aidba55

    (@aidba55)

    I just want to mention I have tried the alternative fix you uploaded here: https://drive.google.com/uc?export=download&id=19z0iF_HkFBfH5XYRTwxUuhRDFh2kU7vv

    This temporary fix plugin breaks the multi-currency abilities of the store. Customers are shown the incorrect currency and the gateway images disappear on checkout.

    Thread Starter aidba55

    (@aidba55)

    Hi Niklas,

    I have tracked this “Error processing checkout” bug down to customers who are purchasing an item using a currency that is not the shop default.

    Currently we can process the store default currency US dollar, however, we cannot process any other currencies.

    I must mention that we have been successful in processing numerous currencies before the latest update.

    Thread Starter aidba55

    (@aidba55)

    Hi David,

    Thanks for getting back to me.

    I’m unsure of which module is causing it. I was looking through my WooCommerce system report and the file was flagged as being outdated.

    Would you require a list of my activated modules?

    Thread Starter aidba55

    (@aidba55)

    Hi Niklas,

    Thanks for getting back to me.

    I have tried the recommended but it hasn’t helped.

    I was able to get some invaluable info from one customer who was experiencing this error. The customer experienced this error message on both the “debit or Credit Card” option and the “Paypal” option on checkout. They tried numerous cards and experienced the same issue across both Chrome and Safari.

    At the same time we were able to process a successful card transaction through the very same form on the checkout.

    We then disabled Woocommerce Paypal Payments and activated “PayPal Standard” gateway. The customer was able to immediately make a successful payment.

    This would suggest that the issue lies within the Woocommerce PayPal Payments plugin.

    We have since disabled this plugin until we can better understand this error and potentially re-activate once there is less risk involved in failed payments.

    Thanks

    Thread Starter aidba55

    (@aidba55)

    Hi Niklas,

    Thanks for getting back to me.

    I have looked into PayPal’s Card Processing in some depth, however, I don’t reside in one of the qualifying regions unfortunately.

    Will keep an eye on the performance and optimizations you have planned for Q1 though, looking forward to seeing their impact.

    Thanks.

Viewing 15 replies - 1 through 15 (of 20 total)