How to customize export page template and filters

How to update template using hooks

Available Template Hooks:
wpcie_frontend_before_export_form_field – this hook used to add section/content at the beginning of the export form.
wpcie_frontend_middle_export_form_field – this hook used to add section/content at middle of the export form.
wpcie_frontend_after_export_form_field – this hook is used to add section/content at the end of the export form.

Sample Code (In this example you will add pickup date as custom export filter)

//Add field for custom export filter
function wpcargo_custom_export_field(){ 

// In this sample code we added pikup date field with a name attribute of "wpcargo_pickup_date_picker"
// Note: wpcargo_pickup_date_picker is the meta key for this field?>
    <section class="form-group">
        <div class="md-form">
            <input placeholder="<?php _e('YYYY-MM-DD', 'wpc-import-export'); ?>" type="text" id="pickup_date" name="wpcargo_pickup_date_picker" class="form-control wpccf-datepicker _group-data">
            <label for="pickup_date"><?php _e( 'Pickup Date', 'wpc-import-export' ); ?></label>
        </div>
    </section>
<?php
}

add_action('wpcie_frontend_after_export_form_field', 'wpcargo_custom_export_field');

After adding the custom field in the form, It needs to add filter for export  meta query to make the custom field data added on the query parameter using the ff. hooks:

wpcie_get_shipments_sql_filter_table 

wpcie_get_shipments_sql_filter_data

wpcie_get_shipments_sql_filter_parameter

Sample Code

// Copy this sample filter hook in your theme functions.php file
// Note: Here we filter wpcargo_pickup_date_picker name attribute from added fields in the template</pre>

function wpccustom_wpcie_sql_users_filter_table($sql, $data){
  global $wpdb;
  if( array_key_exists( 'wpcargo_pickup_date_picker', $data) && !empty($data['wpcargo_pickup_date_picker']) ){
    $sql .= " LEFT JOIN {$wpdb->postmeta} AS tblcont ON tblposts.ID = tblcont.post_id";
  }
  return $sql;
}

function wpccustom_wpcie_sql_users_filter_data($sql, $data){
  if( array_key_exists( 'wpcargo_pickup_date_picker', $data) && !empty($data['wpcargo_pickup_date_picker']) ){
    $sql .= " AND tblcont.meta_key = %s AND tblcont.meta_value = %s";
  }
  return $sql;
}

function wpccustom_wpcie_sql_users_filter_parameter($params, $data){
  if( array_key_exists( 'wpcargo_pickup_date_picker', $data) && !empty($data['wpcargo_pickup_date_picker']) ){
    $params[] = 'wpcargo_pickup_date_picker'; // assuming that the metakey for the shipment's pickup date is "wpcargo_pickup_date_picker"
    $params[] = $data['wpcargo_pickup_date_picker']; // this will be the value of the custom date filter on your export dashboard
  }
  return $params;
}
add_filter('wpcie_get_shipments_sql_filter_table', 'wpccustom_wpcie_sql_users_filter_table', 100, 2);
add_filter('wpcie_get_shipments_sql_filter_data', 'wpccustom_wpcie_sql_users_filter_data', 100, 2);
add_filter('wpcie_get_shipments_sql_filter_parameter', 'wpccustom_wpcie_sql_users_filter_parameter', 100, 2);
0
    0
    Your Cart
    Your cart is emptyReturn to Shop