Customer Number in Invoice.pdf
-
Hi there,
I am an WP-Newbie and am building an Online-Shop for our customers, which order by telephone atm.
Customers shouldn’t be able to register themselves, only be added by an admin manually. Since we already have already customer numbers for each customer, we would like to keep them, and not use the ones wordpress is giving them automatically.
In the User->New User screen, I integrated a new “customer number” (“kundennummer” in German) field, with the following plugin:<?php /* Plugin Name: KUNDENNUMMER IN REGISTRATION FIELD Plugin URI: https://scriptbaker.com/adding-custom-fields-to-wordpress-user-profile-and-add-new-user-page/ Description: Plugin for adding a custom profile field to WordPress and on the registration page Author: Siehe Kommentare Version: 0.1 Author URI: */ /*-----Adding Additionnal User Informations-----*/ function custom_user_profile_fields($user){ if(is_object($user)) { $company = esc_attr( get_the_author_meta( 'kundennummer', $user->ID ) ); } else { $company = null; } ?> Kundennummer <input type="text" class="regular-text" name="kundennummer" value="<?php echo $company;?>" id="kundennummer" /> <?php } add_action( 'show_user_profile', 'custom_user_profile_fields' ); add_action( 'edit_user_profile', 'custom_user_profile_fields' ); add_action( "user_new_form", "custom_user_profile_fields" ); function save_custom_user_profile_fields($user_id){ # again do this only if you can if(!current_user_can('manage_options')) return false; # save my custom field update_user_meta($user_id, 'kundennummer', $_POST['kundennummer']); } add_action('user_register', 'save_custom_user_profile_fields'); ?>
Now I would like to see that customer number on my pdf invoice. My German market plugin has the following code for the content of the invoice:
<?php /** * Invoice Content * * @author Vendidero * @package WooCommerceGermanizedPro/Templates * @version 1.0 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly $newY = $pdf->getY(); ?> <?php if ( $invoice->get_option( 'address_margin_top' ) ) : ?> <?php $pdf->setTmpY( $pdf->getY() + $invoice->get_option( 'address_margin_top' ) ); ?> <?php endif; ?> <?php if ( $invoice->get_option( 'show_sender_address' ) == 'yes' ) : ?> <?php $pdf->writeCustomHTML( implode( ' - ', $invoice->get_sender_address() ), array( 'classes' => array( 'address-header' ) ) ); ?> <?php endif; ?> <?php if ( $invoice->get_address() ) : ?> <?php $pdf->writeCustomHTML( wpautop( $invoice->get_address() ), array( 'classes' => array( 'address' ) ) ); ?> <?php endif; ?> <?php $newY = $pdf->getY(); $pdf->resetTmpY(); ?> <?php if ( $invoice->get_option( 'show_sender_address_detail' ) == 'yes' ) : ?> <?php $pdf->writeCustomHTML( $invoice->get_template_content( $invoice->locate_template( 'info-right.php' ), $pdf ), array( 'classes' => array( 'address-header-detail' ), 'align' => 'R' ) ); ?> <?php endif; ?> <?php if ( $invoice->get_option( 'date_margin_top' ) ) : ?> <?php $pdf->setTmpY( $pdf->getY() + $invoice->get_option( 'date_margin_top' ) ); ?> <?php endif; ?> <?php $pdf->writeCustomHTML( wpautop( $invoice->get_date( $invoice->get_option( 'date_format' ) ) ), array( 'classes' => array( 'date' ), 'align' => 'R' ) ); ?> <?php $pdf->resetTmpY(); if ( $newY > $pdf->getY() ) $pdf->setXY( $pdf->getX(), $newY ); ?> <?php if ( $invoice->get_option( 'title_margin_top' ) ) : ?> <?php $pdf->setY( $pdf->getY() + $invoice->get_option( 'title_margin_top' ) ); ?> <?php endif; ?> <?php $pdf->writeCustomHTML( wpautop( $invoice->get_title_pdf() ), array( 'classes' => array( 'number' ) ) ); ?> <?php if ( $invoice->get_option( 'table_margin_top' ) ) : ?> <?php $pdf->setY( $pdf->getY() + $invoice->get_option( 'table_margin_top' ) ); ?> <?php endif; ?> <?php $pdf->writeCustomHTML( $invoice->get_template_content( $invoice->locate_template( 'table.php' ), $pdf ), array( 'classes' => array( 'table' ) ) ); ?>
I think I need a line, that prints me: “Customer Number: XXXX” before the invoice-table.
Does anyone have an idea? Help please…Best,
Ilke
- The topic ‘Customer Number in Invoice.pdf’ is closed to new replies.