Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter sammzand

    (@sammzand)

    Any help regarding this issue..

    Plugin Contributor Ewout

    (@pomegranate)

    Hi!
    The PHP code from that documentation page is broken (it was probably partially parsed at some point), so I can’t really tell much from it. I also don’t know whether this is stored in the WP user profile or the order data. I recommend contacting Dokan support about this, and refer to the PDF template action hooks documentation.
    There’s also some pointers on how to get user data in this thread: Add User Profile Custom Data to PDF Invoice. Note that this is user data from the buyer, not the seller, so I’m not sure that’s what you need.
    Again, Dokan support is probably in a much better position to help here!

    Ewout

    Thread Starter sammzand

    (@sammzand)

    Thanks for the feedback..I have placed it to dokan guys but they didn’t respond.Your plugin is already fetching order related buyer information and that is enough.Dokan invoice plugin fetch only seller related information.The above dokan code in link add 4 extra field in dokan store page and user profile.Perhaps,I have done some coding and need your help to hook it in invoice kindly guide me..

    I found dokan invoice plugin used add_filter to replace or add more info to your present variables shop_name and shop_address of seller but they don’t have any action hook to hook any fetched data..I saw you have

    <?php do_action( 'wpo_wcpdf_after_document_label', $wpo_wcpdf->export->template_type, $wpo_wcpdf->export->order ); ?>

    which means it accepts 2 arguments.

    But,I have added this in dokan invoice plugin and trying to fetch text field 1 which is company name here:

    /**
         * Filter Company name
         * 
         * @since 1.1
         * 
         * @global type $wpo_wcpdf
         * 
         * @param type $company_name
         * 
         * @return string $company_name
         */
        function wpo_wcpdf_add_dokan_billing_city( $company_name ) {
    
            global $wpo_wcpdf;
            // If parent order keep Original Store name else set seller store name
            if ( $wpo_wcpdf->export->order->post->post_parent == 0 ) {
    
                if ( function_exists( 'dokan_get_seller_ids_by' ) ) {
    
                    $seller_list = dokan_get_seller_ids_by( $wpo_wcpdf->export->order->id );
    
                } else {
    
                    $seller_list = array_unique( array_keys( dokan_get_sellers_by( $wpo_wcpdf->export->order->id ) ) );
    
                }
    
                if ( count( $seller_list ) > 1 ) {
    
                    return $company_name;
    
                } else {
    
                    $seller_id  = $seller_list[0];
    
                    $store_info = dokan_get_store_info( $seller_id );
    
                    $company_name = !empty( $store_info['company_name'] ) ? $store_info['company_name'] : __( 'store_info', 'dokan-invoice' );
    
                    return $company_name . '<br /><br />Company Name: ' . $company_name;
                }
    
            } else {
    
                $seller_id  = $wpo_wcpdf->export->order->post->post_author;
                
                $store_info = dokan_get_store_info( $seller_id );
    
                $company_name = !empty( $store_info['company_name'] ) ? $store_info['company_name'] : __( 'store_info', 'dokan-invoice' );
    
                return $company_name . '<br /><br />Company Name: ' . $company_name;
            }
        }

    As an action hook I am using

    add_action( 'wpo_wcpdf_after_document_label', array( $this,'wpo_wcpdf_add_dokan_billing_city'), 10, 1 );

    I think the above code cannot fetch the company name in invoice as it does not match with the function format you mentioned in your documentation.

    Kindly provide me the right hook statement so that I can make company name appear in invoice..

    Plugin Contributor Ewout

    (@pomegranate)

    I am sorry to tell you that this is beyond support for the free plugin.
    You are right that the arguments don’t match, the wpo_wcpdf_add_dokan_billing_city function takes the $company_name variable whereas the $wpo_wcpdf_after_document_label filter passes template_type and $order. You will need to extra the company name from the order yourself.

    Good luck!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘show additional fields in invoice’ is closed to new replies.