• Resolved sylvain68

    (@sylvain68)


    Hi again!

    I was asking myself if it was possible to export orders with ‘post_type’ like ‘shop_order_refund’?

    It seems that only orders with post_type ‘shop_order’ are retrieved during export, so only the ‘post_parent’ orders in fact.

    Actually, I would like to export information on credit notes (PDF Invoices & Packing Slips plugin). But as you know, there may be several refunds for one order and I would like to have one refund, so one credit note, per ligne in the export file.

    Here is an example of a desired line:
    _wcpdf_credit_note_number, _wcpdf_credit_note_date_formatted, _order_total

    Moreover, I need to filter the results by month (of the refund) :
    Example: ‘_wcpdf_credit_note_date_formatted LIKE 2019-07’

    Thank you in advance for your feedback and have a nice end of day!

    Kind Regards,
    Sylvain

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

    (@algolplus)

    hi Sylvain

    You can temporary put this code in functions.php. and the plugin should export only refunds (not orders).
    don’t forget to remove this code — it affects to ALL export jobs!!
    thanks, Alex

    add_action(‘admin_init’, function($statuses){
    WC_Order_Export_Data_Extractor_UI::$object_type=’shop_order_refund’;
    WC_Order_Export_Data_Extractor::$object_type=’shop_order_refund’;
    } );

    Thread Starter sylvain68

    (@sylvain68)

    Wow! Thank you very much ??!

    If only we could have an option to modify the type of object processed (‘shop_order’,’shop_order_refund’,…) in each export profile, it would just be a dream!

    For information, the function in snippet must be arranged as follows otherwise credit note data are not retrieved:

    
    add_filter('woe_get_order_value_credit_note_number', 'woe_get_credit_note_field', 10, 3);
    add_filter('woe_get_order_value_credit_note_date', 'woe_get_credit_note_field', 10, 3);
    add_filter('woe_get_order_value_credit_note_date_formatted', 'woe_get_credit_note_field', 10, 3);
    function woe_get_credit_note_field($value,$order, $field) {
        $value = $order->get_meta('_wcpdf_'.$field);
    	return $value;
    }

    Just one weird thing, if I filter the commands as follows, I don’t get any results?
    ‘_wcpdf_credit_note_date_formatted LIKE 2019-06’

    Even with the full 2019 year… and even if I select the ‘=’ (equal) operator with a specific credit note date formatted…

    Could you please test it on your side?

    Thank you again!

    Plugin Author algol.plus

    (@algolplus)

    hi Sylvain

    could you submit another ticket to helpdesk ?
    we’ll provide beta next week and add hook for profile type.

    please, turn on ‘enable debug output’ in ‘misc settings’ and debug SQL.
    probably, you have to use %2019%

    thanks, Alex

    Thread Starter sylvain68

    (@sylvain68)

    Hi Alex,

    Great! Yes sure, I will open a ticket.

    Debug output is already enabled in misc settings. No customized PHP code in my test profile for credit notes and no error. Export file is well created with column headers but no refund data is retrieved (it works without filter).

    For information I use your “Filter by order > custom fields” option on the right pane which has always worked without the need to use the wildcard ‘%’. So ‘_wcpdf_invoice_date_formatted LIKE 2019-06’ works in ‘shop_order’ mode. But not ‘_wcpdf_credit_note_date_formatted LIKE 2019-06’ in ‘shop_order_refund’ mode.

    Are you sure that the filtering rules apply to refund and not order objects?

    Thank you in advance and have a nice day!

    Kind Regards,
    Sylvain

    Thread Starter sylvain68

    (@sylvain68)

    Sorry! I didn’t think to use the preview function…

    Okay the filter works!

    But the problem comes from the sorting:
    If you sort by “_wcpdf_credit_note_date_formatted” for example, there is no more result.

    Thread Starter sylvain68

    (@sylvain68)

    I close this topic since you provided me the following code to place in the misc settings:

    add_filter("woe_settings_validate_defaults", function($settings){
     WC_Order_Export_Data_Extractor_UI::$object_type="shop_order_refund";
     WC_Order_Export_Data_Extractor::$object_type="shop_order_refund";
     $settings['skip_refunded_items'] = 0;
    return $settings;
    } );

    Thank you again Alex.

    Kind Regards,
    Sylvain

    Plugin Author algol.plus

    (@algolplus)

    you’re welcome.
    but it’s partial solution

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Export orders like ‘shop_order_refund’, possible?’ is closed to new replies.