Finally being able to zoom in on these two images, I see that they are as later reported related to the shipping module, so hopefully the other assistance provided clarifies(or closely clarifies)this issue.
Printable View
i will come back to this, very busy
Couple of things.
SBA works off of two stock quantities, 1 for the specific attribute (attribute combination when more than one attribute is involved) and the quantity of product identified overall for the product.
Deleting the attribute(s) from the product and reassigning them does not change the non_stock table. This means that if an action hasn't been taken to remove the entries from the non-stock table, then the ones previously assigned remain in place and will cause the single dropdown option to appear to have the quantity available that is entered for the overall product once those attributes are again assigned to the product and the product assigned to SBA.
The recommendation I made a few days ago to change return false to return true will cause the shopping_cart page to only support a quantity of 1 existing in the cart, even though on the product page it will appear that there are more available. The "value" returned should be the quantity of product that are purchasable at that time (either some sort of total quantity of all available product or perhaps some sort of maximum per purchase. This portion of the code as previously said had not been flushed out. Even now with this new concept of using it there are additional caveats to consider.
If configuration->stock->subtract stock is true, then with each purchase, the total available quantity will decrease for both the attribute and the overall product quantity. So, recommend considering how the store's stock is used when trying to flush out operation. At the moment there is no individual setting against SBA that would prevent this decrease for either/both values other than the above described stock setting.
So I hope that with any combination of the above information at least there is some more understanding. Of course I'd like to finish off the section of code in question.
So I still have this changed to true
For test2 I have now added two attributes. the first one is pick type of vinyl, the second one is to pick color. It works, but the colors I have shown in zc_products_with_attributes_stock_attributes_non_stock is what it shows as in stock.Quote:
Anyways, if you go to includes/classes/class.products_with_attributes_class_stock.php and then modify line 1351 from:
Code:
return false;
to:
Code:
return true;
How do i incorporate this into code above. if products qty 0 and products attribute stock 0 this item is nonstock.
if products qty 1 and products attribute stock 0 this item is nonstock,
if products qty 0 and products attribute stock 1 this item is instock, etc.
Mind you, there is also a function that has been incorporated/modified for SBA called zen_check_stock, which returns a string of text if the product is out-of-stock (less than zero would remain if the provided quantity to be removed from the stock would cause the quantity to be less than zero).
The modified version of this call is: zen_check_stock($products_id, $quantity_to_try_to_obtain, $attributes);
In your case, the second parameter would be $qty.
While on the surface of things I would approach this differently, I have used the code I previously provided in the below since you have indicated that you want to know the actual numbers involved and not just whether the item would be in stock or not based on the program/code written to provide that information (zen_check_stock).
Now, I note that here in the "shipping" page you are trying to assign/capture the current stock status. I don't know if the above is a one time only check or will be called again just before closing out the order during the order generation process. But there is a stock check evolution performed in checkout_confirmation processing to try to prevent an individual from checking out with product that have "just" been purchased by someone else. Further though, the session variables set here could become out-of-date if the purchase is not pushed through "quickly" and someone else purchases those items.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"]; */
$attributes = null;
if (isset($product['attributes'])) {
$attributes = $product['attributes'];
}
$quantityAttrib = zen_get_products_stock($products_id, $attributes);
$quantityProd = zen_get_products_stock($products_id);
/* Do whatever is necessary to mark product as in stock here in place of this comment block and then below take action if it is identified as out-of-stock */
$quantity = $qty;
if (isset($attributes) && $quantityAttrib <= 0) {
/* out-of-stock */
/* This if block says that if there are attributes associated with the product (assuming all of the appropriate attributes have been provided)
and those attributes have made it such that there are no attribute related product then the product is considered out-of-stock
regardless of the quantity of the original product.
*/
$quantity = $quantityAttrib;
} else if (!isset($attributes) && $quantityProd <= 0) {
/* out-of-stock */
/* This block identifies that the product is out-of-stock based on not having attributes and the quantity available associated is out-of-stock.*/
$quantity = $quantityProd;
}
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;
}
Thank you, u already know you are a coding genius, LOL
one more thing, when products are not in stock a banner in reds tells the customer this, but banner doesnt show with attributes out of stock
im sorry code did not work, i have a product attribute in cart with 0 Quantity, but product has 10000 quantity and it istrying to ship it as stock, should ship as a special order,(from Vendor)
Product in question https://jnsflooringandsupplies.com/i...860adc5a9a58d1
i disabled nonstock method from showing in shopping cart, i put a #1 in front of stock method title to know the different methods, there is a third shipping called stock an nonstock, when stock and nonstock are in cart.
I just was able to add a "special order" product to the cart and was provided a notification that there was special ordering required (when viewing shipping options from the shopping cart page), I added an instock product and had the same options overall, then removed the special order product and was provided a different series of shipping options. Don't recall which "special order" product I selected, but from my perspective and limited knowledge of the site, it seemed like *something* was handled correctly.