PHP Code:
// bof: only show if all Products are from master_categories_id, individual products_id and Linked Categories
if (!IS_ADMIN_FLAG) {
// check the count of a specific field
$chk_catAll = 0;
$chk_cats = 0;
$chk_catAll = $_SESSION['cart']->count_contents();
// check how many Products are in the cart for master_categories_id 409 etc
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','409');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','7');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','103');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','104');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','105');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','336');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','372');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','361');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','397');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','395');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','385');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','401');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','400');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','391');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','394');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','384');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','387');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','399');
$chk_cats += $_SESSION['cart']->in_cart_check('master_categories_id','390');
echo 'Products master_categories_id Found: ' . $chk_cats . '<br>';
//------------------------------------------------------------------------------------
// check individual products_id 168, 169, 172
// $chk_products_found = 0;
// $chk_products = $_SESSION['cart']->get_products();
// for ($i=0, $n=sizeof($chk_products); $i<$n; $i++) {
// if ( in_array((int)$chk_products[$i]['id'], array(168, 169, 172)) ) {
// $chk_products_found += $chk_products[$i]['quantity'];
// }
// }
// echo 'Products Individual Found: ' . $chk_products_found . '<br>';
//--------------------------------------------------------------------------------------
// check Products from Linked Categories 409 etc
$chk_linked = $db->Execute("SELECT distinct products_id FROM products_to_categories WHERE categories_id IN (409, 7, 103, 104, 105, 336, 372, 361, 397, 395, 385, 401, 391, 400, 394, 384, 387, 399, 390)");
while(!$chk_linked->EOF) {
$selected_products_check .= $chk_linked->fields['products_id'];
$chk_linked->MoveNext();
if (!$chk_linked->EOF) {
$selected_products_check .= ',';
}
}
$selected_products = explode(',', $selected_products_check);
// check cart contents for linked products
$chk_products_linked = $chk_products;
$chk_products_found_linked = 0;
for ($i=0, $n=sizeof($chk_products_linked); $i<$n; $i++) {
if ( in_array((int)$chk_products_linked[$i]['id'], $selected_products) ) {
$chk_products_found_linked += $chk_products_linked[$i]['quantity'];
}
}
echo 'Products Linked Found: ' . $chk_products_found_linked . '<br>';
// if any are found turn off the shipping module
if (($chk_cats + $chk_products_found + $chk_products_found_linked) != $chk_catAll) {
$this->enabled = false;
}
}
// eof: only show if all Products are from master_categories_id, individual products_id and Linked Categories
Bookmarks