I was editing my "checkout" page to show product image or to be exact option image for products with options
it's working fine for products with 1 option,
but for products with multiple options sometimes it work and sometimes it automatically select the option that doesn't have image so it show the placeholder,
for example i have 3 options for a tshirt
1. Color with image of each color ( red - black - blue )
2. Size without image ( medium - large - xlarge )
3. material without image ( cotton - polyester )
it should show the color option image since it's the only option with images
but unfortunately sometimes it select size option or material option
so there is no image and instead there is a placeholder
i want to know how to check if the option has image or not,
i did a var_dump for $options and the result was
Code: Select all
array(15) { ["product_option_id"]=> string(3) "250" ["product_option_value_id"]=> string(3) "110" ["option_id"]=> string(2) "18" ["option_value_id"]=> string(3) "111" ["name"]=> string(17) "Size" ["value"]=> string(6) "xlarge" ["type"]=> string(5) "radio" ["quantity"]=> string(3) "100" ["subtract"]=> string(1) "1" ["price"]=> string(8) "100.0000" ["price_prefix"]=> string(1) "+" ["points"]=> string(1) "0" ["points_prefix"]=> string(1) "+" ["weight"]=> string(10) "0.00000000" ["weight_prefix"]=> string(1) "+" }
Code: Select all
if($options has image){
show it's image
}elseif($options doesn't have image){
select another option
}