• Hello,

    I am trying to add the “VAT ID #” field from my Dokan vendor registration form (named: VAT ID) to show upon the Woocommerce PDF invoices (under the vendor’s address). I am trying to find proper action/filter hooks to achieve it, but having a bit of a difficult time.

    I am looking @ Hooks and Filters in WooCommerce PDF Invoice: https://docs.woocommerce.com/document/pdf-invoice-developer-tools/ but not sure which of these would help achieve what I am trying to do. I am not sure if this applies to me as I was told that “I need to fetch the data to the Dokan Invoice. The Dokan Invoice file dokan-invoice.php”

    Would I just apply the following in my functions.php file or dokan-invoice.php?

    add_filter( 'dokan_settings_form_bottom', 'extra_fields', 10, 2);
    
    function extra_fields( $current_user, $profile_info ){
    $VAT ID= isset( $profile_info['VAT ID'] ) ? $profile_info['VAT ID'] : '';
    ?>
     <div class="gregcustom dokan-form-group">
            <label class="dokan-w3 dokan-control-label" for="setting_address">
                <?php _e( 'VAT Number', 'dokan' ); ?>
            </label>
            <div class="dokan-w5">
                <input type="text" class="dokan-form-control input-md valid" name="VAT ID" id="reg_VAT ID" value="<?php echo $VAT ID; ?>" />
            </div>
        </div>
        <?php
    }
    
        //save the field value
    
    add_action( 'dokan_store_profile_saved', 'save_extra_fields', 15 );
    function save_extra_fields( $store_id ) {
        $dokan_settings = dokan_get_store_info($store_id);
        if ( isset( $_POST['VAT ID'] ) ) {
            $dokan_settings['VAT ID'] = $_POST['VAT ID'];
        }
     update_user_meta( $store_id, 'dokan_profile_settings', $dokan_settings );
    }
    
        // show on the store page
    
    add_action( 'dokan_store_header_info_fields', 'save_VAT ID', 10);
    
    function save_VAT ID($store_user){
    
        $store_info    = dokan_get_store_info( $store_user);
    
       ?>
            <?php if ( isset( $store_info['VAT ID'] ) && !empty( $store_info['VAT ID'] ) ) { ?>
                <i class="fa fa-globe"></i>
                <?php echo esc_html( $store_info['VAT ID'] ); ?>
        
        <?php } ?>
           
      <?php
    
    }

    Hope someone can help.
    Best,
    Chris

    • This topic was modified 3 years, 9 months ago by Lori Boone.
    • This topic was modified 3 years, 9 months ago by Lori Boone.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Hi Chris! ??

    It sounds like you have a valid subscription with us. If so, please contact us at WooCommerce.com > My Account > Support. You may need to create an account before you can access that page.

    Please include a link to this forum thread, so that we can keep track of what’s already been done.

    We will be able to help you further there. ??

    Thread Starter Lori Boone

    (@pleazo)

    hi @gabrielfuentes unfortunately I did not get any help from woocommerce.com as they said to contact Dokan (but I am using woocommerce pdf invoice). Dokan is not helping me with the action and now I am stuck ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding new field to Woocommerce PDF invoice’ is closed to new replies.