Skip to content

Instantly share code, notes, and snippets.

@SubCon
Created March 26, 2017 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SubCon/a628e596e85d6ba3685258caef971e0a to your computer and use it in GitHub Desktop.
Save SubCon/a628e596e85d6ba3685258caef971e0a to your computer and use it in GitHub Desktop.
<?php
add_action( 'woo_ce_before_scheduled_export_general_options', 'alo_general_options_sced', 10, 1);
function alo_general_options_sced($post_ID) {
$product_orderby = get_post_meta( $post_ID, '_product_orderby', true );
// Default to Ascending
if( $product_orderby == false ) {
$product_orderby = 'title';
}
ob_start(); ?>
<div class="options_group">
<p class="form-field discount_type_field">
<label for="product_orderby"><?php _e( 'Product Sorting', 'woocommerce-exporter' ); ?></label>
<select id="product_orderby" name="product_orderby">
<option value="ID"<?php selected( 'ID', $product_orderby ); ?>><?php _e( 'Product ID', 'woocommerce-exporter' ); ?></option>
<option value="title"<?php selected( 'title', $product_orderby ); ?>><?php _e( 'Product Name', 'woocommerce-exporter' ); ?></option>
<option value="sku"<?php selected( 'sku', $product_orderby ); ?>><?php _e( 'Product SKU', 'woocommerce-exporter' ); ?></option>
<option value="date"<?php selected( 'date', $product_orderby ); ?>><?php _e( 'Date Created', 'woocommerce-exporter' ); ?></option>
<option value="modified"<?php selected( 'modified', $product_orderby ); ?>><?php _e( 'Date Modified', 'woocommerce-exporter' ); ?></option>
<option value="rand"<?php selected( 'rand', $product_orderby ); ?>><?php _e( 'Random', 'woocommerce-exporter' ); ?></option>
<option value="menu_order"<?php selected( 'menu_order', $product_orderby ); ?>><?php _e( 'Sort Order', 'woocommerce-exporter' ); ?></option>
</select>
</p>
</div>
<!-- .options_group -->
<?php
ob_end_flush();
}
add_action( 'woo_ce_extend_scheduled_export_save', 'alo_filter_sced_save' );
function alo_filter_sced_save($post_ID) {
update_post_meta( $post_ID, '_product_orderby', sanitize_text_field( $_POST['product_orderby'] ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment