• Resolved mrjotd

    (@mrjotd)


    Hello,

    I am currently using the free version of this plugin with plans to upgrade to the paid version in time. I have a question regarding the custom field filtering.

    I want to use the plugin to export all orders that are expected to be delivered on that day, is there any way I can manipulate or add an extra select option for this custom field that will compare it to today’s date?

    Thank you

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

    (@algolplus)

    Hello

    1. you should select field in dropdwon, use operator “=”, type {today} and press button (+).
    so you will see condition “fieldname={today}”.

    2. add following code to section “Misc Settings”

    // replace  {today}  with actual values in settings
    add_filter('woe_settings_validate_defaults', function ($settings) {
    	$settings = json_encode($settings); // to string
    	$today = date("Y-m-d" , current_time( 'timestamp' ) );// TWEAK format!
    	$settings = str_replace( '{today}', $today, $settings);
    	$settings = json_decode($settings, true); // to array
    	return $settings;
    } );

    thanks, Alex

    Thread Starter mrjotd

    (@mrjotd)

    Hello,

    I have added the code to the ‘Misc Settings’ and tweaked the date to return as m/d/y as this is how I need it to be formatted, I also typed {today} in to the dropdown, this is not returning any results. When I test using a rendered value of the custom field the orders I expect to see appear however.

    Plugin Author algol.plus

    (@algolplus)

    Could you mark “enable debug output”( section “Misc Settings”) and press Preview ?

    Will you see some SQLs ? Could you paste them here ?

    • This reply was modified 7 years, 8 months ago by algol.plus.
    Thread Starter mrjotd

    (@mrjotd)

    Hello,

    This is the SQL I am seeing: SELECT ID AS order_id FROM wp_posts AS orders LEFT JOIN wp_postmeta AS ordermeta_cf_1 ON ordermeta_cf_1.post_id = orders.ID AND ordermeta_cf_1.meta_key=’byconsolewooodt_delivery_date’ WHERE orders.post_type in ( ‘shop_order’) AND 1 AND orders.post_status NOT in (‘auto-draft’,’trash’) AND ( ordermeta_cf_1.meta_value IN (’09/14/18′) ) AND orders.ID IN ( SELECT order_id FROM wp_woocommerce_order_items WHERE order_item_type=’shipping’ AND order_item_name IN (‘Flat Rate’) )

    Plugin Author algol.plus

    (@algolplus)

    it looks good.

    if you add field “byconsolewooodt_delivery_date” to export , do you see “09/14/18” ? or 9/14/18?

    thanks, Alex

    • This reply was modified 7 years, 8 months ago by algol.plus.
    Thread Starter mrjotd

    (@mrjotd)

    The output is showing as 09/14/2018 , I am gathering that it may just be an issue with how I have stated the date output?

    Thanks, Josh

    Thread Starter mrjotd

    (@mrjotd)

    Just changed my formatting and all is well!

    Thank you for your help Alex!

    Plugin Author algol.plus

    (@algolplus)

    you’re welcome, Josh.

    have a good weekend.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Add value to custom field filter’ is closed to new replies.