html - PHP Comparison Inversion -
following code excommerce shipping module:
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'); // not show florida 18 , 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; } } above code checks if items in shopping cart product id's 12 or 22 along shipping zone/state id 18 or 43. if both true, disables ($this->enabled = false;).
if products 12 or 22 in cart and shipping zone 18 or 43, disable
i want modify zone portion of be:
if products 12 or 22 in cart and shipping zone not 43, disable
use this:
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 , $chk_products_in_cart > 0 $arr2 = explode(", ", $order->delivery['zone_id']); if (!in_array('43', $arr2) && $chk_products_in_cart > 0) { $this->enabled = false; } }
Comments
Post a Comment