• Hey guys,

    If a costumer orders the same product twice but with different variations (e.g. Skirt#123 black and Skirt#123 green) I want to do something.
    I have:

    
    $variation = $item['myAttribute']; /*var_dump($variation) = string(5) "black" string(5) "green"*/
    
    if (strpos($variation,"black")===false){ 
    		//do something
    	}
    	if (strpos($variation,"green")===false){ 
    		//do something
    
    	}
    	if (strpos($variation,"white")===false){ 
    		
    		//do something
    		
    	}
    	if (strpos($variation,"yellow")===false){ 
    		
    		//do something
    		
    	}
    	if (strpos($variation,"pink")===false){ 
    		//do something
    
    	}

    But when one attirbute is found (e.g black and green) the if never reaches the “green” section, because of the black it jumps right out too early.
    How can I pack this that it works?

    Thanks in advance.

    • This topic was modified 7 years, 6 months ago by rasidrsd.
Viewing 4 replies - 1 through 4 (of 4 total)
  • What kind of code do you have inside the if statements? The code exactly as you have above would not “jump right out” anywhere. You must have some kind of return in your if statements causing it to leave the function this is in.

    Thread Starter rasidrsd

    (@rasidrsd)

    I use the FPDF library to generate pdf files and write on them.

    if (strpos($variation,"black")===false){ 
    		$pdf->Line(150,129,202,129);
    		$pdf->Line(150,133,165,133);
    	}

    Simply: If “black” is selected write lines.
    But if two Colors are selected it does only the first “if”, the other one doesnt write anything.

    • This reply was modified 7 years, 6 months ago by rasidrsd.
    Thread Starter rasidrsd

    (@rasidrsd)

    So the problem is, that when the first “Color” enters the “if” statements, all the other colors would draw a line, so if the second “color” gets to the “if” it doesnt write the line, but the previous one did, so it looks that nothing happens.
    How can I solve this problem?

    Just a thought, but you don’t happened to be covering the lines up by using the same numbers in the different if statements? Try an error_log("color") in each if statement just to make sure the problem is the if statements instead of the line drawing itself.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Continue if with 2 Attributes’ is closed to new replies.