Almost working... but not quite. When I had several products in cart from a mix of different linked and main cats it was showing only the table409.php option at checkout.
However, adding some bulkier products (from categories outside the list of ID's I'm using) and the table409.php is still the only option. It should not show at this stage. Only the table.php option should show. Let me paste the contents of both files. I think it's one of my stupid syntax things!
table409.php
PHP Code:
// bof: only show if all Products are from individual products_id and Master/Linked Categories
if (!IS_ADMIN_FLAG) {
//-------------------------------------------------------------------------------------------------
// 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 5, 10, 22
$chk_linked = $db->Execute("SELECT distinct products_id FROM " . TABLE_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 Master/Linked Found: ' . $chk_products_found_linked . '<br>';
$chk_cat_total = ($chk_products_found + $chk_products_found_linked);
// if any Products are found and does not match ALL products in cart turn off the shipping module
if (($chk_cat_total) != $chk_catAll) {
$this->enabled = false;
}
}
// eof: only show if all Products are from individual products_id and Master/Linked Categories
table.php
PHP Code:
// bof: only show if all Products are OUTWITH Master/Linked Categories
if (!IS_ADMIN_FLAG) {
//-------------------------------------------------------------------------------------------------
// 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
$chk_linked = $db->Execute("SELECT distinct products_id FROM " . TABLE_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 Master/Linked Found: ' . $chk_products_found_linked . '<br>';
$chk_cat_total = ($chk_products_found + $chk_products_found_linked);
// if any Products are found and does not match ALL products in cart turn off the shipping module
if (($chk_cat_total) == $chk_catAll) {
$this->enabled = false;
}
}
// eof: only show if all Products are OUTWITH Master/Linked Categories