I'm using v1.4.9 and am selling products that vary by size only. I've setup each product and the size option with values and quantities per option.
How do you display to the user that it's only certain options that are in stock? ie. if I only have 1 pair of size 10, it somehow shows that size 10 is the only size in stock?
How do you display to the user that it's only certain options that are in stock? ie. if I only have 1 pair of size 10, it somehow shows that size 10 is the only size in stock?
You'll need to make a change to the catalog/model/catalog/product.php firstly.
Find this line
After it put
That should load up the quantity value for each option ready to be used in the template. Next you need to put the code into your product template, and use $option_value['quantity'] for the value of the quantity. I'm not actually sure if you want to do it the way you suggested however as if all quantities are 0, then you'll end up with no option values, and that could be an issue
Find this line
Code: Select all
'price' => $product_option_value['price'],
Code: Select all
'quantity' => $product_option_value['quantity'],
Thanks ocpro. I added the code and then opted to simply hide the normal Availability line in the product listing and add a stock level to each option in the dropdown:
'name' => $option_value['name'] . ' (' . $option_value['quantity'] . ' in stock)'
Thanks!
'name' => $option_value['name'] . ' (' . $option_value['quantity'] . ' in stock)'
Thanks!
I think you would also have to add to catalog/controller/product/product.php:
The other consideration is that product and option quantities are allowed to go negative so in
catalog/model/checkout/order.php
Change:
To:
Which will prevent it from going below zero which would look odd.
+ + +
Personally, I think preventing negative product/option stock should be core behaviour
Example:
- Product has Options A,B,C with quantities 1,1,1 (overall product quantity 3)
- Someone buys 4 of Option C (after 4-5 days message)
- This leaves Options A,B,C with quantities 1,1,-3 (overall product quantity -1)
- Someone wants to buy Options A,B but product confusingly shows out-of-stock despite being available
But, I guess a $this->config->get('Allow_Negative_Stock') would be the best option.
Code: Select all
'quantity' => $option_value['quantity'],
catalog/model/checkout/order.php
Change:
Code: Select all
foreach ($order_option_query->rows as $option) {
$this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity - " . (int)$product['quantity'] . ") WHERE product_option_value_id = '" . (int)$option['product_option_value_id'] . "' AND subtract = '1'");
}
Code: Select all
foreach ($order_option_query->rows as $option) {
$this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = greatest(0,(quantity - " . (int)$product['quantity'] . ")) WHERE product_option_value_id = '" . (int)$option['product_option_value_id'] . "' AND subtract = '1'");
}
+ + +
Personally, I think preventing negative product/option stock should be core behaviour
Example:
- Product has Options A,B,C with quantities 1,1,1 (overall product quantity 3)
- Someone buys 4 of Option C (after 4-5 days message)
- This leaves Options A,B,C with quantities 1,1,-3 (overall product quantity -1)
- Someone wants to buy Options A,B but product confusingly shows out-of-stock despite being available
But, I guess a $this->config->get('Allow_Negative_Stock') would be the best option.
Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products
Thanks for info, I understand the premise but have a couple questions you guys might clear up for me:
Using the above method, will purchases deduct stock from the options upon purchase? (if setup to deduct normally in ACP)
and
is there a way to prevent negative stock? I assumed if the setting was enabled in the ACP to prevent checkout with items marked "out of stock"
Thank you
Using the above method, will purchases deduct stock from the options upon purchase? (if setup to deduct normally in ACP)
and
is there a way to prevent negative stock? I assumed if the setting was enabled in the ACP to prevent checkout with items marked "out of stock"
Thank you
Hi, I am trying to do exactly what you did.jtsroberts wrote:Thanks ocpro. I added the code and then opted to simply hide the normal Availability line in the product listing and add a stock level to each option in the dropdown:
'name' => $option_value['name'] . ' (' . $option_value['quantity'] . ' in stock)'
Thanks!
Would you please let me know the location of the file where you made the changes in order to display the stock status next to each option and also the file where you removed the normal Availability
Thank you
catalog/model/catalog/product.phpelmerrfudd wrote: Hi, I am trying to do exactly what you did.
Would you please let me know the location of the file where you made the changes in order to display the stock status next to each option and also the file where you removed the normal Availability
Thank you
Just edit catalog/model/catalog/product.php
FIND:
$product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value WHERE product_option_id = '" . (int)$product_option['product_option_id'] . "' ORDER BY sort_order");
REPLACE:
$product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value WHERE product_option_id = '" . (int)$product_option['product_option_id'] . "' AND quantity > 0 ORDER BY sort_order");
This will not allow options with 0 quantity or less to display.... enjoy
FIND:
$product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value WHERE product_option_id = '" . (int)$product_option['product_option_id'] . "' ORDER BY sort_order");
REPLACE:
$product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value WHERE product_option_id = '" . (int)$product_option['product_option_id'] . "' AND quantity > 0 ORDER BY sort_order");
This will not allow options with 0 quantity or less to display.... enjoy
Hi guys!
How can you do the same thing in 1.5.3? (store has 2 languages)
I want the store to display "In Stock" or "Not in stock" after the option name. If i would get the quantity, I would just do an simple if/else there. But I have trouble getting the $option_value['quantity'] value in product.tpl.
I have added
on line 345 in "catalog/model/catalog/product.php"
but when I try to
on line 72 in "catalog/view/theme/my_theme/template/product/product.tpl"
only the name and the " - " is printed out.
i also tryed echoing $option_value['option_id'] and other array elements there but it seems I can only access $option_value['name']
I'll investigate and post solution, if I find one.
How can you do the same thing in 1.5.3? (store has 2 languages)
I want the store to display "In Stock" or "Not in stock" after the option name. If i would get the quantity, I would just do an simple if/else there. But I have trouble getting the $option_value['quantity'] value in product.tpl.
I have added
Code: Select all
'quantity' => $product_option_value['quantity']
but when I try to
Code: Select all
echo $option_value['name']. " - " .$option_value['quantity'];
only the name and the " - " is printed out.
i also tryed echoing $option_value['option_id'] and other array elements there but it seems I can only access $option_value['name']
I'll investigate and post solution, if I find one.
I have other problem 1.4.9.3
T-shirts Some how quantity 100
Red color 0
Blue color 0
some how customer "add to cart" T-SHIRTS then this order through without option.
How do I have to change if option is 0 then make unable to order.
T-shirts Some how quantity 100
Red color 0
Blue color 0
some how customer "add to cart" T-SHIRTS then this order through without option.
How do I have to change if option is 0 then make unable to order.
Who is online
Users browsing this forum: No registered users and 73 guests