Title: Conditional Field Export
Last modified: January 4, 2022

---

# Conditional Field Export

 *  Resolved [alortiz3](https://wordpress.org/support/users/alortiz3/)
 * (@alortiz3)
 * alortiz3
 * [4 years, 5 months ago](https://wordpress.org/support/topic/conditional-field-export/)
 * Hello,
 * We are currently running Advanced Order Export pro for WooCommerce. I would like
   to know if there is a way where I can export orders that match a specific criteria.
   Here is my current condition:
    We have a custom field called ‘Credit Limit’. 
   I would like to export all orders where the “total amount” of the order exceeds‘
   Credit Limit’. Is this possible with this plugin, and if so, how can I get it
   accomplished?
 * Cheers!

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

 *  Plugin Author [algol.plus](https://wordpress.org/support/users/algolplus/)
 * (@algolplus)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/conditional-field-export/#post-15218470)
 * hello
 * please, use hook woe_order_export_started
    visit [https://docs.algolplus.com/algol_order_export/filters-orders/](https://docs.algolplus.com/algol_order_export/filters-orders/)
   to check examples
 * you should add code to section “Misc Settings”
 * thanks, Alex
 *  Thread Starter [alortiz3](https://wordpress.org/support/users/alortiz3/)
 * (@alortiz3)
 * alortiz3
 * [4 years, 5 months ago](https://wordpress.org/support/topic/conditional-field-export/#post-15218653)
 * Thank you very much that worked very well!
 *  Plugin Author [algol.plus](https://wordpress.org/support/users/algolplus/)
 * (@algolplus)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/conditional-field-export/#post-15218694)
 * You’re very welcome 😉
 *  Thread Starter [alortiz3](https://wordpress.org/support/users/alortiz3/)
 * (@alortiz3)
 * alortiz3
 * [4 years, 5 months ago](https://wordpress.org/support/topic/conditional-field-export/#post-15225261)
 * I thought this was working but come to find out, I get the notification for every
   order regardless of condition. Here is my code:
 *     ```
       //  export only orders with total > Credit Limit
       add_filter( 'woe_order_export_started',  function ( $order_id ) { 
         $order = new WC_Order($order_id);
         return   ($order->get_total()  > $credit_limit) ? $order_id: false;
       });
       ```
   
 * Here is an example of the output:
    Order Number Order Status Order Date First
   Name (Billing) Last Name (Billing) Company (Billing) Email (Billing) Phone (Billing)
   Order Total Credit Limit 4333 Processing 2022-01-06 08:26 Amber Bainbridge Trans
   Equipment Co Inc [transequipleann@gmail.com](https://wordpress.org/support/topic/conditional-field-export/transequipleann@gmail.com?output_format=md)(
   717) 859-2095 239.40 3000 Attachments area
 * Your help is always greatly appreciated!
 *  Plugin Author [algol.plus](https://wordpress.org/support/users/algolplus/)
 * (@algolplus)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/conditional-field-export/#post-15225453)
 * what is $credit_limit ?
 * if it’s order field , use
    `$order->get_meta("credit_limit")`
 *  Thread Starter [alortiz3](https://wordpress.org/support/users/alortiz3/)
 * (@alortiz3)
 * alortiz3
 * [4 years, 5 months ago](https://wordpress.org/support/topic/conditional-field-export/#post-15225617)
 * Thank you for your prompt response. $credit_limit is a custom field (Credit Limit).
   I just need to make sure that I get notifications when the order amount that 
   is greater than the Credit Limit.
 *  Plugin Author [algol.plus](https://wordpress.org/support/users/algolplus/)
 * (@algolplus)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/conditional-field-export/#post-15225660)
 * You confused me, what plugin do you use to set Credit Limit?
 * Please, contact to plugin’s author . I think they know how to get this value 
   using PHP.
 *  Thread Starter [alortiz3](https://wordpress.org/support/users/alortiz3/)
 * (@alortiz3)
 * alortiz3
 * [4 years, 5 months ago](https://wordpress.org/support/topic/conditional-field-export/#post-15225689)
 * Very sorry, I used the plugin custom fields to create the Credit Limit. I can
   get the value in the results by using ‘User_credit_limit’. But I don’t know how
   to use it when comparing the value. I’m using this value: return ($order->get_total()
   > $credit_limit) ? $order_id: false;
 * Should I be using return ($order->get_total() > User_credit_limit) ? $order_id:
   false; instead?
 * Thank you!
 *  Plugin Author [algol.plus](https://wordpress.org/support/users/algolplus/)
 * (@algolplus)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/conditional-field-export/#post-15225836)
 * please, try this version
 *     ```
       //  export only orders with total > Credit Limit
       add_filter( 'woe_order_export_started',  function ( $order_id ) { 
         $order = new WC_Order($order_id);
         $credit_limit = get_user_meta($order->get_user_id(), "credit_limit", true);
         return   ($order->get_total()  > $credit_limit) ? $order_id: false;
       });
       ```
   
 *  Thread Starter [alortiz3](https://wordpress.org/support/users/alortiz3/)
 * (@alortiz3)
 * alortiz3
 * [4 years, 5 months ago](https://wordpress.org/support/topic/conditional-field-export/#post-15225949)
 * Thank very much! I will try it and let you know if I run into any issues.
 *  Plugin Author [algol.plus](https://wordpress.org/support/users/algolplus/)
 * (@algolplus)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/conditional-field-export/#post-15226912)
 * if you still have problem — please, submit your settings as new ticket to [https://algolplus.freshdesk.com/](https://algolplus.freshdesk.com/)
 * use tab Tools to get the settings.

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

The topic ‘Conditional Field Export’ is closed to new replies.

 * ![](https://ps.w.org/woo-order-export-lite/assets/icon-256x256.png?rev=1365554)
 * [Advanced Order Export For WooCommerce](https://wordpress.org/plugins/woo-order-export-lite/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woo-order-export-lite/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woo-order-export-lite/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-order-export-lite/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-order-export-lite/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-order-export-lite/reviews/)

 * 11 replies
 * 2 participants
 * Last reply from: [algol.plus](https://wordpress.org/support/users/algolplus/)
 * Last activity: [4 years, 5 months ago](https://wordpress.org/support/topic/conditional-field-export/#post-15226912)
 * Status: resolved