开发者 | baaaaas |
---|---|
更新时间 | 2021年10月13日 01:33 |
PHP版本: | 4.0 及以上 |
WordPress版本: | 5.8 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
Invoices for WooCommerce Premium This plugin offers a premium version which comes with the following features: - Attach PDF invoices to many more email types including third party plugins - Send credit notes and cancelled PDF invoices - Fully customize PDF invoice table content by modifying line item columns and total rows - Automatically send a reminder email configurable within a specific period of time and display a payment due date - Bulk generate PDF invoices - Bulk export and/or download PDF invoices - Bill periodically by generating and sending global invoices - Let customers decide to generate a PDF invoice on checkout - Change the font of the PDF invoices - Add additional PDF files to PDF invoices - Send customer invoices directly to multiple recipients - Compatible with WooCommerce Subscriptions plugin emails. Upgrade to Invoices for WooCommerce Premium >>
Copy the default template files (including folder) you'll find in plugins/woocommerce-pdf-invoices/includes/templates/invoice/simple
to uploads/woocommerce-pdf-invoices/templates/invoice/simple
. The plugin will automatically detect the template and makes it available for selection within the Template Settings. Now go ahead and start making some changes to the template files! :)
Important: Before you update the plugin, always have a look at the Changelog if their have been any changes to the template files. There will be updates that require updating your custom template!
To add a fee to WooCommerce and your invoice, simply add the following action to your themes functions.php
.
`
function add_woocommerce_fee() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
$amount = 5;
$woocommerce->cart->add_fee( 'FEE_NAME', $amount, true, 'standard' );
}
add_action( 'woocommerce_cart_calculate_fees','add_woocommerce_fee' );
`
To hide order item meta from the invoice, simply add the following filter to your themes functions.php
.
`
/**
To change the more common options of the PDF, use below example. ` function custom_bewpi_mpdf_options( $options ) { $options['mode'] = ''; $options['format'] = ''; // use [format]-L or [format]-P to force orientation (A4-L will be size A4 with landscape orientation) $options['default_font_size'] = 0; $options['default_font'] = 'opensans'; $options['margin_left'] = 14; $options['margin_right'] = 14; $options['margin_top'] = 14; $options['margin_bottom'] = 0; $options['margin_header'] = 14; $options['margin_footer'] = 6; $options['orientation'] = 'P'; // Also try to force with format option return $options; } add_filter( 'bewpi_mpdf_options', 'custom_bewpi_mpdf_options' ); `
To fully customize the PDF, use below code. This filter gives you full control over the mPDF library. Check the mPDF manual for more info. ` function bewpi_mpdf( $mpdf, $document ) { // change the direction of the invoice to RTL $mpdf->SetDirectionality( 'rtl' ); return $mpdf; } add_filter( 'bewpi_mpdf', 'bewpi_mpdf', 10, 2 ); `
Add below code for example to your "thankyou" page or "customer-completed-order" email template.
echo do_shortcode( '[bewpi-download-invoice title="Download (PDF) Invoice {formatted_invoice_number}" order_id="' . $order->get_id() . '"]' );
For use in WordPress editor use below shortcode. This will only work if you replace "ORDER_ID" with an actual order id.
[bewpi-download-invoice title="Download (PDF) Invoice {formatted_invoice_number}" order_id="ORDER_ID"]
Note: Download button will only be displayed when PDF exists and order has been paid.
Add the name of the payment method to the array.
function bewpi_attach_invoice_excluded_payment_methods( $payment_methods ) { return array( 'bacs', 'cod', 'cheque', 'paypal' ); } add_filter( 'bewpi_attach_invoice_excluded_payment_methods', 'bewpi_attach_invoice_excluded_payment_methods', 10, 2 );
Add below function to your themes 'functions.php' file. ` function bewpi_skip_invoice_generation( $skip, $status, $order ) { // Do your stuff based on the order. return true; // True to skip. } add_filter( 'bewpi_skip_invoice_generation', 'bewpi_skip_invoice_generation', 10, 3 ); `
Add the name of the role to the array. By default shop managers and administrators are allowed to download invoices.
function bewpi_allowed_roles_to_download_invoice($allowed_roles) { // available roles: shop_manager, customer, contributor, author, editor, administrator $allowed_roles[] = "editor"; // end so on.. return $allowed_roles; } add_filter( 'bewpi_allowed_roles_to_download_invoice', 'bewpi_allowed_roles_to_download_invoice', 10, 2 );
Add following filter function to your 'functions.php' within your theme. ` function alter_formatted_invoice_number( $formatted_invoice_number, $document_type ) { if ( $document_type === 'invoice/global' ) { // 'simple' or 'global'. // add M for global invoices. return 'M' . $formatted_invoice_number; } return $formatted_invoice_number; } add_filter( 'bewpi_formatted_invoice_number', 'alter_formatted_invoice_number', 10, 2 ); `
Use below code to display meta-data. Replace {META_KEY}
with the actual key. If you use another plugin, just ask the key from the author of that plugin.
`
templater()->get_meta( '{META_KEY}' ); ?>
`
Important: A custom template is required to add a custom field to the PDF invoice.
Use below code to use a different template based on WPML order language. You can for example change the function to use a different template based on the payment method instead. ` /**
Use below code to add invoice information meta to the PDF invoice template. ` /**
Use below filter to change the invoice date. ` /**
Since version 2.9.4 the plugin removed the ability to update the PDF invoice when it already has been sent to the customer. If in what manner you still want to update the invoice, you can do so by resetting a custom field. 1. Go to Edit Order page. 1. Change custom field 'bewpi_pdf_invoice_sent' value within custom field widget to 0. 1. Refresh page and Update button will appear.
WPI()->get_option()
. See Issue #190.get_order_number()
instead of get_id()
.<p>
and <br>
tags. Update custom template needed!