and, problem solved. In the /includes/modules/pages/checkout_shipping/header_php.php if you've already installed Stock by Attributes there is already an in-stock loop. just a copy paste without the condition will do it, Search for:
Code:
// Stock Check
if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
$products = $_SESSION['cart']->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
// START "Stock by Attributes"
// Added to allow individual stock of different attributes
unset($attributes);
if(is_array($products[$i]['attributes'])){
$attributes = $products[$i]['attributes'];
}
else{
$attributes = null;
}
if(!empty($attributes)){
if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'], $attributes)) {
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
break;
}
}
else{
if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
break;
}
}
}
// END "Stock by Attributes"
Then add BEFORE it:
Code:
//In Stock Shipping Check
$in_stock_flag = true;
$products = $_SESSION['cart']->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
// START "Stock by Attributes"
// Added to allow individual stock of different attributes
unset($attributes);
if(is_array($products[$i]['attributes'])){
$attributes = $products[$i]['attributes'];
}
else{
$attributes = null;
}
if(!empty($attributes)){
if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'], $attributes)) {
$in_stock_flag = false;
break;
}
}
else{
if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
$in_stock_flag = false;
break;
}
}
}
// END in stock shipping
Then search for where the shipping modules are loaded:
Code:
// load all enabled shipping modules
require(DIR_WS_CLASSES . 'shipping.php');
$shipping_modules = new shipping;
and insert your specific logic immediately AFTER:
Code:
if (!in_stock_flag){
$shipping_modules->modules = array("upsxml.php");
}
else {
if ($_SESSION['customer_whole'] && $_SESSION['customer_whole'] != '0' ) {
$shipping_modules->modules = array("wholesaletable.php");
} else {
$shipping_modules->modules = array("table.php");
}
}
Bookmarks