PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Dec 12, 2017 1:02 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Tue Nov 21, 2017 8:42 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4377
Location: United Kingdom
Syntax: [ Download ] [ Hide ]
[20-Nov-2017 03:30:28 UTC] PHP Warning:  Illegal string offset 'is_variation' in /var/www/vhosts/domain.co.uk/httpdocs/wp-content/plugins/improved-variable-product-attributes/includes/ivpa-frontend.php on line 741


Line 741 is:
Syntax: [ Download ] [ Hide ]
if ( $v['is_variation'] == '1' ) { ...

This is that section.
Syntax: [ Download ] [ Hide ]
                                        foreach ( $available_attributes as $k => $v ) {
                                                if ( $v['is_variation'] == '1' ) {
                                                        if ( isset($curr_customizations['ivpa_attr']) && is_array($curr_customizations['ivpa_attr']) && in_array(self::utf8_urldecode( $k ), $curr_customizations['ivpa_attr']) ) {
                                                                $ready_customization[array_search(self::utf8_urldecode( $k ), $curr_customizations['ivpa_attr'])] = $k;
                                                        }
                                                        else {
                                                                $keep_customization[$k] = $k;
                                                        }
                                                }
                                                else {
                                                        if ( self::$settings['wc_settings_ivpa_simple_support'] !== 'none' ) {
                                                                if ( isset($curr_customizations['ivpa_attr']) && is_array($curr_customizations['ivpa_attr']) && in_array(self::utf8_urldecode( $k ), $curr_customizations['ivpa_attr']) ) {
                                                                        $rCid = array_search(self::utf8_urldecode( $k ), $curr_customizations['ivpa_attr']);
                                                                        if ( isset( $curr_customizations['ivpa_svariation'][$rCid] ) && $curr_customizations['ivpa_svariation'][$rCid] == 'yes' ) {
                                                                                $ready_customization[$rCid] = array( 'slug' => $k, 'custom' => true );
                                                                        }
                                                                }
                                                                else {
                                                                        if ( self::$settings['wc_settings_ivpa_simple_support'] == 'full' ) {
                                                                                $keep_customization[$k] = array( 'slug' => $k, 'custom' => true );
                                                                        }
                                                                }
                                                        }
                                                }
                                        }


This is on the latest woocommerce and WP 4.9.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Tue Nov 21, 2017 9:57 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6603
Location: WA, USA
The message means that $v is a string.

If that's supposed to be possible then you could
Syntax: [ Download ] [ Hide ]
if ( is_array($v) && $v['is_variation'] == '1' ) {

If that's not supposed to be possible then, well, obviously, fix it.


Top
 Profile  
 
PostPosted: Tue Nov 21, 2017 10:25 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4377
Location: United Kingdom
If I change it to that, the icons that show the colour swatches don't appear on the category or product pages. We are awaiting an answer from the plugin people, but it's taking time.
This is the plugin:
https://codecanyon.net/item/improved-va ... 1511197223

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Tue Nov 21, 2017 10:51 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6603
Location: WA, USA
So maybe you try tweaking the logic of what I wrote just a tiny little bit to make it work the way you want?


Top
 Profile  
 
PostPosted: Tue Nov 21, 2017 10:58 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4377
Location: United Kingdom
I'm not sure about it - I didn't write it. I'm guessing you have a sense of what tiny adjustment could be made.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Tue Nov 21, 2017 8:48 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6603
Location: WA, USA
If
Syntax: [ Download ] [ Hide ]
if ( is_array($v) && $v['is_variation'] == '1' ) {

isn't doing the customization thing, and you know that $v is a string (because of the error message), then that means the is_array($v) is not true. Which means the else branch will execute.

If you want the if branch to execute if $v is a string then you don't want if $v is an array and is_variation=1, but rather if $v is not an array or it is and is_variation=1.
Syntax: [ Download ] [ Hide ]
if ( !is_array($v) || $v['is_variation'] == '1' ) {


But that will also catch every other $v that is a string. But that might be what it should do.


Top
 Profile  
 
PostPosted: Wed Nov 22, 2017 11:30 am 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13457
Location: New York, NY, US
simonmlewis wrote:
I'm not sure about it - I didn't write it. I'm guessing you have a sense of what tiny adjustment could be made.

I'd recommend looking at what is in $available_attributes to see what you should be looking for. Use print_r() or var_dump() to see what the elements of $available_attributes actually are.

_________________
(#10850)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Bing [Bot] and 24 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group