Export filename
-
Hello,
I wonder is any option, to set up export filename with such information as:
Buyer Company name / or Buyer last name
I see it’s possible to set up some word and date as filename is any other option?
-
Hello
Please, put this code to “Misc Settings”
and you add use tags {bill_last_name} or {bill_company} to filename.Use button “Export w/o progressbar”.
thanks, Alex// add extra tags to filename, use button "Export w/o progressbar" add_filter('woe_make_filename_replacements',function($pairs) { $order = new WC_Order( WC_Order_Export_Engine::$order_id ); // LAST order! $pairs['{bill_last_name}'] = $order->get_billing_last_name(); $pairs['{bill_company}'] = $order->get_billing_company(); return $pairs; });Do you mean I should put this code at “Misc Settings” and after at “Custom PHP code to modify output” ?
yes
Unfortunately it’s not allow to put code, even if my role is administrator and allowed to “edit_themes”
Could you advice how I could resolve it?
Maybe it’s possible to use Code Snippets plug-in to do this?
you can just put it in functions.php
or yes, you can use mentioned plugin https://ww.wp.xz.cn/plugins/code-snippets/
Cool, it’s work perfectly. Is it also possible to use additional field as a filename such data as invoice number / or user role?
and VAT number, Thanks.
It depends on invoicing plugin.
but should looks like$pairs['{vat}'] = get_post_meta($order->get_id(),"field_VAT", true); $pairs['{invoice_date}'] = get_post_meta($order->get_id(),"field_Invoice_Date", true); ;Hi again,
I mean customer company VAT registration number, and Invoice No. Invoicing plugin WooCommerce PDF Invoices & Packing Slips (premium template)
meta key for invoice number, _wcpdf_invoice_number
meta key for VAT number, VAT Numberand also would be needed Customer Role.
Could you help with these fields export to Filename?
ok, here is final version
// add extra tags to filename, use button "Export w/o progressbar" add_filter('woe_make_filename_replacements',function($pairs) { if( !WC_Order_Export_Engine::$order_id ) return $pairs; $order = new WC_Order( WC_Order_Export_Engine::$order_id ); // LAST order! $pairs['{bill_last_name}'] = $order->get_billing_last_name(); $pairs['{bill_company}'] = $order->get_billing_company(); $pairs['{vat_number}'] = get_post_meta($order->get_id(), "VAT Number", true); $pairs['{invoice_number}'] = get_post_meta($order->get_id(), "_wcpdf_invoice_number", true); $user = $order->get_user(); $pairs['{user_role}'] = $user ? $user->roles[0] : 'guest'; return $pairs; });-
This reply was modified 7 years, 7 months ago by
algol.plus.
Cool, it’s work perfectly. Thank you, Great plug-in! Good luck
you’re welcome.
have a good weekend -
This reply was modified 7 years, 7 months ago by
The topic ‘Export filename’ is closed to new replies.