Support » Plugin: Advanced Order Export For WooCommerce » Export filename

  • Resolved orderbot

    (@orderbot)


    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?

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author algol.plus

    (@algolplus)

    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” ?

    Plugin Author algol.plus

    (@algolplus)

    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?

    Plugin Author algol.plus

    (@algolplus)

    you can just put it in functions.php

    Plugin Author algol.plus

    (@algolplus)

    or yes, you can use mentioned plugin https://wordpress.org/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.

    Plugin Author algol.plus

    (@algolplus)

    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 Number

    and also would be needed Customer Role.

    Could you help with these fields export to Filename?

    Plugin Author algol.plus

    (@algolplus)

    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 months, 3 weeks ago by  algol.plus.

    Cool, it’s work perfectly. Thank you, Great plug-in! Good luck

    Plugin Author algol.plus

    (@algolplus)

    you’re welcome.
    have a good weekend

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Export filename’ is closed to new replies.