group of repeated custom field for each product.

  • Posts: 201
  • Thank you received: 7
1 month 4 days ago #363984

hi
i want added a repeated group of custom field (or you can imagine repeated set of fields) to each product . for example:
product 1:
set 1 {custom field A1 custom field A2 custom field A3}
set 2 {custom field A1 custom field A2 custom field A3}

product 2:
set 1 {custom field A1 custom field A2 custom field A3}
set 2 {custom field A1 custom field A2 custom field A3}
set 3 {custom field A1 custom field A2 custom field A3}
set 4 {custom field A1 custom field A2 custom field A3}

product 3:
set 1 {custom field A1 custom field A2 custom field A3}


how to do it? In fact, the number of sets of fields is determined based on the opinion of the person (admin of site ) who creates the product.
is it possible with hikashop? must use characteristics or custom field for my need which is better?

in my case i want sell template.
each template has some layout. each layout has layout preview and layout file and some other attribute.
template means product in hikashop
and layout preview means hika ajax image custom field A1
and layout file means hika ajax file custom field A2
and ...

some of template has 2 layout and some of template has 7 layout. and as i say in above each layout has some attribute.
after customer buy template, can download layout files but before buy template only can see layout preview.
something such as "subform" Joomla field type .

Last edit: 1 month 3 days ago by sadaf3d.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 month 2 days ago #363987

Hi,

So I understand that you're talking about custom fields of the table "product" so that the admin can attach custom information to the products.
You can only have one set of custom fields per product. However, if the product has variants, you can have one set of custom fields for each variant of the product. And when the selected variant changes on the frontend, the user will see the data of the custom fields set relative to this variant.

The following user(s) said Thank You: sadaf3d

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

  • Posts: 201
  • Thank you received: 7
2 weeks 5 days ago #364233

My problem still persists.
Do you suggest I make a plugin for this? I mean, is it difficult to make a plugin for such a task?
If you agree, guide me a little in relation to the construction of this plugin. Thank you.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 weeks 5 days ago #364234

Hi,

Well, the problem is a structure problem of the custom field system.
The custom field system is based on the fact that one custom field correspond to one column of the table in the database.
So, if you create a custom field of the table "product" called "field1", then HikaShop will add a column "field1" in the hikashop_product table.
Now, if you want to introduce repeatable custom fields, it would require adding as many columns to the table in the database for the maximum amount of repeated in the products.
This means potentially adding a lot of columns.
Besides, that also means reviewing the custom field system to support "grouping". Not only the custom field configuration interface in the backend, but any view where custom fields are displayed. Also, you need to change any saving function to support this too. And this also means complex changes for import / export / mass actions. So, these are really extensive changes.
A plugin to support this won't cut it.

A way simpler approach is to just have the layout as a characteristic of your products, with one variant per layout. That way, in each variant you can configure one set of custom product fields, and when the user selects the layout on the product page, the custom fields display will update on the product page to reflect the value of the custom fields for the selected variant.
This doesn't require changing any code, and seems to need your needs. Or am I missing something ?

The following user(s) said Thank You: sadaf3d

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

  • Posts: 201
  • Thank you received: 7
2 weeks 4 days ago #364262

Thank you for your complete answer.
1- if you say me how can i create something such picture attached, i guess i can create repeated field and save that in my own custom table.


2-is it possible to use upload file field in this addable field ?
my custom information don't need to show to the user.
note: is there any discount in black friday?

Attachments:
Last edit: 2 weeks 4 days ago by sadaf3d.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 weeks 4 days ago #364265

Hi,

1. Ah yes, if you create your own interface with your own table in the database, you can do it with something much simpler than adapting the whole custom field system and HikaShop to supporting repeatability.
In your plugin, you'll want to implement the onProductBlocksDisplay(&$product, &$html) event and inject your HTML as an extra entry of the $html array. You can also use the onAfterProductCreate(&$product) and onAfterProductUpdate(&$product) events to handle the saving of the data in the database.
You can see an example of this with the plugin which handles shipping prices per product. In shipping methods, you have a "shipping price per product" setting. If you activate that setting, an extra interface "shipping prices" will appear on the product edit screen so that you can configure different shipping prices for different products. This is all handled by a plugin, which implements these events I described above. You can find the files of the plugin in the folder plugins/hikashop/shippingmanual_prices/
The plugin also handles frontend display with the onHikashopBeforeDisplayView (&$view) event, but you can simply add your code in a view override, it will be easier for you.

2. If you use the "AJAX image" or "AJAX file" types in a custom field, you can activate its "multiple files" setting. This allows you to be able to upload several files in one custom field. So if your custom fields are only upload fields, you could use this capability to be able to upload several files without having to create one field per possible upload. That might be an interesting solution maybe ?

There is no discount for black friday.

Last edit: 2 weeks 4 days ago by nicolas.
The following user(s) said Thank You: sadaf3d

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

  • Posts: 201
  • Thank you received: 7
2 weeks 3 days ago #364289

nicolas wrote: Hi,

2. If you use the "AJAX image" or "AJAX file" types in a custom field, you can activate its "multiple files" setting. This allows you to be able to upload several files in one custom field. So if your custom fields are only upload fields, you could use this capability to be able to upload several files without having to create one field per possible upload. That might be an interesting solution maybe ?

Thank you. but i want use upload field not in custom field. i want use upload field in the $html array. i want implement something when i click that, i can add title, description and most important of all upload a file. i understand how to add title and description field as you say in section 1, but my second problem is how to create upload file field in that group of field after click on add+ button. is there any sample such as shipping.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 weeks 3 days ago #364300

Hi,

I would recommend going simple here and just use the HTML file type:
developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file
If you want something more advanced, with drag & drop, like in HikaShop, you can use something like this:
bdwm.be/drag-and-drop-upload-files/
The upload system we use in HikaShop (which is a more complex solution but based on the same principle as what is presented in the link above) is not easy to add in a plugin. It's possible, but there is no ready-made example. The system requires several pieces added in different places. It's not easy to use what we already have as an example as we was not made to be used by third party code easily.

The following user(s) said Thank You: sadaf3d

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

Time to create page: 0.076 seconds
Powered by Kunena Forum