kluver
Forum Replies Created
-
Forum: Plugins
In reply to: [PDF Invoices & Packing Slips for WooCommerce] price after discountHi @dennisdepunt,
In WooCommerce there is difference between a discount and a sale price. It looks like you are trying to display the difference between the regular price and the sale price. This can be achieved with our Premium Templates extension (which you are already using judging by your screenshot?). More information on that here: https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/difference-between-sale-price-and-discount/
If you are indeed using our Premium Templates extension I would have to kindly ask you to direct further support questions to support@wpovernight.com. We are not allowed to give premium support on this forum.
Hi @alexqbox,
Yes you can check for the user role(s) with the following logic:
$user = $order->get_user(); if ( $user && ( in_array( 'b2b_kunde', (array) $user->roles ) ) ) { // Your code here... }Forum: Plugins
In reply to: [PDF Invoices & Packing Slips for WooCommerce] I need help editin the invoiceHi @gerard04,
It looks like the Woo Delivery plugin is storing the delivery data in the total rows for some reason. You can hide them in the totals table on your PDFs and add them to the order data table via the following code snippet:
add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_add_woo_delivery_data', 10, 2 ); function wpo_wcpdf_add_woo_delivery_data( $template_type, $order ) { $document = wcpdf_get_document( $template_type, $order ); $delivery_data = array( 'delivery_date', 'delivery_time', 'pickup_date', 'pickup_time' ); foreach( $document->get_woocommerce_totals() as $key => $total ) { if ( in_array( $key, $delivery_data ) ) { ?> <tr class="woo-delivery"> <th><?php echo $total['label']; ?></th> <td><?php echo $total['value']; ?></td> </tr> <style>table.totals tr.<?php echo $key; ?> { display: none; }</style> <?php } } }This code snippet should be added to the functions.php of your child theme or via a plugin like Code Snippets. If you haven’t worked with code snippets or functions.php before please read this: How to use filters
Hi @ckriegel
You can disable invoice creation for all orders that have products with the ‘donations’ category in them via the following code snippet:
add_filter( 'wpo_wcpdf_document_is_allowed', 'wpo_wcpdf_not_allow_invoice_for_certain_categories', 10, 2 ); function wpo_wcpdf_not_allow_invoice_for_certain_categories ( $condition, $document ) { if ( $document->type == 'invoice' ) { //Set categories here (comma separated) $not_allowed_cats = array( 'donations' ); $order_cats = array(); if ( $order = $document->order ) { //Get order categories foreach ( $order->get_items() as $item_id => $item ) { // get categories for item, requires product if ( $product = $item->get_product() ) { $id = $product->get_parent_id() ? $product->get_parent_id() : $product->get_id(); $terms = get_the_terms( $id, 'product_cat' ); if ( empty( $terms ) ) { continue; } else { foreach ( $terms as $key => $term ) { $order_cats[$term->term_id] = $term->slug; } } } } } // get array of category matches $cat_matches = array_intersect( $not_allowed_cats, $order_cats ); if ( count( $cat_matches ) > 0 ) { return false; // 1 or more matches: do not allow invoice } } return $condition; }This code snippet should be added to the functions.php of your child theme or via a plugin like Code Snippets. If you haven’t worked with code snippets or functions.php before please read the following guide: How to use filters
- This reply was modified 5 years, 3 months ago by kluver.
Forum: Plugins
In reply to: [PDF Invoices & Packing Slips for WooCommerce] Custom PDF filenameHi @nflor,
As mentioned in the documentation the easiest way would be with our Professional extension. This will let you change the filename right in the plugin settings using the {{order_number}} placeholder.
Having said that the second example code snippet can be slightly adjusted to give you the desired result:
add_filter( 'wpo_wcpdf_filename', 'wpo_wcpdf_custom_filename_including_order_number', 10, 4 ); function wpo_wcpdf_custom_filename_including_order_number( $filename, $template_type, $order_ids, $context ) { $invoice_string = _n( 'invoice', 'invoices', count( $order_ids ), 'woocommerce-pdf-invoices-packing-slips' ); $new_prefix = _n( 'business', 'businesses', count( $order_ids ), 'woocommerce-pdf-invoices-packing-slips' ); $new_filename = count( $order_ids ) > 1 ? str_replace( $invoice_string, $new_prefix, $filename ) : sprintf( '%s-%s', $new_prefix, $order_ids[0] ); return $new_filename; }Hi @madleine,
This only applies if you are running PHP 7.0 or older. As you can see here PHP 7.0 was ‘End of life’ on January 2019. That is why we stopped actively supporting it but we do offer a separate addon for users that really need to run an outdated version of PHP.
In your case, running PHP 7.4, you can update without any issues. And the update also adds support for the PHP 8.0 so you can even update your PHP version if you like to make your site even faster (although not all plugins in the WordPress ecosystem have active PHP 8.0 support, so be careful).
Hi @colibrijoven,
That’s unfortunate. Are you using a custom template and/or has anything changed in your setup recently? Also could you check if you are getting any specific errors via WooCommerce > Status > Logs. Check for log files starting with wpo_wcpdf_ that have a timestamp that corresponds with the time you’ve tried to create the PDF.
Hi @grafikx,
It looks like you’re dealing with a so called ‘race condition’ from time to time. This happens when the same process is triggered twice at exactly the same time. Because these two processes are doing the same thing in parallel, neither knows there is already an invoice number created. Resulting in two numbers for the same order.
Are the orders with double invoice numbers perhaps payed via PayPal? We have had some more issues with this in the past. See the following ticket: https://wordpress.org/support/topic/bug-skipped-invoice-numbers/#post-10436537
- This reply was modified 5 years, 3 months ago by kluver.
Hi @muleque,
There was a small typo in the code snippet of my colleague. Please try the following:
add_filter('wpo_wcpdf_document_is_allowed', function( $allowed, $document ) { if ( !empty( $order = $document->order ) && $document->get_type() == 'invoice' ) { $user = $order->get_user(); // based on user login if ( $user->user_login == 'some_username' ) { // replace with another user login name $allowed = false; } // based on user role if ( in_array( 'administrator', (array) $user->roles ) ) { // replace with another role $allowed = false; } } return $allowed; }, 10, 2 );Hi @nenosw,
You can check for the used payment method via:
$order->get_payment_method()So adding a due date on the invoice only for orders paid via direct bank transfer (BACS) would look something like this:
add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_due_date', 10, 2 ); function wpo_wcpdf_due_date ( $template_type, $order ) { if ( $template_type == 'invoice' && $order->get_payment_method() == 'bacs' ) { // put due date only on invoice and when payment method is bacs $invoice = wcpdf_get_invoice( $order ); if ( $invoice_date = $invoice->get_date() ) { $due_date = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date->date_i18n( 'Y-m-d H:i:s' ) . ' + 14 days' ) ); ?> <tr class="due-date"> <th>Due Date:</th> <td><?php echo $due_date; ?></td> </tr> <?php } } }- This reply was modified 5 years, 5 months ago by kluver.
[duplicate answer]
- This reply was modified 5 years, 5 months ago by kluver.
You can repeat the footer on every page by following this guide: Repeating headers and footers
You can then add the page numbers to the footer via the following code snippet:
add_filter( 'wpo_wcpdf_footer_settings_text', 'wpo_wcpdf_add_page_number_to_footer', 10, 2 ); function wpo_wcpdf_add_page_number_to_footer( $text, $document ) { $text .= '<div>Page {{PAGE_NUM}} / {{PAGE_COUNT}}</div>'; return $text; }This code snippet should be added to the functions.php of your child theme or via a plugin like Code Snippets. If you haven’t worked with function.php or code snippets before please read this guide: How to use filters
Hi @mohejazi,
Are you using our WooCommerce Order Proposal plugin? If so, I would have to kindly ask you to redirect your question to support@wpovernight.com as we are not allowed to give premium support on this forum.
Forum: Plugins
In reply to: [PDF Invoices & Packing Slips for WooCommerce] Cash on Delivery on invoicesHi @eowyn_86,
You can easily add custom text to your documents on specific places with a custom block. You get access to the custom blocks via our Premium Templates extension. And it is possible to only show the text for certain payment methods.
Please note it is not possible to add conditional custom text to the totals table via a custom block. But you can add your text for instance in the order data column (with the invoice number and date) or underneath the product table.
Forum: Plugins
In reply to: [PDF Invoices & Packing Slips for WooCommerce] separate invoices – Dokan ProHi @emyb,
Dokan provides a small plugin that makes it compatible with our PDF Invoices plugin: https://wordpress.org/plugins/dokan-invoice/
This should allow you to create invoices per vendor.