i modified a shipping module to detect out of stock to ship another way so having a problem looking at attribute stock to determine
ex.
Code:
// Variable holds information about the products in the order
$this->_products = $_SESSION['cart']->get_products();
$_SESSION['cart']->shopping_stock = 1;
$inStock = 0;
$outStock = 0;
$_SESSION['cart']->in_stock_products = [];
$_SESSION['cart']->out_stock_products = [];
foreach ($this->_products as $product) {
$pid = $product["id"];
$qty = $product["quantity"];
$product_query = "select products_quantity
from " . TABLE_PRODUCTS . "
where products_id = '" . (int)$pid . "'";
$product = $db->Execute($product_query);
$quantity = $product->fields["products_quantity"];
if ($quantity < $qty){
$_SESSION['cart']->shopping_stock = 2;
array_push($_SESSION['cart']->out_stock_products,(int)$pid);
$outStock = 1;
}else{
$_SESSION['cart']->shopping_stock = 1;
array_push($_SESSION['cart']->in_stock_products,(int)$pid);
$inStock = 1;
}
}
if($outStock == 1 && $inStock == 1 && count($this->_products) > 0){
$_SESSION['cart']->shopping_stock=3;
}
Bookmarks