0

I checked my PHP logs, and it says that

[16-May-2016 16:42:07 UTC] PHP Parse error: syntax error, unexpected '[' in C:\mysite.com\www\wp-content\plugins\woocommerce-bolder-product-alerts\inc\class-account.php on line 48

Here is that line:

if( $settings_low[ 'enabled' ] == 'yes' || $settings_sales[ 'enabled' ] == 'yes' || $this->get_subscription_settings( $user_id )[ 'restocking' ] ) :

I'm no PHP coder, so does this line look correct?

Thanks.


SOLUTION

$subscription_settings = $this->get_subscription_settings( $user_id );

if( $settings_low[ 'enabled' ] == 'yes' || $settings_sales[ 'enabled' ] == 'yes' || $subscription_settings[ 'restocking' ] ) :

halfer
  • 19,824
  • 17
  • 99
  • 186
t0rxe
  • 95
  • 3
  • 14
  • 3
    I'd guess this is the problem `$this->get_subscription_settings( $user_id )[ 'restocking' ] )` Accessing an array returned from a function directly like that was added in PHP 5.4 - which version of PHP are you running? – JimL May 16 '16 at 16:51
  • I am running PHP 5.3. I just commented out that line, and the plugin is stable and the sites 500 error has gone, so how would I re-code that line for 5.3? – t0rxe May 16 '16 at 16:56
  • Then you need to update to use this plugin (you should update anyway) – JimL May 16 '16 at 16:56
  • Fair enough. I'm just worried that my forums may have problems and other plugins may have issues. I'll give it a shot anyway. Thanks. – t0rxe May 16 '16 at 16:57
  • Backup your site/database and try to run it locally. You can get a dev environment up quickly using either [scotch box](https://box.scotch.io/) or [Laravels Homestead](https://laravel.com/docs/5.2/homestead). Then you can mess around trying whatever you want without breaking production (the live site) – JimL May 16 '16 at 16:59
  • Try to put `$this->get_subscription_settings( $user_id )` in a variable before ($my_var for example), then update your code with: $my_var[ 'restocking' ]… – LoicTheAztec May 16 '16 at 17:14
  • Something like this? `$settings_settings = get_subscription_settings();` .................................. `if( $settings_low[ 'enabled' ] == 'yes' || $settings_sales[ 'enabled' ] == 'yes' || $settings_settings( $user_id )[ 'restocking' ] ) :` – t0rxe May 16 '16 at 18:09
  • 1
    Something like `$settings_settings = get_subscription_settings($user_id);` and then you use `$settings_settings[ 'restocking' ]` instead in if statement… just a suggestion… I haven't tested because you are using a specific function from a subscription commercial plugin. – LoicTheAztec May 16 '16 at 19:14
  • That didn't seem to work, but you were awfully close :) `$settings_settings = $this->get_subscription_settings( $user_id );` And then this is the main logic: `if( $settings_low[ 'enabled' ] == 'yes' || $settings_sales[ 'enabled' ] == 'yes' || $settings_settings[ 'restocking' ] ) :` This code works. – t0rxe May 17 '16 at 13:20
  • The only thing you forgot was `$this->` on the variable. Thank you for your help though. It is much appreciated. – t0rxe May 17 '16 at 13:47

0 Answers0