Product Variations and stock

  • Posts: 93
  • Thank you received: 3
11 years 3 months ago #158405

-- url of the page with the problem -- : mywebsite.com/mypage
-- HikaShop version -- : 2.3.1
-- Joomla version -- : 3.3
-- PHP version -- : x.x.x
-- Browser(s) name and version -- : XXXXX x.x.x
-- Error-message(debug-mod must be tuned on) -- : Error_message

Hi,
I need to know if the following is possible and if so how to configure. My client is selling toilet cubicles of which there could be 1 to 6 in a block which would be 6 different products. There are a number of variations such as door color which is easy to setup but he also wants the components needed to build set up with stock and not be editable by the customer but come out on the invoice like bill f materials. So for instance a 2 block toilet needs 2 sides, 1 partition and 6 legs, whereas a 3 block toilet need 8 legs and 2 partitions.

Is there a way to set up characteristics or variations that use a preset qty and cannot be edited by the user, so we could set up a characteristic called partition with stock of 1 and you could order a 2 block toilet but not a 3 block due to stock levels.

Any guidance appreciated

Thanks

Tony

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

  • Posts: 12953
  • Thank you received: 1778
11 years 3 months ago #158417

Hello Tony,
I think that the best solution will probably be to use some "product" custom fields so that you can add different specifications regarding your product variant.

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

  • Posts: 93
  • Thank you received: 3
11 years 3 months ago #158591

Hi,
the problem with that is that custom fields as far as I can tell do not carry stock. somehow I need to show that a 2 toilet cubicle will take the stock from the characteristic or variant 'DOORS' but it will automatically take 2 and the customer cannot change this to 1 or 3 for that option.

Thanks

Tony

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

  • Posts: 12953
  • Thank you received: 1778
11 years 3 months ago #158633

Hi Tony,
Then the solution will be to use options which will be sold per pack of 2-3-4, then you'll be able to manage your stock of main products and even their options.

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

  • Posts: 93
  • Thank you received: 3
11 years 2 months ago #160608

Hi,
I have got to the development stage for this at last but cannot see how to setup certain things.

I have a product setup PartA, It has a Color Characteristic which works perfectly and I have tried to add 2 other products as options (ie the components).

What I can seem to find is how to set an option to Yes by default and to set a default quantity for that option tht is related to the product.

ie. PartA needs only 2 option a and 1 option b
PartB needs only 4 option a and 2 option b

Thanks

Tony

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

  • Posts: 84298
  • Thank you received: 13697
  • MODERATOR
11 years 2 months ago #160676

Hi,

You need to add a characteristic to your option product so that you can have different variants of your options instead of just yes/no:
www.hikashop.com/support/support/documen...html#characteristics

I'm not sure what you mean by setting a default quantity ? The quantity of the option in the cart will be equal to the quantity of the product that you entered when adding it to the cart.

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

  • Posts: 93
  • Thank you received: 3
11 years 2 months ago #160687

Hi nicolas,
I cant see how characteristic will work? As i do not want the customer to be able to select/change the option. I just need all the options i add to a product to default to yes so they are preselected i can then hide that div from the user.

On the second question, let me try to explain, product1. Needs 1 of option a. But product b needs 2 of option a. So the same option product say something like ram modules. But the qty is different . However it needs to be preset as mentioned above so we can track stock of the option products and print them on the invoice. Is there a way to do this? If not if the answer can be preset to yes if i add the optional product twice will it summarise on the invoice or list seperaley

Thanks

Tony

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

  • Posts: 84298
  • Thank you received: 13697
  • MODERATOR
11 years 2 months ago #160841

Hi,

1. When you don't have any characteristic attached to a product and that you use that product as an option, the system automatically displays a yes/no choice defaulting to no.
When you have a characteristic attached to a product and that you use that product as an option, the system automatically displays a dropdown with one value per variant of the option product. So simply have one value in your characteristic for your option product and you'll get only one choice in the dropdown (so what you want).

2. There is no way to do that. As I said in me previous answer, the quantity of the option in the cart will be equal to the quantity of the product that you entered when adding it to the cart. I've never tried to have twice the same option attached to a product but that's your best bet here and if that doesn't work, that it would require to modify the code to support quantities for options.

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

  • Posts: 93
  • Thank you received: 3
11 years 2 months ago #160980

Hi,
I thought I nearly had something working but options only work at one level not two!.

What I have found is that if I set the minimum order qty of an option product to say 2 it takes that much stock which is great, You also have a plugin called custom_quantity (that I cant find to download).. If I created multiple custom fields in the main product which are the quantity needed of the option product, How in the same way that the custom_quantity manipulates the main product qty field could I access the same field in the option items.

thanks

Tony

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

  • Posts: 84298
  • Thank you received: 13697
  • MODERATOR
11 years 2 months ago #160982

Hi,

You can for example use the custom_price plugin (which is called donation).
You can find an example of what it does here:
demo.hikashop.com/index.php?option=com_h...ct&task=show&cid=214

As you'll see in the code of the plugin, the $quantity can be changed to whatever you want via the plugin.
So that would be a solution yes.

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

  • Posts: 93
  • Thank you received: 3
11 years 2 months ago #161085

Thanks Nicolas,
I think I am going to have to write some sort of plugin to get what my customer wants, can you tell me whats contained in the options array in $product as its not listed in the docs, and how easy would it be if I built a plugin using on afterorderconfirm to update the stock figures of the option products not the main product.

also I have noticed an issue with options if you have 2 optional products with a default option so they are preselected , if you update the quantity of the main product when in the cart the quantity of the optional products do not increase as well.

Thanks

Tony

Last edit: 11 years 2 months ago by bettston. Reason: update

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

  • Posts: 93
  • Thank you received: 3
11 years 2 months ago #161161

Hi I think I have figured out want I need a new plug have to write this weekend to do but need some guidance.

1. What trigger is called that causes the stock of a product to be decremented?

What I want to do is I will have a main product with 2 custom fields containing a number
At the point the product stock would get updated I need a plugin to trigger
the plugin needs to read the custom field, if it has a figure then update the stock of another product in the product table. so as a schematic

Product toilet cubicle has custom fields Sides and Bottom with 2 and 1 in each respectively.

Customer orders 2 toilet cubicles
When the plugin is triggered products Sides and Bottom stock gets decremented by 4 and 2. And as normal toilet cubilcle goes down by 1

Seems simple in logic but I need some guidance on which trigger to use and how to update a different product than that that's loaded (an example here would be great).

One I have it written it may well be usefull to anyone trying to track stock of component parts

Thanks

Tony

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

  • Posts: 84298
  • Thank you received: 13697
  • MODERATOR
11 years 2 months ago #161214

Hi,

If you want to change the stock, I would recommend to do it either when the order is created or when the order status is updated to "confirmed" (it depends on your requirements)
For the order created, you can add your code in a trigger onAfterOrderCreate. The $order in it will contain all the data of the order and you can do a var_dump of the variable if you want to see what's inside and how to access what you need.
For the order status changed to confirmed, you want to add your code in a trigger onAfterOrderUpdate. You'll have to make sure that the status is being updated:
if($order->order_status=="confirmed" && $order->old->order_status=="created"){
//your code
}
The $order object might not always contain all the data of the order. So in your code, you'll want to load the data of the order as shown with one of the code sample we provide at the end of the developer documentation:

If you want to load the whole information of an order, you can use the code :
$orderClass = hikashop_get('class.order');
$order = $orderClass->loadFullOrder($order_id, true, false);

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

  • Posts: 93
  • Thank you received: 3
11 years 2 months ago #161218

Hi nicolas,
Thats really helpful, so i just need to know how to update the stock for products not on the order and we are set ie a custom field represents another product thst i want to update as well. And are all the custom product field listed in $order?

Thanks

Tony

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

  • Posts: 84298
  • Thank you received: 13697
  • MODERATOR
11 years 2 months ago #161232

Hi,

The value of custom item fields will be in the $order object. The value of custom product fields won't e in the $order object.
You'll have to do a query on the hikashop_product table to load them based on the product_id of the products that you'll find in the $order object.
And to update the quantity of the products, it's basically the same, you'll have to do an update query on the product_quantity column of the hikashop_product table based on the product_id of the products for which you want to update the stock.

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

Time to create page: 0.090 seconds
Powered by Kunena Forum