我试图组合一个方法来查看 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;
}
即使两者都存在,该方法也只返回“卡”或“费用”。做错了什么?