AliExpress Dropshipping forum - Save users input

  • Author
    Posts
  • Daniels
    Participant
    #13525

    Hi,

    There is an option “Allow adding new option”, it lets users add a new option to Autocomplete field, but I noticed that it doesn’t save that option so other users can later select it.
    Is there a way to save newly created options so they can later be shown to other users?

    Thanks,
    Daniels

    Admin
    Keymaster
    #13528

    Hello Daniel,

    Yes, you’re right, the new option will not be available for other users.
    But we could add such a behavior as a custom task.
    Please send a request to our support center if you’re interested.

    Thanks.

    James H
    Participant
    #13645

    Like Daniel I assumed that this was part of the logic.

    Has this since been added so that newly created options are stored for all users?

    James

    Daniels
    Participant
    #13646

    The support here isn’t very helpful.

    I couldn’t wait for them to add this option so i used a gravity forms hook to loop through all answers checking if its autocomplete field and if it is then save it somewhere where i need it.

    If you know something about coding here is my answer:

    /*Save new companies after successful form submission*/
    add_action( 'gform_after_submission', 'action_gform_after_submission', 10, 2 );
    function action_gform_after_submission( $entry, $form ) {
    
        $companies = getSurveyCompanies();
    
        $new_companies = array();
    
        foreach ( $form['fields'] as $field ) {
            if($field->get_input_type() == 'autocomplete'){
                $value = htmlspecialchars(rgar( $entry, (string) $field->id ));
    
                if($value){
                    $is_in_db = false;
    
                    if(strlen($value) > 170){
                        $value = substr($value,0, 170);
                    }
    
    
                    foreach ($companies as $company){
                        if($company->name == $value){
                            $is_in_db = true;
                            break;
                        }
                    }
    
                    if(!$is_in_db){
                        array_push($new_companies, $value);
                    }
                }
            }
        }
    
        if(!empty($new_companies)){
            foreach ($new_companies as $company){
                if(strlen($company) > 3){
                    addSurveyCompany($company);
                }
            }
        }
    }
    /*END Save new companies after successful form submission*/
    Admin
    Keymaster
    #13651

    Daniel,

    Thank you for sharing your code snippet.

  • You must be logged in to reply to this topic.

Turn Your Store Into

Cash Machine

Enter email and get FREE eBook with

best dropshipping tips for 2020

guide box

By entering your email, you agree to receive marketing

emails from Ali2woo. You can unsubscribe any time.

Thank you!

Check Your E-mail & Start Downloading

Thank you for your interest in our e-book. We’ve sent you an email with a download link - simply click it, and start downloading

Download our free ebook:

Turn Your Store Into Cash Machine