Title: PHP Warning
Last modified: November 22, 2016

---

# PHP Warning

 *  [derekakelly](https://wordpress.org/support/users/derekakelly/)
 * (@derekakelly)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/php-warning-100/)
 * I’m working to debug a problem I’m having with the subscriptions plugin. So I’ve
   enabled wordpress debugging. This came up in my log overnight.
 * [22-Nov-2016 09:36:32 UTC] PHP Warning: Invalid argument supplied for foreach()
   in /home/xxxx/public_html/wp-content/plugins/woocommerce/includes/wc-template-
   functions.php on line 211

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

 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/php-warning-100/#post-8470345)
 * My line 211 doesn’t have a foreach(), are you using the latest version of WC?
   I’ve got 2.6.8.
 *  Thread Starter [derekakelly](https://wordpress.org/support/users/derekakelly/)
 * (@derekakelly)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/php-warning-100/#post-8470475)
 * Here is the code directly from my website
 *     ```
       function wc_body_class( $classes ) {
       	$classes = (array) $classes;
   
       	if ( is_woocommerce() ) {
       		$classes[] = 'woocommerce';
       		$classes[] = 'woocommerce-page';
       	}
   
       	elseif ( is_checkout() ) {
       		$classes[] = 'woocommerce-checkout';
       		$classes[] = 'woocommerce-page';
       	}
   
       	elseif ( is_cart() ) {
       		$classes[] = 'woocommerce-cart';
       		$classes[] = 'woocommerce-page';
       	}
   
       	elseif ( is_account_page() ) {
       		$classes[] = 'woocommerce-account';
       		$classes[] = 'woocommerce-page';   <--------- line 211
       	}
   
       	if ( is_store_notice_showing() ) {
       		$classes[] = 'woocommerce-demo-store';
       	}
   
       	foreach ( WC()->query->query_vars as $key => $value ) {
       		if ( is_wc_endpoint_url( $key ) ) {
       			$classes[] = 'woocommerce-' . sanitize_html_class( $key );
       		}
       	}
   
       	return array_unique( $classes );
       }
       ```
   
 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/php-warning-100/#post-8470673)
 * Looks like what I have, but I wonder if you have an older version of WooCommerce
   there could be a change somewhere else. Do you have v 2.6.8, if not, consider
   updating.
 *  Thread Starter [derekakelly](https://wordpress.org/support/users/derekakelly/)
 * (@derekakelly)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/php-warning-100/#post-8474719)
 * [@lorro](https://wordpress.org/support/users/lorro/)
    Yes I am on the latest 
   WooCommerce, 2.6.8
 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/php-warning-100/#post-8474962)
 * I’ve downloaded a fresh copy of WooCommerce 2.6.8, and line 211 in wc-template-
   functions.php reads:
 *     ```
           $classes[] = 'woocommerce-page';
       ```
   
 * there is a foreach() on line 218.
    Sorry to labour the point but if some files
   in your install are not 2.6.8 then maybe your install is incomplete and that 
   could be a pointer to the problem.
 *  Thread Starter [derekakelly](https://wordpress.org/support/users/derekakelly/)
 * (@derekakelly)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/php-warning-100/#post-8479848)
 * [@lorro](https://wordpress.org/support/users/lorro/)
 * I think you may have missed how i put that reply together. I just copied the 
   whole section and pointed out my 211 line with an arrow i typed in <—–
 * `$classes[] = 'woocommerce-page'; <--------- line 211`
 * I put the whole function in because i wanted to show how it’s followed up shortly
   thereafter by
    `foreach ( WC()->query->query_vars as $key => $value ) {`
 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/php-warning-100/#post-8479936)
 * Yes but the first post said the foreach() was on line 211, whereas the foreach()
   is currently on 218. So the file must have changed since the error message was
   created. Therefore other WooCommerce files could have changed also. So if you
   reset the error log and wait, does the error recur with the current plugin files.
 * Anyway, “WC()->query->query_vars” is invalid at the point in time when this function
   is executed. You could try var_dump()ing this function’s return value to see 
   what’s in there. Of course, debugging the code backwards from this point won’t
   be easy.

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

The topic ‘PHP Warning’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * Last activity: [9 years, 6 months ago](https://wordpress.org/support/topic/php-warning-100/#post-8479936)
 * Status: not resolved