PHP 比较反转
PHP Comparison Inversion
以下代码来自电子商务运输模块:
if (!IS_ADMIN_FLAG) {
global $cart;
$chk_products_in_cart = 0;
$chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '12');
$chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '22');
// do not show florida 18 and new york 43
$chk_delivery_zone = $order->delivery['zone_id'];
$chk_states = '18, 43';
$arr1 = explode(", ", $chk_states);
$arr2 = explode(", ", $chk_delivery_zone);
$donotshow_state = array_intersect($arr1, $arr2);
if ((int)$donotshow_state && $chk_products_in_cart > 0) {
$this->enabled = false;
}
}
以上代码检查购物车中的商品是否为产品 ID 的 12 或 22 以及运输 zone/state ID 18 或 43。如果两者都为真,它会禁用 ($this->enabled =假;).
如果产品 12 或 22 在购物车中 and 运输区域是 18 or 43、禁用
我想将其区域部分修改为:
如果产品 12 或 22 在购物车中 and 运输区域是 不是 43 , 禁用
使用这个:
if (!IS_ADMIN_FLAG) {
global $cart;
$chk_products_in_cart = 0;
$chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '12');
$chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '22');
// disable if not 43 and $chk_products_in_cart > 0
$arr2 = explode(", ", $order->delivery['zone_id']);
if (!in_array('43', $arr2) && $chk_products_in_cart > 0) {
$this->enabled = false;
}
}
以下代码来自电子商务运输模块:
if (!IS_ADMIN_FLAG) {
global $cart;
$chk_products_in_cart = 0;
$chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '12');
$chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '22');
// do not show florida 18 and new york 43
$chk_delivery_zone = $order->delivery['zone_id'];
$chk_states = '18, 43';
$arr1 = explode(", ", $chk_states);
$arr2 = explode(", ", $chk_delivery_zone);
$donotshow_state = array_intersect($arr1, $arr2);
if ((int)$donotshow_state && $chk_products_in_cart > 0) {
$this->enabled = false;
}
}
以上代码检查购物车中的商品是否为产品 ID 的 12 或 22 以及运输 zone/state ID 18 或 43。如果两者都为真,它会禁用 ($this->enabled =假;).
如果产品 12 或 22 在购物车中 and 运输区域是 18 or 43、禁用
我想将其区域部分修改为:
如果产品 12 或 22 在购物车中 and 运输区域是 不是 43 , 禁用
使用这个:
if (!IS_ADMIN_FLAG) {
global $cart;
$chk_products_in_cart = 0;
$chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '12');
$chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '22');
// disable if not 43 and $chk_products_in_cart > 0
$arr2 = explode(", ", $order->delivery['zone_id']);
if (!in_array('43', $arr2) && $chk_products_in_cart > 0) {
$this->enabled = false;
}
}