• 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 6 years, 8 months ago by dkvadratu.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter dkvadratu

    (@dkvadratu)

    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 6 years, 8 months ago by dkvadratu.

    Hello,

    I’m also loving this plugin but am getting the same PHP error from line 169.

    @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

    (@dkvadratu)

    Hi @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!

    Makes total sense @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.