Hi, I'm new here, sorry if this is not the right place to post this but my developer is in a hospital and I have things falling apart, I have this: 1. if($order->source == 'unknown') { $data->CustomerRef = $extra_field_1; } How can I add/merge that (1) with (2): 2. if(($order->payment_method == 'collect_on_delivery') or strpos($order->delivery_method ,'pobraniowa')) { $data->CustomerRef = $order->delivery_package_nr; }else{ $data->CustomerRef = $order->order_id; }
Depending on how $data->CustomerRef is constructed, you might be able to, but probably not. The problem here isn't merging the if-conditions, but to get more than one return-value. Ie, look at this code: if ($order->source == 'unknown' && (($order->payment_method == 'collect_on_delivery') || strpos($order->delivery_method ,'pobraniowa'))) { $data->CustomerRef = $extra_field_1; $data->CustomerRef = $order->delivery_package_nr; } else { $data->CustomerRef = $order->order_id; } PHP: That won't work (probably), because the return value if the first if-condition is correct will only return one of the $data-results (basically, the last one, the delivery package nr). So, depending on what you need, and what you want, you might need to rethink the whole thing. If you just want the whole thing to be ONE combined conditional, depending on different values, you could do something like this: if ($order->source == 'unknown') { $data->CustomerRef = $extra_field_1; } elseif (($order->payment_method == 'collect_on_delivery') || strpos($order->delivery_method,'pobraniowa')) { $data->CustomerRef = $order->delivery_package_nr; } else { $data->CustomerRef = $order->order_id; } PHP:
if(($order->payment_method == 'collect_on_delivery') or strpos($order->delivery_method ,'pobraniowa')) { $data->CustomerRef = $order->delivery_package_nr; } else if($order->source == 'unknown') { $data->CustomerRef = $extra_field_1; } else{ $data->CustomerRef = $order->order_id; } Code (markup):