I'm not too sure about PHP but I normally took it was like math and the brackets are done before anything else.
I have this:
if( !strncmp($method_id,'OPTION', 6) && ( ($method_id != 'OPTION_5') || ($method_id != 'OPTION_12') ) )
unset( $available_methods[ $method_id ] );
Where $method_id
is equal to OPTION_
1 through to 12.
Effectively if option 5 and 12 are available unset everything except those two.
QUESTION Why doesnt the above work.
EDIT
So I tried simplifying it but I think I made it harder to understand.
This is a shipping loop. The available methods are ship:REGULAR_LOCAL
, ship:EXPRESS_LOCAL
, ship:PLAT_LOCAL
, ship:REGULAR_INT
, ship:EXPRESS_INT
, ship:PLAT_INT
, and FREE_SHIPPING
[where LOCAL
is within shipping country, and INT
is international].
When an order goes over $100, FREE_SHIPPING
automatically kicks in, but I also want to have either ship:EXPRESS_LOCAL
or ship:EXPRESS_INT
present depending on where the customer is from.
if( !strncmp($method_id,'ship:', 5) && ( ($method_id != 'ship:EXPRESS_LOCAL') || ($method_id != 'ship:EXPRESS_INT') ) )
unset( $available_methods[ $method_id ] );
This should return with only FREE_SHIPPING
, and either ship:EXPRESS_LOCAL
or ship:EXPRESS_INT
.
LOOP
if( isset( $available_methods['FREE_SHIPPING'] ) ) {
foreach( $available_methods as $method_id => $method ) {
if( !strncmp( $method_id, 'ship:', 5 ) && ( ($method_id != 'ship:EXPRESS_LOCAL') && ($method_id != 'ship:EXPRESS_INT') ) )
unset( $available_methods[ $method_id ] );
}
}
return $available_methods;