Adding Multiple Characteristics individually

  • Posts: 49
  • Thank you received: 1
5 years 3 months ago #310158

-- HikaShop version -- : 4.2.1
-- Joomla version -- : 3.9
-- PHP version -- : 7.2

Hello,

I am trying to add multiple characteristics, let's say:

I am selling x product, and that product has different colors and sizes as well the user can choose if they want to get this product within one day.

So what I am trying to do is

Since I will have three variants in this case, and please note this is just an example:

1. Colors variant should be added individually (Because when I click on add variant it forces me to add sizes to the same variant as well, I dont want this to happen)
2. Sizes Variant should be added individually without forcing me to add the colors variants to each color and size, I do not want the calculation to be that way it gets very hard to calculate all the combinations of options because I have about 10 different variants
3. Within one day delivered variant should also be added individually I do not want to go and calculate every variant mixes with that variant.

In short what I am trying to achieve is if I have 3 different variants when I go to the variants tab, I should be able to add different variants individually not to mix them all together, and each option adds to the price that's it in short.

*I should be able to select which variant I want to add these options too like add colors, without being forced to add the other variants.

That's it thanks, please do let me know if you have any questions or if anything is not clear.

Please note I do not have time to keep customizing everything in the component, I know this is not your responsibility, so far you have a great component, however, I just want something that solves the issue really quickly, because I have already customized the component to display pictures as tiles with the variants instead of dropdown or radio buttons, so people can see which option to select as a picture. What I am trying to say I do not want to add these as products and then add them as options because there is noway to customize this as well, plus the "options" option is so limited, it is just you want to add this "yes or no" don't want this.

Thanks & Regards.

Look forward to hearing from you ASAP

Last edit: 5 years 3 months ago by onereik.

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

  • Posts: 49
  • Thank you received: 1
5 years 3 months ago #310163

I have about 9 different variants each variant comes with a list of options.

Let's name them as variant1, 2, 3, 4, 5, 6, 7, 8, and variant 9

variant 1: comes with 10 different values
variant 2: comes with 10 different values

in that case I have to calculate all the combination of 100 because 10*10 = 100

While if I can add them individually without the combining option I will only have to do this for 20 options.

This really gets complicated with many variants.

I just gave an example of two different variants, how would it be when I have 9 different variants? Can you imagine? it is going to take 3 years just to add one product
=====================
Edit:
I just did a small calculation on all the variants I am going to add, so I have to edit 93,750 prices to different variants doing all the calculation between all the possible combination while if I want to do it my way, it is going to be only about 45 variants. This is seriously not easy.

Please help.

Thanks

Last edit: 5 years 3 months ago by onereik.

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

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
5 years 3 months ago #310159

Hi,

All that you describe in your message is what you can do with options actually.
And no, options are not limited to yes/no. You can have options with many values by adding characteristics to the option (usually only one characteristic).
So you would have a "color" product in an unpublished category, with a "color" characteristic added to it, with all the variants of colors added to that product. You can also set a price for each variant (color) of that product. Then, you can add that color product as an option of a main product and it will add the price of the selected variant (color) to the product base price.
And that's the same for the other characteristics (size and shipping mode) you talked about.

Now you're saying that you don't want to use the options feature and that you don't want to customize anything. However, the only way I can see to do what you're talking about without changing anything is to use the options.
So I would recommend to reconsider, knowing that you can have several values for options, and knowing that you can also change the look of the options to radios thanks to the "Product selection method" setting of the HikaShop configuration.

Without using options, and supposing you want to use characteristics/variants, I don't see how to achieve what you want. Even I would have to spend a lot of work ( weeks of complex development ) to change the way characteristics/variants work to basically have them work like options (and then I would be stuck with core modifications that would be lost with updates of HikaShop).

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

  • Posts: 49
  • Thank you received: 1
5 years 2 months ago #310204

Nicolas,

Thank you for taking the time to read my situation and reply.

Ok great that options have all the functionalities, however doing that for every product, it is going to be a pain, because:

1. For every product, there will be other 9 products (options) assigned to this main product.
2. For every assigned product (options) there will be assigned characteristics to that product (option).
3. You have to edit the price of all these 9 options' characteristics for every main product you make.

In short, this means going to 9 different pages just to edit one price for one product, that's a lot of hassle.

I know it is very hard to edit the core, and it will be lost with updates, however, what I was thinking is just to guide me which file I can edit to have the ability to add characteristics individually, let me make it simpler:

Now when I am about to add values to characteristics it forces me to add the values of all the other characteristics with an alert message "Please select a value for each characteristic of your product"

I fixed the javascript so this alert message doesn't pop up anymore, however now the PHP part, will not INSERT any (data) INTO the corresponding table in the database, because you have made it not to insert any data if there is more than a characteristic selected for one product, what I simply need is to edit this part where it lets me add (values fo characteristics without forcing me to add values for other characteristics selected for a product) In case this works fine then that's it if it didn't work, then I guess I will have to switch to another component or unfortunately I will have to stick to customizing the view of the /administrator component and the /site component to be able to achieve what I want to achieve, if I only had time I wouldn't have complained about this at all, but unfortunately I don't really have time to do all these customizations.

Please suggest another solution other than the options if you could. Also like I said earlier, I customized the characteristics part to be displayed as images, and instead of radio buttons you can select an image, so by using options I will have to do another customization to make it look like I made it look for "characteristics"

But for the future, I guess you better group the characteristics, like make a characteristics category, and assign different characteristics to different categories, in that case, a user will not be forced to edit 100 different prices to 20 different values in characteristics, like my scenario above.

Just think about it, if I have 10 colors and 5 sizes I will have to fix 50 different prices for these options while if it was like I am saying you will only have to do that 15 times so it is 15 vs 50 and in my scenario, it is 93,750 different options VS 45 options.

Can you see how it gets complicated once you have more than 3 or 4 characteristics?

I really look forward to hearing from you about, if you just could guide me about which file I can edit to fix this restriction of being forced to add all the options every time I want to add a value for a characteristic.

Thanks

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

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
5 years 2 months ago #310207

Hi,

Well. I think there are three ways to move forward in your case:

1. You could stick with characteristics. However, the interface in the backend is meant to edit variants.
And even in the database, you can't store the price of each value of characteristic, only the combination.
So first, you would have to add a column to the hikashop_variant tab so that you could have a price stored for the links between the hikashop_product table and the hikashop_characteristic table.
Then, you should redo the interface of the "variants" tab in the backend so that you would display each value of each characteristic with a checkbox you could check to use it or not for that product and a price input field. You could do that view a view override ( www.hikashop.com/support/documentation/1...-display.html#layout )
Then, in the "backSaveForm" of administrator/components/com_hikashop/classes/product.php you could add your custom code to generate the data in the hikashop_variant table based on what was checked/inputed in the "variants" tab. You could potentially do it with a plugin implementing the onAfterProductCreate / onAfterProductUpdate triggers ( www.hikashop.com/support/documentation/6...r-documentation.html ).
For the frontend, you'll want to do an override on show_block_characteristic.php to remove the check on $this->element->characteristics since it will likely be empty.
Finally, in the administrator/components/com_hikashop/types/charactersitic.php you'll want to load the data from hikashop_variant and generate the characteristic dropdowns with that data the way you need it. You should be able to reuse some part of the system but you'll probably have to rewrite a big part of it in that file. In fact, you might instead want to directly add your code to show_block_characteristic.php and don't use $this->characteristic->displayFE()

2. You could use the options system. From what I understand, your only grief with that is that you have to manage a lot of products and thus you have a lot of back and forth in your backend when managing the options because of the way your products/shop needs to be.
In that case, why not simply modify a bit the interface of the backend product edition with a view override ( www.hikashop.com/support/documentation/1...-display.html#layout ) to have an interface to enter the values and prices you want for the characteristics/values already setup in your shop. Then, with the "backSaveForm" of administrator/components/com_hikashop/classes/product.php ( you could potentially do it with a plugin implementing the onAfterProductCreate / onAfterProductUpdate triggers ( www.hikashop.com/support/documentation/6...r-documentation.html )), you could generate the product variants and options in the hikashop_product table (and hikashop_variant and hikashop_price tables).
The nice thing with this is that you don't have to do anything else. As long as you generate the appropriate options data for the product, the frontend interface of the options already works like you want. So I believe it would be a lot of development time saved for you. And just displaying the options as radios with images shouldn't be too difficult if you can already do the rest. It's just a bit of customization in the view product / option.php

3. You could use the custom field system. Our custom fields API allows you to create new types of custom fields:
www.hikashop.com/support/documentation/6...entation.html#fields
And you can create custom fields of the table "item" so that customers can select things on the product details page on the frontend.
So you could create your own type of custom item field where you could display it based on the radio custom field type but with data you would load yourself from the database.
Now custom item fields can't change the price of a product by default, but you could use a plugin to do it, like we do in "shop custom" plugins of our marketplace: www.hikashop.com/marketplace/category/39-products.html
Now to set the data in the backend, you could use custom fields of the "product" table, or your own interface and save that in one or several custom product field (each custom product field is a column of the hikashop_product table).

So these are the solutions I can think of with what you presented from your situation and what you want to do.
Note also that if you issue with the options is that it's a problem when you want to change the price because you need to edit a lot of things, then you might want to have a look at mass actions:
www.hikashop.com/support/documentation/167-massaction-form.html
or the export/import system:
www.hikashop.com/support/documentation/73-hikashop-import.html
These can allow you to rapidely update a lot of products at once.

The following user(s) said Thank You: onereik

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

  • Posts: 49
  • Thank you received: 1
5 years 2 months ago #310230

Hi Nicolas,

That was such a detailed informative post, thanks a lot for explaining everything, now I am confident enough I can do it, however, still on a very tight schedule, so if you can or would do it, please let me know how much would you charge for such a task? If not I guess I will do it myself.

Please note, I do not want you to do everything just making the process easy in the administrator part, I can take care of the view part on the frontend.

Thanks

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

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
5 years 2 months ago #310236

Hi,

Well, supposing that we're talking about the first solution I gave, and supposing that we're only talking about us working on the backend interface, I think we could do the changes I talked about

So first, you would have to add a column to the hikashop_variant tab so that you could have a price stored for the links between the hikashop_product table and the hikashop_characteristic table.
Then, you should redo the interface of the "variants" tab in the backend so that you would display each value of each characteristic with a checkbox you could check to use it or not for that product and a price input field. You could do that view a view override ( www.hikashop.com/support/documentation/1...-display.html#layout )
Then, in the "backSaveForm" of administrator/components/com_hikashop/classes/product.php you could add your custom code to generate the data in the hikashop_variant table based on what was checked/inputed in the "variants" tab. You could potentially do it with a plugin implementing the onAfterProductCreate / onAfterProductUpdate triggers ( www.hikashop.com/support/documentation/6...r-documentation.html ).

for 600 euros.
Note however that upon thinking about it, I was merely thinking about the backend edition and the product page display.
I didn't thought about the cart and checkout when writing solution 1. I guess what you'll want to do is always add the main product to the cart (instead of adding the variant) and then add the selection in several custom item fields and then have a plugin to modify the price of the product in the cart taking into account the data in the custom item fields. So it adds a bit of work to it. Basically, it's kinda of a merge between solution 1 and solution 3 that you need. The solution 1 for the backend and product page, and the solution 3 for the cart/checkout.

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

  • Posts: 49
  • Thank you received: 1
5 years 2 months ago #310269

Hi Nicolas,

Thanks for the prompt reply and for your offer, I really appreciate the time and effort you have put into this. I think that is much more than I expected, so I guess I will implement the solution myself, and I will let you know if I have any questions.

Cheers.

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

  • Posts: 49
  • Thank you received: 1
5 years 2 months ago #310398

Hi Nicolas,

I have been working on this and have done some changes, so far it is going great but one thing which we didn't think of before, which is by default in Hikashop if I select more than an option for a product, and those two options are radio buttons you can only select one radio button among all these options, which is logical because as you know in HTML when it comes to radio buttons, they have to be grouped by name attribute and in Hikashop it seems all the options have the same name attribute in radio buttons, and the value of the name attribute should be changed to the characteristics name or hikashop_product_option[Product ID] or any other easy solution rather than "hikashop_product_option[]"

a real example of Hikashop options

<input type="radio" name="hikashop_product_option[]" id="hikashop_product_option_0192" value="192" checked="checked" class="inputbox" size="1" data-product-option="0" onchange="hikaProductOptions.change();">

Regardless of the option, the name attribute will always be "hikashop_product_option[] and for that reason, they are not grouped individually by the option you select, so in that case, you can only select one radio button among all the options assigned to one product.

For now, I used dropdown instead of radio buttons but I guess for the future this should be an important update, still there are a lot of things I am fixing because it doesn't simply work out of the box, luckily I am a developer and I can do some customizing, hacking and tweaking, however, as you know it is not good to hack the model and controllers file because you can not override them in Joomla, and you can only override the "view"

Plugins for sure are a great thing as they are events & triggers so you can trigger things and I know that very well, but there are some core files in the component that really need some update, it will easily start to get pretty complex if you want to scale the app you are developing.

=============
EDIT:
For sure checkboxes can be selected, but not if you can only select one option from each group of options, because as you know you can select as many checkboxes as you want regardless of if they are in the same group or in different groups but for radio inputs a user should be able to at least select one option from each group.

Regards

Last edit: 5 years 2 months ago by onereik.

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

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
5 years 2 months ago #310467

Hi,

Indeed, the options system has been developed first to support only dropdowns. Radios and checkboxes were added later on.
In fact, you're the first one giving feedback on that particular problem.
What you could try is to change the line:

$map = 'hikashop_product_option[]';
to:
$map = 'hikashop_product_option['.$i.']';
in the option.php view file.
That way, you would still have the same array name in the add to cart controller receiver, but you would have a different group name for the radios of different options. I didn't test that solution but I think it's quit an elegant one.
Let me know how that goes. That way, we could include the change on our end for others in the same situation in the future.

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

Time to create page: 0.081 seconds
Powered by Kunena Forum