Add product to cart based on custom field

  • Posts: 11
  • Thank you received: 0
11 years 3 months ago #124776

-- url of the page with the problem -- : n/a yet
-- HikaShop version -- : 2.2.1
-- Joomla version -- : 3.1.5
-- PHP version -- : 5.3.13

Hi,

I am building a site to sell cards, where the visitor is able to add a personal message to a cart. However, the personal message comes with a price, which I want to add to the cart. From my point of view the steps would be the following:
1. User selects a product
2. On the product page, the user adds additional options (small gifts)
3. The user selects if he wants to add a personal message
3a. In case yes, a text field appears
3b. In case no, nothing happens
4. When clicking the order-button:
On the shopping cart, the specifc product appears, the selected options and an additional product for the cost of the personal message

Currently I have tried to accomplish this:
1. by adding two options to the product page, but unfortunately I cannot show the custom text box in that case when the user selects yes for the personal message. The product will appear on the cart
2. by creating two custom fields, one for the selection and one for the text box, but unfortunately then I cannot add the additional product to the cart.

Hope somebody can help me out.

Thanks in advance,
Jeroen

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

  • Posts: 13201
  • Thank you received: 2322
11 years 2 months ago #124818

Hi,

The best way is to use a plugin which will increase the price of the product if the text field is not empty.
Thanks to create two custom fields, one which will be the input for the text named "customtext" and one named "amount" to set the price when the text field is filled. The second one have to be a product type custom field.

Then thanks to try the following plugin:

File Attachment:

File Name: h04b9666.zip
File Size:1 KB

Attachments:

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

  • Posts: 11
  • Thank you received: 0
11 years 2 months ago #125254

Hi Xavier,

thanks for the swift reply! I have installed the plugin (btw, I had to update it for Joomla 3.1) and this was succesful.
Additionally I created two new fields:
1. field name: customtext, table: item, type: text
2. field name: amount, table: product, type: text, default value 2.5

Now when I order, I can see the the customtext. However, when I proceed with the order I do not see any price increase of my product.

What am I doing wrong?

Regards,
Jeroen

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

  • Posts: 13201
  • Thank you received: 2322
11 years 2 months ago #125327

Hi,

I just tried on my end, and it's working fine.
Have you save again your products after adding the custom field amount ?
Because, the field is created, but it don't change the product values.

The following user(s) said Thank You: Jeroen

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

  • Posts: 11
  • Thank you received: 0
11 years 2 months ago #125392

Hi Xavier,

Strange, because I can't get it to work on my end. I now have the following settings:

customtext
Label: Text
Table: item
Column name: customtext
Field type: text
Published: Yes
Categories: All (incl. sub)
amount
Label: amount
Table: product
Column name: amount
Field type: text (also tried other types via phpmyadmin)
Default value: 2
Published: Yes
Categories: All (incl. sub)

The plugin is enabled and of the type: system.

I have not made any changes to the plugin or in the ordering steps in Joomla except for some css changes.

Regards,
Jeroen

ps. Unofrtunately it seems I can't attach the screenshots or upload the word document.

Last edit: 11 years 2 months ago by Jeroen.

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

  • Posts: 26165
  • Thank you received: 4029
  • MODERATOR
11 years 2 months ago #125421

Hi,

You have to edit the product in the HikaShop backend and specify a value for the amount.
Even if you set a default value, it does not fill the value in the database for all products.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 11
  • Thank you received: 0
11 years 2 months ago #125454

Hi Jerome,

I have actually done so, also checked the database table itself and for the specific product the amount is filled. Any clue on how I could debug this?

Regards,
Jeroen

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

  • Posts: 11
  • Thank you received: 0
11 years 2 months ago #125473

Allright, I just made a completely clean installation of Joomla and Hikashop. created a new product, added the fields, etc. All working great. The only difference I see now between the two is the ordering of the plugin. Any idea how I could debug this?

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

  • Posts: 26165
  • Thank you received: 4029
  • MODERATOR
11 years 2 months ago #125535

Hi,

Well, if the only difference is the plugin ordering. I will suggest you to make a little modification in the plugin (to display something) and see if the function is right called.
This is really strange and I am wondering how this plugin ordering could affect the process.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: Jeroen

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

  • Posts: 11
  • Thank you received: 0
11 years 2 months ago #125755

Hi Jerome and Xavier,

Thanks for the support! I finally found the issue. Mistake from my side, topic can be closed. I didn't realize that I had to add the amount to the variants of the products as well. So, I only added the additional amount to the main product, as a result no succes.

After some debugging I finally realized the amount had to be added to the variants of the characteristics as well.

All working fine now. just a few steps away of bringing my shop live!

Regards,
Jeroen

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

Time to create page: 0.081 seconds
Powered by Kunena Forum