+function custom_woo_ce_scheduled_export_products_filter_by_custom_meta( $post_ID = 0 ) {
+ // This is the Product meta key we want to filter Products by
+ $meta_key = 'performance_date';
+ $custom_meta = get_post_meta( $post_ID, '_filter_product_custom_meta', true );
+<div class="export-options product-options">
+ <p class="form-field discount_type_field">
+ <label for="product_filter_custom_meta"><?php echo esc_attr( $meta_key ); ?></label></label>
+ <input type="text" id="product_filter_custom_meta" name="product_filter_custom_meta" value="<?php echo $custom_meta; ?>" size="5" class="text" />
+add_action( 'woo_ce_after_scheduled_export_type_options', 'custom_woo_ce_scheduled_export_products_filter_by_custom_meta' );
+function custom_woo_ce_scheduled_export_save_product_custom_meta( $post_ID = 0 ) {
+ // Save the Post meta value against the Scheduled Export
+ update_post_meta( $post_ID, '_filter_product_custom_meta', ( isset( $_POST['product_filter_custom_meta'] ) ? sanitize_text_field( $_POST['product_filter_custom_meta'] ) : false ) );
+add_action( 'woo_ce_extend_scheduled_export_save', 'custom_woo_ce_scheduled_export_save_product_custom_meta' );
+function custom_woo_ce_scheduled_export_get_products_args( $args ) {
+ // Check if this is a Export
+ if( !isset( $export ) )
+ // Check that this is a Scheduled Export
+ $scheduled_export = ( $export->scheduled_export ? absint( get_transient( WOO_CD_PREFIX . '_scheduled_export_id' ) ) : 0 );
+ if( empty( $scheduled_export ) )
+ // This is the Product meta key we want to filter Products by
+ $meta_key = 'performance_date';
+ $custom_meta = get_post_meta( $scheduled_export, '_filter_product_custom_meta', true );
+ if( !empty( $custom_meta ) ) {
+ // Check if $args['meta_query'] exists
+ if( !isset( $args['meta_query'] ) )
+ $args['meta_query'] = array();
+ $args['meta_query'][] = array(
+ 'value' => $custom_meta
+add_filter( 'woo_ce_get_products_args', 'custom_woo_ce_scheduled_export_get_products_args' );