Codeigniterショッピングカートを調べて、カート内のアイテムのIDに基づいてトランザクションのタイプを判別するメソッドをまとめようとしています。
ここに方法があります
function parse_transaction_type() {
$card_skus = array("MYU_SC1","MYU_SC2","MYU_SC3");
$fee_skus = array("MYU_SF1","MYU_AD1","MYU_AD2");
foreach ($this->cart->contents() as $key => $item) {
if(in_array($item['id'], $card_skus) && in_array($item['id'], $fee_skus))
{
$type = "fees-cards";
}
if (in_array($item['id'], $card_skus) && !in_array($item['id'], $fee_skus))
{
$type ="cards";
}
if (in_array($item['id'], $fee_skus) && !in_array($item['id'], $card_skus))
{
$type ="fees";
}
}
echo $type;
}
このメソッドは、両方が存在する場合でも、「カード」または「手数料」のいずれかのみを返します。何が悪いのですか?