product bundle stock not updated on succesful order

  • Posts: 5
  • Thank you received: 1
  • Hikashop Business
1 month 6 days ago #359927

-- 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

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
1 month 6 days ago #359929

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:

		$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;
			}
		}
before the line:
		$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 '.
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.

Last edit: 1 month 5 days ago by nicolas.
The following user(s) said Thank You: tlweb

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 1
  • Hikashop Business
1 month 6 days ago #359933

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: 1 month 6 days ago by tlweb.

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 1
  • Hikashop Business
1 month 6 days ago #359934

removed this because it's not true.

Last edit: 1 month 6 days ago by tlweb.

Please Log in or Create an account to join the conversation.

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
1 month 5 days ago #359962

Hi,

So I've looked into it today and it's a bit more complicated.
I had to add the 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;
			}
		}
instead of the code I gave you yesterday, and I also had to change the code:
				if($product->product_id != $bundle_data->bundle_id)
					continue;
to:
				// 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;
				}
in that same file. Now it's working fine in my tests.

We'll be including the modifications for the next version of HikaShop.

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 1
  • Hikashop Business
1 month 2 days ago #360009

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

Please Log in or Create an account to join the conversation.

Time to create page: 0.057 seconds
Powered by Kunena Forum