I'm having a difficult to finish a if statement twice.. The rest works fine but when I try to check in another subarray it doesn't work.
EDIT: - The first if condition is to check the type of products - The second if condition is to check the size attributes. - Products: sweatshirt_crianca and sweatshirtc_crianca_capuz - Sizes: 4_anos, 6_anos, 8_anos, 11_anos, 12_anos and 14_anos Need to disable ( $this->enabled = false; ) Those sizes except 14_anos.
This is what I get from $order->products[$i]
Array
(
[qty] => 1
[name] => .Mr Mickey T-shirt
[model] =>
[image] => blusa-mr-mrs-blusao-sweat-camisolas-portugal.png
[tax] => 20
[tax_description] => IVA 23%
[price] => 10.8333
[final_price] => 16.6666
[weight] => 0.00
[id] => 1342{18}135{17}132{19}148
[attributes] => Array
(
[0] => Array
(
[option] => s_cor_produto
[value] => branco
[option_id] => 18
[value_id] => 135
[prefix] => +
[price] => 0.0000
)
[1] => Array
(
[option] => s_produto
[value] => sweatshirt_crianca
[option_id] => 17
[value_id] => 132
[prefix] => +
[price] => 5.8333
)
[2] => Array
(
[option] => s_tamanho_produto
[value] => 8_anos
[option_id] => 19
[value_id] => 148
[prefix] => +
[price] => 0.0000
)
)
)
Array
(
[qty] => 1
[name] => Adivinha quem vai ser mama shirt
[model] =>
[image] => adivinha-quem-vai-ser-mama-tshirt-gravida.png
[tax] => 20
[tax_description] => IVA 23%
[price] => 10.8333
[final_price] => 10.8333
[weight] => 0.00
[id] => 1860{20}157{18}139{17}128{19}152
[attributes] => Array
(
[0] => Array
(
[option] => s_cor_impressao
[value] => branco
[option_id] => 20
[value_id] => 157
[prefix] => +
[price] => 0.0000
)
[1] => Array
(
[option] => s_cor_produto
[value] => azul_royal
[option_id] => 18
[value_id] => 139
[prefix] => +
[price] => 0.0000
)
[2] => Array
(
[option] => s_produto
[value] => tshirt_mulher
[option_id] => 17
[value_id] => 128
[prefix] => +
[price] => 0.0000
)
[3] => Array
(
[option] => s_tamanho_produto
[value] => M
[option_id] => 19
[value_id] => 152
[prefix] => +
[price] => 0.0000
)
)
)
Sometimes it can contains 1 or 4 subarrays. This is cod payment from osCommerce, I'm trying to exclude specific products from this method based on the attributes of it. This works fine in the first if statement to check the [value] but the lines that are commented the syntax is correct but it's not working. This is the code I got:
for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
if ($order->products[$i]['weight'] > '0.00') {
$this->enabled = false;
}
if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
if ( ($order->products[$i]['attributes'][$j]['option'] == 's_produto') && ($order->products[$i]['attributes'][$j]['value'] == 'sweatshirt_crianca') ) {
//if ( ($order->products[$i]['attributes'][$j]['option'] == 's_tamanho_produto') && ($order->products[$i]['attributes'][$j]['value'] == '14_anos') ) {
$this->enabled = false;
//}
}
else if ( ($order->products[$i]['attributes'][$j]['option'] == 's_produto') && ($order->products[$i]['attributes'][$j]['value'] == 'sweatshirtc_crianca_capuz') ) {
//if ( ($order->products[$i]['attributes'][$j]['option'] == 's_tamanho_produto') && ($order->products[$i]['attributes'][$j]['value'] != '14_anos') ) {
$this->enabled = false;
//}
}
}
}
}
Any solutions? Thanks.
Sidyll beat me to it but I was thinking along similar lines: