Home Forums Plugins Product Importer Deluxe Support [Resolved] Help: Product Variations Reply To: Help: Product Variations


Hello…today I get information about new update is prepared. I was hoping, the next update fix the product variation problem, but not. It still not working. So I give my time, I was searching, where can be the problem and I find interesting bug. In includes/functions.php on line 2186 is this condition:
if( $product->is_variation && $product->is_variation != “false” )

But after change it to something like this
if( isset($product->is_variation) && $product->is_variation != false )
Everything works ok. The same condition is used more time in code, so I recommend to replace it everywhere, because the original condition cannot work.

And the explanation
The PHP using more ways of compare…but always do the compare of same type of variable(so if the variable type is not the same, the PHP retype one of this vars)

if( $product->is_variation && $product->is_variation != “false” )
so, if $product->is_variation has boolean value true the first part of condition return true.

But the second part no. Because in PHP, when is compared more datatypes, PHP will use the simpliest datatype of all.
So if($product->is_variation == “false”)
is in this situation the same like if(true == “false”)
And this return true. Why? Because you are comparing boolean variable type and string variable. So PHP will transform it to boolean value, something like if(true == (bool)”false”)….and (bool)”false” is has the same value like true….

so if($product->is_variation != “false”) return false
And this is the result, why this if( $product->is_variation && $product->is_variation != “false” ) always return false. Because if first part return true, the second part return false and if the first part return false, the second part return true

PS: Sorry for my English 😉