- Posts: 7
- Thank you received: 1
product bundle stock not updated on succesful order
2 years 6 months ago #359927
by tlweb
product bundle stock not updated on succesful order was created by tlweb
-- HikaShop version -- : 5.0.3
-- Joomla version -- : 4.4.3
-- PHP version -- : 8.2.x
-- Browser(s) name and version -- : safari latest
-- Error-message(debug-mod must be tuned on) -- : no error message
Hi,
I have a product that has 2 variants because you have an option to get a free product or discount.
This product has 21 bundled products linked to it.
When i order the product the stock of those 21 products is not updated. WHat am i doing wrong?
See attache screenshots for configuration
-- Joomla version -- : 4.4.3
-- PHP version -- : 8.2.x
-- Browser(s) name and version -- : safari latest
-- Error-message(debug-mod must be tuned on) -- : no error message
Hi,
I have a product that has 2 variants because you have an option to get a free product or discount.
This product has 21 bundled products linked to it.
When i order the product the stock of those 21 products is not updated. WHat am i doing wrong?
See attache screenshots for configuration
Please Log in or Create an account to join the conversation.
2 years 6 months ago - 2 years 6 months ago #359929
by nicolas
Replied by nicolas on topic product bundle stock not updated on succesful order
Hi,
Bundled products on products with variants is not supported now.
However, looking into it, I think it could be added with a few lines of code.
Try adding the code:
before the line:
in the file administrator/components/com_hikashop/classes/order_product.php and it should hopefully do it.
Note also that the stock will be updated based on the "Update the product stock on confirmed status" option of the HikaShop configuration. If that option is activated, the status of the order needs to be confirmed for the stock to be updated.
Bundled products on products with variants is not supported now.
However, looking into it, I think it could be added with a few lines of code.
Try adding the code:
Code:
$query = 'SELECT product_parent_id FROM #__hikashop_product WHERE product_parent_id > 0 AND product_id IN ('.implode(',', $bundle_product_ids).')';
$this->database->setQuery($query);
$parents = $this->database->loadObjectList('product_parent_id');
if(!empty($parents)) {
foreach($parents as $k => $v) {
$bundle_product_ids[ (int)$k ] = (int)$k;
}
}
Code:
$query = 'SELECT pr.product_id as `bundle_id`, pr.product_related_id as `product_id`, pr.product_related_quantity, p.product_name, p.product_code, p.product_tax_id '.
Note also that the stock will be updated based on the "Update the product stock on confirmed status" option of the HikaShop configuration. If that option is activated, the status of the order needs to be confirmed for the stock to be updated.
Last edit: 2 years 6 months ago by nicolas.
The following user(s) said Thank You: tlweb
Please Log in or Create an account to join the conversation.
2 years 6 months ago - 2 years 6 months ago #359933
by tlweb
Replied by tlweb on topic product bundle stock not updated on succesful order
There is an error in your query syntax. It didn't have "FROM" in it. But at first i thought it worked. But now i can't get it to work anymore.
Last edit: 2 years 6 months ago by tlweb.
Please Log in or Create an account to join the conversation.
2 years 6 months ago - 2 years 6 months ago #359934
by tlweb
Replied by tlweb on topic product bundle stock not updated on succesful order
removed this because it's not true.
Last edit: 2 years 6 months ago by tlweb.
Please Log in or Create an account to join the conversation.
2 years 6 months ago #359962
by nicolas
Replied by nicolas on topic product bundle stock not updated on succesful order
Hi,
So I've looked into it today and it's a bit more complicated.
I had to add the code:
instead of the code I gave you yesterday, and I also had to change the code:
to:
in that same file. Now it's working fine in my tests.
We'll be including the modifications for the next version of HikaShop.
So I've looked into it today and it's a bit more complicated.
I had to add the code:
Code:
$query = 'SELECT product_parent_id, product_id FROM #__hikashop_product WHERE product_parent_id > 0 AND product_id IN ('.implode(',', $bundle_product_ids).')';
$this->database->setQuery($query);
$parents = $this->database->loadObjectList('product_id');
if(!empty($parents)) {
foreach($parents as $k => $v) {
$bundle_product_ids[ (int)$v->product_parent_id ] = (int)$v->product_parent_id;
}
}
Code:
if($product->product_id != $bundle_data->bundle_id)
continue;
Code:
// check that the current bundle data is for the current product
if($product->product_id != $bundle_data->bundle_id) {
// the current bundle data is not for the current product
$found = false;
// check if the product is actually a variant of a product linked to the bundled data
foreach($parents as $parent) {
if($parent->product_id == $product->product_id && $parent->product_parent_id == $bundle_data->bundle_id) {
$found = true;
}
}
if(!$found)
continue;
}
We'll be including the modifications for the next version of HikaShop.
Please Log in or Create an account to join the conversation.
2 years 5 months ago #360009
by tlweb
Replied by tlweb on topic product bundle stock not updated on succesful order
Hi Nicolas,
I've tested your updated code but it still is not working for me unfortunately. I'll set up a test domain tomorrow so i can do more extensive testing.
Kind regards,
Tom
I've tested your updated code but it still is not working for me unfortunately. I'll set up a test domain tomorrow so i can do more extensive testing.
Kind regards,
Tom
Please Log in or Create an account to join the conversation.
Time to create page: 0.233 seconds