Zen Cart Logo
Forums / General Questions / Trigger an action depending on attribute

Trigger an action depending on attribute

Views: 489

Results 1 to 3 of 3
27 Jun 2014, 11:28 PM
#1
strelitzia avatar

strelitzia

Totally Zenned

Join Date:
Nov 2005
Location:
France
Posts:
588
Plugin Contributions:
1

Trigger an action depending on attribute

I need to trigger an action based on what attribute is selected by the customer and in most cases code such as this works

if (strpos($options_menu[$i], 'name="id[1]"') !== false) {
TRIGGER ACTION
}

However, if the attribute is one with images it doesn't work

I set this as a test and it ALWAYS returns FALSE if the attribute has images

if (strpos($options_menu[$i], 'name="id[26]"') !== false) {
echo "TRUE";
}else{
echo "FALSE";
}

Any ideas why this doesn't work on attributes with images? It's got me stumped.

28 Jun 2014, 12:16 AM
#2
strelitzia avatar

strelitzia

Totally Zenned

Join Date:
Nov 2005
Location:
France
Posts:
588
Plugin Contributions:
1

Re: Trigger an action depending on attribute

I did some more testing and if I do

print_r ($options_menu);

the data printed DOES NOT contain any of the attribute info that has images which suggests they are not built in that array

So if they are not in $options_menu[$i], where are they?

28 Jun 2014, 1:45 AM
#3
strelitzia avatar

strelitzia

Totally Zenned

Join Date:
Nov 2005
Location:
France
Posts:
588
Plugin Contributions:
1

Re: Trigger an action depending on attribute

I worked this out.

Used the following:

if (strpos($options_attributes_image[$i], 'name="id[26]"') !== false) {