Home Forums WC Vendors Pro Support Custom Fields in Settings Page

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 26 posts - 1 through 26 (of 26 total)
  • Author
    Posts
  • #15564
    Bharath23
    Participant

    Hello Ben,

    I am trying to add a custom field to capture the vendor’s bank details. The box appears but the data entered is not getting saved. After I click “save”, when I go back to the payment tab on the settings page, I cant see the data i entered.

    I used this code which you had shared with someone else –

    add_action(‘wcvendors_settings_after_paypal’, ‘pv_add_custom_bank_name_field’);
    function pv_add_custom_bank_name_field() {
    ?>
    <div class=”pv_bank_name_container”>
    <p><b><?php _e( ‘Bank Name’, ‘wc_product_vendor’ ); ?></b><br/>
    <?php _e( ‘Your Local Bank Name.’, ‘wc_product_vendor’ ); ?><br/>

    <input type=”text” name=”pv_bank_name” id=”pv_bank_name” placeholder=”First Bank” value=”<?php echo get_user_meta( get_current_user_id(), ‘pv_bank_name’, true ); ?>” />
    </p>
    </div>
    <?php
    }
    add_action( ‘wcvendors_admin_after_commission_due’, ‘pv_admin_user_info’ );
    function pv_admin_user_info( $user ) {
    ?>
    <tr>
    <th><label for=”pv_bank_name”><?php _e( ‘Bank Name’, ‘wc_product_vendor’ ); ?></label></th>
    <td><input type=”text” name=”pv_bank_name” id=”pv_bank_name” value=”<?php echo get_user_meta( $user->ID, ‘pv_bank_name’, true ); ?>” class=”regular-text”></td>
    </tr>
    <?php
    }
    add_action( ‘wcvendors_shop_settings_saved’, ‘pv_save_bank_name’ );
    add_action( ‘wcvendors_update_admin_user’, ‘pv_save_bank_name’ );
    function pv_save_bank_name( $user_id )
    {
    if ( isset( $_POST[‘pv_bank_name’] ) ) {
    update_user_meta( $user_id, ‘pv_bank_name’, $_POST[‘pv_bank_name’] );
    }
    }

    Please can you tell me if I am missing something. Thank you!

    Kind regards,
    Bharath

    #15580
    WC Vendors Support
    Participant

    Looks like those filters are missing in Pro that save the settings (wcvendors_update_admin_user & wcvendors_shop_settings_saved).

    Your code is good, it’s not you, it’s us. 🙂

    We’ll have this patched for v1.1.0 which is finishing up testing right now and prepping for release within 24 hrs. When you update to v1.1.0, it will work just fine.

    #15601
    Jamie
    Keymaster

    Hello,

    The above code is applicable to our free plugin, not the pro plugin. In pro as we don’t store information with the user, it is saved to the store which is its own post type. In our next release ANY custom field that starts with ‘_wcv_custom_settings_’ will automatically be saved to the database and you don’t have to hook into the action at all.

    This gist is the new way of doing things, create the new form input, have the id start with _wcv_custom_settings_ and everything else is created for you and saved for you.

    https://gist.github.com/digitalchild/9fe913cd140931a0cc6b

    If you do want to hook into the action for saving custom data on the store setting page you can call the following action:

    wcv_pro_store_settings_saved

    cheers,

    Jamie.

    #15815
    Sheldon
    Participant

    How I would save this information to the vendor store in the wp-admin?

    #16115
    CriterioNet
    Participant

    The site admin where you view the data in these new fields?

    #16135
    WC Vendors Support
    Participant

    I think Jamie would have to code in something to allow that to show up on the Vendor Store wp-admin listing. @digitalchild

    #16685
    Bharath23
    Participant

    Sorry Ben, can you help me with this?
    After the vendor has updated their bank details, I am not able to view it as the admin.

    Is there a way I can get this data?

    #16705
    WC Vendors Support
    Participant

    You make a good point. What good is saving it if you can not see it? @digitalchild will have to code this up.

    For now, install: https://wordpress.org/plugins/user-switching/ and go to wp-admin > users > vendors > hover over the vendor and “switch to” them. Then go to the Pro Dashboard and view the bank information.

    Ben

    #18468
    WC Vendors Support
    Participant

    I must have misunderstood this the first time I read it.

    If you add a custom field, and you use the KnowledgeBase article for it, you will see code in there that will make it show up on the users page. It’s up to you to code this, we cant just magically detect any custom fields you do use, and automatically show them. We’re good at PHP, but we aint Willy Wonka. 😉

    #18516
    CriterioNet
    Participant

    Hi @ben, you think then it will not be possible to show custom fields in admin panel?

    #18543
    WC Vendors Support
    Participant

    You can show any data anywhere you want. It’s just a matter of writing the code for it.

    #31472
    Xehon
    Participant

    Hello, is there a way to set up a mask on one of these new fields ?
    I mean, when user type his SWIFT or another specific code, it would be apropriate to avoid any typing mistake !

    #31491
    WC Vendors Support
    Participant

    There’s no masking in Pro, no…

    #31494
    Andy
    Participant

    Hi I had this working correctly for a while now and haven’t changed anything except replacing the code that goes into WCV > templates > dashboard > store-settings.php after the update being that to was overridden in 3.0.

    I have two custom fields for banking data placed within the “Payment Methods” tab underneath the PayPal address field, both fields including the entered data are still visible and when save is hit gives conformation, when I view the input data in the User’s account page again both fields are available but the second field is missing its data along with the string of code which was added in functions.php.

    See highlighted screenshots.

    Any help would be greatly appreciated.

    Andy

    functions.php
    /* WC Vendors Pro – My Custom Bank Fields */
    function store_bank_details( ){
    if ( class_exists( ‘WCVendors_Pro’ ) ){
    $key = ‘_wcv_custom_settings_bankname’;
    $value = get_user_meta( get_current_user_id(), $key, true );
    // Bank Name
    WCVendors_Pro_Form_Helper::input( array(
    ‘id’ => $key,
    ‘label’ => __( ‘Banküberweisung als Auszahlungs Methode Ihres Provision verwenden’, ‘wcvendors-pro’ ),
    ‘placeholder’ => __( ‘Bank Name’, ‘wcvendors-pro’ ),
    ‘desc_tip’ => ‘true’,
    ‘description’ => __( ‘Bankinstitut’, ‘wcvendors-pro’ ),
    ‘type’ => ‘text’,
    ‘value’ => $value,
    )
    );
    }
    }
    function store_iban_details( ){
    if ( class_exists( ‘WCVendors_Pro’ ) ){
    $key = ‘_wcv_custom_settings_ibanname’;
    $value = get_user_meta( get_current_user_id(), $key, true );
    // iban Name
    WCVendors_Pro_Form_Helper::input( array(
    ‘id’ => $key,
    ‘label’ => __( ‘IBAN Nummer bitte nicht vergessen’, ‘wcvendors-pro’ ),
    ‘placeholder’ => __( ‘IBAN NUMMER’, ‘wcvendors-pro’ ),
    ‘desc_tip’ => ‘true’,
    ‘description’ => __( ‘IBAN Nummer’, ‘wcvendors-pro’ ),
    ‘type’ => ‘text’,
    ‘value’ => $value,
    )
    );
    }
    }
    add_action( ‘wcvendors_admin_after_commission_due’, ‘wcv_store_bank_details_admin’ );
    function wcv_store_bank_details_admin( $user ) {
    ?>
    <tr>
    <th><label for=”_wcv_custom_settings_bankname”><?php _e( ‘Bank Name’, ‘wcvendors-pro’ ); ?></label></th>
    <td><input type=”text” name=”_wcv_custom_settings_bankname” id=”_wcv_custom_settings_bankname” value=”<?php echo get_user_meta( $user->ID, ‘_wcv_custom_settings_bankname’, true ); ?>” class=”regular-text”></td>
    </tr>
    add_action( ‘wcvendors_admin_after_store_bank_details’, ‘wcv_store_iban_details_admin’ );
    function wcv_store_iban_details_admin( $user ) {
    ?>
    <tr>
    <th><label for=”_wcv_custom_settings_iban”><?php _e( ‘IBAN NUMMER’, ‘wcvendors-pro’ ); ?></label></th>
    <td><input type=”text” name=”_wcv_custom_settings_iban” id=”_wcv_custom_settings_iban” value=”<?php echo get_user_meta( $user->ID, ‘_wcv_custom_settings_iban’, true ); ?>” class=”regular-text”></td>
    </tr>
    <?php
    }
    ?>

    • This reply was modified 6 years, 9 months ago by Andy.
    #31499
    WC Vendors Support
    Participant

    Andy: You did a crappy copy and paste job. 🙂

    https://www.wcvendors.com/members/ukstang/media/1090/ — The part in yellow? You forgot to begin the add_action line with <?php Without PHP open/close tags, it just outputs text. 🙂

    #31510
    Andy
    Participant

    Its always worked till yesterday after the 3.0 update, so I’m not too sure if your answer is correct 🙁
    I’m not saying you’re wrong with the <?php tags but I tried that and it just gives out an error. The code I am using (apart from the naming edits) is the same as the example in the Knowledge Base Pro #19.

    #31513
    WC Vendors Support
    Participant
    </tr>
    add_action( ‘wcvendors_admin_after_store_bank_details’, ‘wcv_store_iban_details_admin’ );
    function wcv_store_iban_details_admin( $user ) {
    ?>

    Should be:

    </tr>
    <?php
    add_action( 'wcvendors_admin_after_store_bank_details', 'wcv_store_iban_details_admin' );
    function wcv_store_iban_details_admin( $user ) {
    ?>

    Remember, you can also click the code tag in replies to make formatting code easier to read on the forums here. 😉

    #31541
    Andy
    Participant

    Hi Ben,

    as soon as I add the <?php function I get an error message… what I don’t get is that it was working fine before and also in singular mode it works correctly in 3.0 too, by singular mode I mean that I’m adding two fields “Bank” & “IBAN”. The bank field alone works fine without the <?php and even when the IBAn field is re-added too, its just that there after the IBAN outputs the code in the Admin User page, the IBAN field but without the data.

    I also tried your suggestion in the Storefront theme but had the same problem.

    #31570
    WC Vendors Support
    Participant

    @ukstang can you add the code you are using to gist.github.com and paste a link to it here? Since you arent formatting the code properly, it’s just an epic fail as far as reading it and the quotes and stuff. I’ll take a peek once you do!

    #31575
    Andy
    Participant
    #31583
    WC Vendors Support
    Participant

    Thanks. Now compare my version. You’ll see the problem. 🙂

    https://gist.github.com/bentasm1/f68212e0e7c0d0e13b6818623182d21c

    #31601
    Andy
    Participant

    Thanks Ben, what a difference a curley bracket can make but to be honest being a PHP NULL I tried placing exactly as you first described and thats what was causing the error.
    Now all is still not good and well because now that no error is visible it doesn’t save the IBAN field to the database at the Admin UserPage. I feel terrible asking but as I said it was all working how its was, before 3.0, I have data in fields from prior pseudo vendor accounts to prove it.
    So it saves the IBAN field on the Vendors settings page but not in the Admin Users page.

    #31655
    WC Vendors Support
    Participant

    That’s because you told the wp-admin screen to show it, but not to allow any edits to it. I’ve updated the code 2 posts up with the extra filters/functions to save the iban and bankname details when in wp-admin on the user edit screen. 😉

    #31671
    Andy
    Participant

    Hey Ben thanks for this I do appreciate it, very much so 🙂

    Now if only we could get cool whip in Austria my day would be complete 😉

    #40610
    James
    Participant

    HI, Ben, I still very new to wordpress, so I still confuse with the steps above. My problem still the same, wanna add some custom field like Andy in WC-Vendor Pro, and I have add the code you stated in my onesocial child theme, the code is as follow

    /* WC Vendors Pro – My Custom Bank Fields */
    function store_bank_details( ){
    if ( class_exists( ‘WCVendors_Pro’ ) ){
    $key = ‘_wcv_custom_settings_bankname’;
    $value = get_user_meta( get_current_user_id(), $key, true );
    // Bank Name
    WCVendors_Pro_Form_Helper::input( array(
    ‘id’ => $key,
    ‘label’ => __( ‘Banküberweisung als Auszahlungs Methode Ihres Provision verwenden’, ‘wcvendors-pro’ ),
    ‘placeholder’ => __( ‘Bank Name’, ‘wcvendors-pro’ ),
    ‘desc_tip’ => ‘true’,
    ‘description’ => __( ‘Bankinstitut’, ‘wcvendors-pro’ ),
    ‘type’ => ‘text’,
    ‘value’ => $value,
    )
    );
    }
    }
    function store_iban_details( ){
    if ( class_exists( ‘WCVendors_Pro’ ) ){
    $key = ‘_wcv_custom_settings_ibanname’;
    $value = get_user_meta( get_current_user_id(), $key, true );
    // iban Name
    WCVendors_Pro_Form_Helper::input( array(
    ‘id’ => $key,
    ‘label’ => __( ‘IBAN Nummer bitte nicht vergessen’, ‘wcvendors-pro’ ),
    ‘placeholder’ => __( ‘IBAN NUMMER’, ‘wcvendors-pro’ ),
    ‘desc_tip’ => ‘true’,
    ‘description’ => __( ‘IBAN Nummer’, ‘wcvendors-pro’ ),
    ‘type’ => ‘text’,
    ‘value’ => $value,
    )
    );
    }
    }

    add_action( ‘wcvendors_admin_after_commission_due’, ‘wcv_store_bank_details_admin’ );
    function wcv_store_bank_details_admin( $user ) {
    ?>
    <tr>
    <th><label for=”_wcv_custom_settings_bankname”><?php _e( ‘Bank Name’, ‘wcvendors-pro’ ); ?></label></th>
    <td><input type=”text” name=”_wcv_custom_settings_bankname” id=”_wcv_custom_settings_bankname” value=”<?php echo get_user_meta( $user->ID, ‘_wcv_custom_settings_bankname’, true ); ?>” class=”regular-text”></td>
    </tr>
    <?php
    }
    add_action( ‘wcvendors_admin_after_commission_due’, ‘wcv_store_iban_details_admin’ );
    function wcv_store_iban_details_admin( $user ) {
    ?>
    <tr>
    <th><label for=”_wcv_custom_settings_iban”><?php _e( ‘IBAN NUMMER’, ‘wcvendors-pro’ ); ?></label></th>
    <td><input type=”text” name=”_wcv_custom_settings_iban” id=”_wcv_custom_settings_iban” value=”<?php echo get_user_meta( $user->ID, ‘_wcv_custom_settings_iban’, true ); ?>” class=”regular-text”></td>
    </tr>
    <?php
    }
    // This saves the _wcv_custom_settings_iban when on the wp-admin > users > edit user screen
    add_action( ‘wcvendors_update_admin_user’, ‘iban_details_save’ );
    function iban_details_save( $user_id )
    {
    if ( isset( $_POST[‘_wcv_custom_settings_iban’] ) ) {
    update_user_meta( $user_id, ‘_wcv_custom_settings_iban’, $_POST[‘_wcv_custom_settings_iban’] );
    }
    }
    // And repeating this but with the next meta key
    add_action( ‘wcvendors_update_admin_user’, ‘bankname_details_save’ );
    function bankname_details_save( $user_id )
    {
    if ( isset( $_POST[‘_wcv_custom_settings_bankname’] ) ) {
    update_user_meta( $user_id, ‘_wcv_custom_settings_bankname’, $_POST[‘_wcv_custom_settings_bankname’] );
    }
    }

    Then, I aslo add this code, <?php store_bank_details( $key ); ?> (you can see in the photo below)
    to the store-settings.php in the following path, public_html/wp-content/themes/onesocial-child/wc-vendors-pro/templates/dashboard/store-settings.php,

    but no luck, in the seller profile, the payment still didnt show anything.

    Hope for your response

    #40615
    Anna
    Member
Viewing 26 posts - 1 through 26 (of 26 total)
  • The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.
This website uses cookies to ensure you get the best experience on our website.