Home Forums WC Vendors Pro Support CUSTOM FIELDS ISSUE IN PRO

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 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #20034
    stardrive
    Participant

    Hello Ben,

    In the free version of WC Vendors plugin, the custom fields (Bank Name, Bank Account Number, Account Name) were successfully updated, saved and recalled from the database. But, since I installed the pro version of your plugin,the entered values of these custom fields can no more be stored in the database.

    Please, assist.

    See below the function I used to add the custom fields:

    // ADD CUSTOM FIELDS TO WC VENDORS PROFILE
    // ADD Bank Name Field to WC Vendors
    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=”Sample 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_bank_name_info’ );
    function pv_bank_name_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( get_current_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’] );
    }
    }

    // ====================================================================================================
    // ADD Bank Account Number Field to WC Vendors
    add_action(‘wcvendors_settings_after_paypal’, ‘pv_add_custom_bank_account_number_field’);
    function pv_add_custom_bank_account_number_field() {
    ?>
    <div class=”pv_bank_account_number_container”>
    <p><b><?php _e( ‘Bank Account Number’, ‘wc_product_vendor’ ); ?></b><br/>
    <?php _e( ‘Your 10 digit Account Number.’, ‘wc_product_vendor’ ); ?><br/>

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

    // ====================================================================================================
    // ADD Bank Account Name Field to WC Vendors
    add_action(‘wcvendors_settings_after_paypal’, ‘pv_add_custom_account_name_field’);
    function pv_add_custom_account_name_field() {
    ?>
    <div class=”pv_account_name_container”>
    <p><b><?php _e( ‘Account Name’, ‘wc_product_vendor’ ); ?></b><br/>
    <?php _e( ‘Your Account Name.’, ‘wc_product_vendor’ ); ?><br/>

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

    #20036
    WC Vendors Support
    Participant

    That code would work for WC Vendors Free, but not in Pro.

    For Pro:

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

    #20048
    stardrive
    Participant

    Thank you, Ben.

    From your response, I understand the following:

    1. I should place the first function to output the bank name in the functions.php file

    2. I should add the following on the store-settings.php template:
    <?php store_bank_details( $store_id ); ?>

    My questions are:

    3. Can I copy store-settings.php template to my child’s theme folder and place the function in #2 above in it?
    4. How do I create a custom field for the store settings page to output the other two fields: Account Number and Account Name?

    Kindly assist

    #20222
    stardrive
    Participant

    Hello Ben.

    Please, I am still expecting your response

    Regards,

    Stardrive

    #20232
    WC Vendors Support
    Participant

    1 & 2 are answered in the code pasted in my reply above.

    3 – Yes. 🙂 If you don’t copy the template, you would lose it when WC Vendors Pro updates. Always copy templates that you modify so they are “upgrade safe”. https://www.wcvendors.com/kb/changing-vendor-templates/

    4 – https://www.wcvendors.com/kb/custom-fields-to-shop-settings-page/

    #20236
    stardrive
    Participant

    Hello Ben,

    Thank you so much for your response.

    1 & 2. Please, in which position in the store-settings.php template should I add the following code?:
    <?php store_bank_details( $store_id ); ?>

    3. This is noted and understood.

    4. If I want to create a custom field for the store settings page to output the other two fields, Account Number and Account Name, I think I have to edit the program lines I added “–EDIT–” below. (For instance, to create Account Name custom field, I can replace every occurrence of “Bank” below with “Account”). Please, confirm if I am correct.

    –EDIT– function store_bank_details( $store_id ){

    if ( class_exists( ‘WCVendors_Pro’ ) ){

    // Bank Name
    WCVendors_Pro_Form_Helper::input( array(
    ‘post_id’ => $store_id,
    –EDIT– ‘id’ => ‘_wcv_custom_settings_bankname’,
    –EDIT– ‘label’ => __( ‘Bank Name’, ‘wcvendors-pro’ ),
    –EDIT– ‘placeholder’ => __( ‘First Bank’, ‘wcvendors-pro’ ),
    ‘desc_tip’ => ‘true’,
    –EDIT– ‘description’ => __( ‘Your local bank name’, ‘wcvendors-pro’ ),
    ‘type’ => ‘text’,
    )
    );
    }
    }
    ?>

    <?php // Add the following on the store-settings.php template ?>

    –EDIT– <?php store_bank_details( $store_id ); ?>

    #20253
    WC Vendors Support
    Participant

    1&2 — You would place that code where you want it to display on the template. 🙂 It’s like editing a HTML file. Wherever you add the text is where it shows up on the page. Same with templates. Experiment and try it.

    3 — Correct! As long as the “_wcv_custom_settings_bankname” is unique, all will be well. If you use the same meta key twice, then they will clash and overwrite each other.

    #20254
    stardrive
    Participant

    Thank you so much, Ben, for your excellent support and good customer care.

    I will do as you advised and revert back

    Regards,

    Stardrive.

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.