Show custom field based on characteristics

  • Posts: 11
  • Thank you received: 0
10 years 10 months ago #121376

-- url of the page with the problem -- : currently local, but can make available online if required
-- HikaShop version -- : 2.2.1 (Business)
-- Joomla version -- : 3.1
-- PHP version -- : 5.3.13
-- Browser(s) name and version -- : Mozilla/5.0 (Firefox)

Hi,

I am developing a shop to send hand written cards. However I haven't been able to find out the following.

The product page should work for the user in the following way:
1. User selects a product.
2. User selects additional options (gifts)
3. User selects if he wants to add a personal message to the post card
4a. if yes, additional field shows up to add the message
4b. if no, nothing happens
5. user adds product to cart
6. proper price is calculated. Price is increased when the user requires a personal message on the card.

Currently I have succeeded in step 1 to 4b by using the standard functionality as well as two custom fields for step 3 and 4. Field1: Personal message yes/no. Field2 appears when selecting yes in field one. Thereafter obviously step 5 is also succesful, but I am not able to update the price (or add an additional product with the correct price) to the cart

Additionally I have tried to add another option to the main-product, then the price is calculated correctly, but I can't add a specific text message.

Any help or ideas on how to solve this is highly appreciated!

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

  • Posts: 82095
  • Thank you received: 13195
  • MODERATOR
10 years 10 months ago #121380

Hi,

You won't be able to display/hide a text field based on a characteristic/option value. That's not possible easily.
There are two possibilities:
- the obvious is to always display the text field so that the user can enter something in it when he activate the option and clearly explain to him that the field needs only to be filled in that case.
- you can use only custom item fields and the "display limited to" option of the custom item field of the text to limit it to the option with the personal message. However, custom fields cannot change the price of a product like characteristics or options and in that case, you will want to create a small quantity price calculation override plugin to change the price of the product in the cart based on whether the user entered a personal message or not:
www.hikashop.com/support/documentation/6...tation.html#override
Here is an example of such plugin:
demo.hikashop.com/index.php?option=com_hikashop&ctrl=product&task=show&cid=214

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

  • Posts: 174
  • Thank you received: 2
  • Hikashop Business
1 month 3 weeks ago #361240

its been long time from this post, but today i need the same: to display Text field based on characteristics value. Is there any way i can achieve that?

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

  • Posts: 82095
  • Thank you received: 13195
  • MODERATOR
1 month 3 weeks ago #361243

Hi,

It's possible to do it with a bit of custom javascript code in a view override:
www.hikashop.com/forum/product-category-...characteristics.html

Now, I think that in most cases, you should rather use only custom item fields with the "display limited to" setting as I was saying here 10 years ago. Since then, we have released the price calculations plugin ( www.hikashop.com/marketplace/product/148...ce-calculations.html ) which allows you to provide formulas for overriding the price of the product based on what is selected / entered in the custom item fields. So if you're using characteristics because you need to provide different prices for different variants of the product, a full custom item fields solution with the price calculation plugin is what I would recommend.
Now, if you need to handle other things, like different images for different variants, or different stock for different variants, this won't help and the custom javascript code will be more adapted to your situation.

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

  • Posts: 174
  • Thank you received: 2
  • Hikashop Business
1 month 3 weeks ago #361263

i just bought this plugin, looks promising, but for me without coding skills it's quite hard to understand what should i input in formula if i just want to add 60 euros to price if one of dropdown (custom item field value) is selected?

Can you give me at least one real world example?

Last edit: 1 month 3 weeks ago by arnask.

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

  • Posts: 82095
  • Thank you received: 13195
  • MODERATOR
1 month 3 weeks ago #361264

Hi,

Suppose that in your custom field, you've configured the column to be "my_field" and that you've added two values 0 and 1 with their titles being respectively "no" and "yes".
You can use this formula:

({my_field}*60+{price})*{cart_product_quantity}
That way, {my_field} will be replaced by either 0 or 1, {price} will be replaced by the base price of the product that you've configured in the product, and {cart_product_quantity} will be replaced by the quantity of the product in the cart (or 1 on the product details page).
So for example, if the base price of the product is 100, if "no" is selected, the price will be: (0*60+100)*1 = 100
And if "yes" is selected, the price will be: (1*60+100)*1 = 160

Last edit: 1 month 3 weeks ago by nicolas.
The following user(s) said Thank You: arnask

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

Time to create page: 0.080 seconds
Powered by Kunena Forum