Title: Small error in code
Last modified: October 24, 2017

---

# Small error in code

 *  [dkvadratu](https://wordpress.org/support/users/dkvadratu/)
 * (@dkvadratu)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/small-error-in-code/)
 * After installing plugin, it throws error(if DEBUG enabled):
 * `Notice: Undefined index: post_type in /.../public_html/wp-content/plugins/woo-
   orders-date-range-filter/woo-orders-date-range-filter.php on line 169`
 * This problem occurs on pages that doesn’t have GET[‘post_type’] in url, because
   code tries to compare(AND) with undefined($post_type) value:
 *     ```
       $post_type = sanitize_text_field($_GET['post_type']);
       if (!isset($_GET['post_type']) && $post_type !='shop_order') {
       return false;
       }
       ```
   
 * I have changed compare type to OR and problem solved when there’s no $post_type
   at all:
 *     ```
       $post_type = sanitize_text_field($_GET['post_type']);
       if (!isset($_GET['post_type']) || $post_type !='shop_order') { //changed from && to 
       return false;
       }
       ```
   
 * Reply me if I’m not right 🙂 and of course thanks for great plugin!
    -  This topic was modified 8 years, 7 months ago by [dkvadratu](https://wordpress.org/support/users/dkvadratu/).

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

 *  Thread Starter [dkvadratu](https://wordpress.org/support/users/dkvadratu/)
 * (@dkvadratu)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/small-error-in-code/#post-9619257)
 * Ups. Yesterdays night(tired) code really doesn’t help, so changed today to this:
 *     ```
       if ( isset($_GET['post_type']) ){
   
       	$post_type = sanitize_text_field($_GET['post_type']);
   
       	if( $post_type !='shop_order' ) {
       		return false;
       	}
   
       }else{
       	return false;
       }
       ```
   
    -  This reply was modified 8 years, 7 months ago by [dkvadratu](https://wordpress.org/support/users/dkvadratu/).
 *  [btetrault](https://wordpress.org/support/users/btetrault/)
 * (@btetrault)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/small-error-in-code/#post-9757305)
 * Hello,
 * I’m also loving this plugin but am getting the same PHP error from line 169.
 * [@dkvadratu](https://wordpress.org/support/users/dkvadratu/) – your updated code
   worked to remove the PHP error, however it then added the plugin functionality
   to the WooCommerce product admin page as well–which is really badly formatted,
   and also not really needed.
 * Any thoughts/ideas on how to fix that would be awesome! Thanks!
 *  Thread Starter [dkvadratu](https://wordpress.org/support/users/dkvadratu/)
 * (@dkvadratu)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/small-error-in-code/#post-9757560)
 * Hi [@btetrault](https://wordpress.org/support/users/btetrault/),
 * I have checked again, because of interest 🙂 my code change works as it should:
   disables load of CSS and JS files.
 * But, after your comment I’ve noticed that these fields appear also on products
   page. I’ve looked to code again and saw that these fields are created by other
   function `woo_order_add_filterby_daterange_select`
 * Again there is the same problem(but with no error throw, hmm). Make same code
   replace in 26-29 lines on the same file and its gone 🙂
 * I hope i explained this clearly, Cheers!
 *  [btetrault](https://wordpress.org/support/users/btetrault/)
 * (@btetrault)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/small-error-in-code/#post-9757648)
 * Makes total sense [@dkvadratu](https://wordpress.org/support/users/dkvadratu/),
 * The same change on lines 26-29 seemed to have done the trick.
 * Thanks for your interest in keeping this code updated! So useful!

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

The topic ‘Small error in code’ is closed to new replies.

 * ![](https://ps.w.org/woo-orders-date-range-filter/assets/icon-256x256.png?rev
   =1636762)
 * [Woo Orders date range filter](https://wordpress.org/plugins/woo-orders-date-range-filter/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woo-orders-date-range-filter/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woo-orders-date-range-filter/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-orders-date-range-filter/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-orders-date-range-filter/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-orders-date-range-filter/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [btetrault](https://wordpress.org/support/users/btetrault/)
 * Last activity: [8 years, 6 months ago](https://wordpress.org/support/topic/small-error-in-code/#post-9757648)
 * Status: not resolved