I use the PHP variable $sku to remove certain products from the export. The code below works good if I only want to remove the product with SKU X from the export.
foreach ($skus as $key => $sku){if ($sku == "X") return "";
But if I want to remove products with SKU X and/or Y and/or Z from the export, the code below gives empty output. Any idea what is the issue here?
foreach ($skus as $key => $sku){if ($sku == "X" || $sku == "Y" || $sku == "Z") return "";
Update: I have changed the function, but now I am getting Fatal error: 'continue' not in the 'loop' or 'switch' context in your code on line 32 (continue;).
function get_order_item_lines($skus = '', $qty = ''){
$xml = '';
if (!empty($skus) && is_array($skus)){
foreach ($skus as $key => $sku){
if (strpos(strtoupper($sku, "Z")) === 0) return "";
$xml .= "<L>".PHP_EOL;
$xml .= "<P>" . $sku . "</P>".PHP_EOL;
$xml .= "<Q>" . (empty($qty[$key]) ? "" : $qty[$key]) . "</Q>".PHP_EOL;
$xml .= "</L>".PHP_EOL;
}
} else {
$skus = explode( ",", $skus );
if ( !empty( $skus[0] ) && !empty( $qty[0] ) ) {
if (strpos(strtoupper($skus[0], "Z")) === 0) return "";
$xml .= "<L>".PHP_EOL;
$xml .= "<P>" . trim( $skus[0] ) . "</P>".PHP_EOL;
$xml .= "<Q>" . (empty($qty[0]) ? "" : $qty[0]) . "</Q>".PHP_EOL;
$xml .= "</L>".PHP_EOL;
}
}
return $xml;
}