1 Attachment(s)
Out of Stock When Placing Order - IS Checking by Product and Attribute.
When placing product order with attributes. The store is checking stock by the Product and it's Attributes instead of just checking by Product.
I have an item "Custom 14 Karat Gold Namepins Round Wire" with a stock of 1 item, the item has 3 attributes fields "NAME", "CHAIN", "CHRYSTAL HEARTS". the Namepin is priced by character by the name field.
If you add more than 1 item to your cart with identical attributes an error "(Products marked with *** are out of stock)" will appear. if you change an attribute or the name on the namepin, the item gets added to the cart. The problem is I only have 1 product in stock.
the url is: http://www.shamrockstables.org/cart/
I've uploaded a screen shot
Attachment 10239
This is on a linux server.
ZenCart V 1.5
Mysql Version: '5.0.95'
Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.
I reproduced this bug with a fresh (Pristine) install of ZenCart V1.5 on another virtual domain.
Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.
Working on a solution for you ... it will be a while ... :flex:
Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.
See if this works for you ...
Make sure the Product is marked as:
Quote:
Product Qty Min/Unit Mix: Yes
Then edit the file:
/includes/modules/pages/shopping_cart/header_php.php
and add the code in RED:
Code:
$flagStockCheck = zen_check_stock($products[$i]['id'], $products[$i]['quantity']);
// bof: extra check on stock
if ($flagStockCheck != true) {
if ( (zen_get_products_stock($products[$i]['id']) - ($_SESSION['cart']->in_cart_mixed($products[$i]['id']) - $_SESSION['cart']->get_quantity($products[$i]['id']))) <= 0) {
$flagStockCheck = '<span class="markProductOutOfStock">' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '</span>';
} else {
$flagStockCheck = '';
}
}
// eof: extra check on stock
if ($flagStockCheck == true) {
$flagAnyOutOfStock = true;
}
See if that works on the shopping_cart page ...
I am still working out something for the checkout ...
Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.
It flags the item and still adds it to the cart, then it still allows customer to check out with items.
Cart is in testing and dev so your welcome to create a test account on the cart to for testing.
Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.
Now edit the file:
/includes/modules/pages/checkout_shipping/header_php.php
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++) {
if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
break;
} else {
// bof: extra check on stock
if ( (zen_get_products_stock($products[$i]['id']) - ($_SESSION['cart']->in_cart_mixed($products[$i]['id']) - $_SESSION['cart']->get_quantity($products[$i]['id']))) <= 0) {
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
break;
}
// eof: extra check on stock
}
}
}
// if no shipping destination address was selected, use the customers own address as default
/includes/modules/pages/checkout_payment/header_php.php
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++) {
if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
break;
} else {
// bof: extra check on stock
if ( (zen_get_products_stock($products[$i]['id']) - ($_SESSION['cart']->in_cart_mixed($products[$i]['id']) - $_SESSION['cart']->get_quantity($products[$i]['id']))) <= 0) {
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
break;
}
// eof: extra check on stock
}
}
}
// get coupon code
/includes/modules/pages/checkout_confirmation/header_php.php
Code:
if (STOCK_CHECK == 'true') {
for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
if ($stock_check[$i] = zen_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) {
$flagAnyOutOfStock = true;
}
}
// Out of Stock
if ( (STOCK_ALLOW_CHECKOUT != 'true') && ($flagAnyOutOfStock == true) ) {
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
} else {
// bof: extra check on stock
if ( (zen_get_products_stock($order->products[$i]['id']) - ($_SESSION['cart']->in_cart_mixed($order->products[$i]['id']) - $_SESSION['cart']->get_quantity($order->products[$i]['id']))) <= 0) {
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
break;
}
// eof: extra check on stock
}
}
// update customers_referral with $_SESSION['gv_id']
Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.
Still adds it to the cart, but stops it at check out.
Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.
That is all it does ... flag the products that cause the problem and not allow checkout until the quantity is fixed ...
Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.
Thanks, You were quick to find a solution for the bug and fix it. It'll help a lot of people keep from selling products they don't have.
Wish I was working so I could afford to send you a donut and coffee.
Who do I send a request for a few more generic flat rate shipping modules ?
One flat.php for usps flatrate boxs and packages aren't enough.
I took flat.php and edited it and it worked fine, but wouldn't go past the select shipping page.
Re: Out of Stock When Placing Order - IS Checking by Product and Attribute.
You would have to post a new thread and what you are trying to do and perhaps the code that you are using to see why it is broken with details on how to you need it to work and maybe someone will look at it and try to help you ...
Otherwise, you can look at the Recommended services for any that help write custom code for hire ...