Add additional costs at "Upload your image" field

  • Posts: 49
  • Thank you received: 7
  • Hikashop Multisite
8 months 1 week ago #354421

-- HikaShop version -- : 4.7.5
-- Joomla version -- : 4.3.3
-- PHP version -- : 7.4.33
-- Browser(s) name and version -- : Chrome 115.0.5790.170
-- Error-message(debug-mod must be tuned on) -- : -

Hi,

I'm having some difficulties with some products which are having additional options. For instance:

  • A product has an upload an image field
  • I've created a custom field for that
  • Customer uploads an image > now extra costs has to be added to the total of the product

Can you please let me know how to achieve the extra costs? Is that possible anyway?

Thank you very much for your appreciated help!

Regards,
Ans

Attachments:
Last edit: 8 months 1 week ago by Ans van Tongeren.

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

  • Posts: 81563
  • Thank you received: 13071
  • MODERATOR
8 months 1 week ago #354426

Hi,

You should be able to do this with this plugin :
www.hikashop.com/marketplace/product/148...ce-calculations.html
You'll need a formula like this:

{product_quantity}*({price}+intval({uploadafbeelding})*XXX)
where XXX is to be replaced by the amount you want to add to the price of the product when a file is uploaded.

Note that as this is an upload field, the price won't be updated directly when you select a file in the custom field. You need to add the product to the cart to see the price with the extra fee in the cart.

Last edit: 8 months 1 week ago by nicolas.

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

  • Posts: 49
  • Thank you received: 7
  • Hikashop Multisite
8 months 1 week ago #354450

Hi Nicolas,

Thanks for the solution to this issue. Unfortunately it doesn't do what it suppose to do.

I've created some screenshots, as you can see the price drops to 0 in the sidebar cart, at the checkout screen the price is negative. Could it be that there is a typo or something like that in the formula?

Another peculiar result is at the

This message contains confidential information
page. There the upload field is displayed at some of the category items.

Have I done something wrong? Do you need any other screenshots?

Besides this, I've got some other questions. Not related to this topic, but related to this project. Do I have to start a new topic? Or can I continue at this one?

Regards,
Ans

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

  • Posts: 81563
  • Thank you received: 13071
  • MODERATOR
8 months 1 week ago #354452

Hi,

I thought intval would work differently than how it actually works.
The formula has to be changed to:

{product_quantity}*({price}+boolval(strlen({uploadafbeelding}))*8.5)
and also, the line:
$e->fb[] = 'boolval';
needs to be added after the line:
$e->fb[] = 'str_word_count';
in the file plugins/hikashop/calculations/calculations.php of the plugin.
In my tests, it then works.

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

  • Posts: 49
  • Thank you received: 7
  • Hikashop Multisite
8 months 1 week ago #354462

Hi Nicolas,

No problem at all.

I've changed the formula in the plugin, also the line " $e->fb[] = 'boolval'; " has been added to the calculations.php file. Unfortunately the added costs aren't added, the price at checkout is still negative... Is there something else I've got to do?

Regards,
Ans

capture.dropbox.com/incI6VWypBGrMFeX

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

  • Posts: 81563
  • Thank you received: 13071
  • MODERATOR
8 months 1 week ago #354477

Hi,

That's my bad. It should be cart_product_quantity and not product_quantity in the formula so that it uses the quantity of the product in the cart, and not the stock of the product (which is -1 for unlimited, and that's why you got a negative amount).

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

  • Posts: 49
  • Thank you received: 7
  • Hikashop Multisite
8 months 1 week ago #354503

Hi Nicolas,

No problem at all, I'm very glad to let you know it now works perfectly! I'm now officially the happiest resident of my village... thanks to you! :-D

So that's cleared, and also the other issue I had [upload image section displayed on the category page] is solved.

But now I've got another question. There is a product [a cake] which can only be ordered for 30 persons or more. So the customer has to select 30 or more. The price per person is €2,90, which means the starting price is €87,- or more, depending on how many persons has been selected.
Questions are:

  • By default there can only be 15 or less ordered. That needs to be 30 or more. How can I achieve such thing?
  • What do I need to do to get the price calculated on the number of persons?

I've tried to manage something like that in the Limitations and Dimensions block, but that didn't work. Selecting 30 is no problem, but than the calculations aren't right. Do you possibly have a solution for this situation?

Regards,
Ans

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

  • Posts: 81563
  • Thank you received: 13071
  • MODERATOR
8 months 1 week ago #354513

Hi,

There are several ways to achieve this:
- One solution would be to create a characteristic with the values 30,31,32,33, etc and use that characteristic in your product for the selection of the number of personnes. Then, in each variant, you would enter the corresponding price that you would have already calculated.
- One solution would be to use the quantity as the selector of the number of persons. You would change the "quantity input" setting of the product to "show select price", and then set the prices (one for each choice you want in the quantity selector).
- One solution would be to have a custom item field with the different values you want to allow for the number of persons and limit that custom item field to this product. Then, with the price calculations plugin, add a formula like this:

{cart_product_quantity}*{price}*{xxx}
where xxx is the column name of the custom item field. That way, in the product you only need to provide the price for one person.

I think the last method is the best one.

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

  • Posts: 49
  • Thank you received: 7
  • Hikashop Multisite
8 months 1 week ago #354565

Hi Nicolas,

Thanks for the options. I've tried the last one but unfortunately I can't get it to work properly. What have I done:

  • Created a custom field, table product, field type single dropdown
  • Selected only the product involved
  • [Added several field data/li]
  • Added {cart_product_quantity}*{price}*{aantalpersonen} at the Price Calculation plugin

When I select 2 of the product, the cart counts 62. There is no option available for 30 or more, only 1 to 15 is given.
mitz.westerbos.nl/index.php/webshop/taar...erkant-vanaf-30-pers

I've enclosed an attachment where you can see the settings I've used at the custom field. Somehow or the other I've got the feeling that I should've chosen other settings.

Thanks in advance for your help!

Attachments:

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

  • Posts: 81563
  • Thank you received: 13071
  • MODERATOR
8 months 1 week ago #354566

Hi,

Sorry, I thought you already knew the differences between the different custom fields when I said you had to create a custom item field. I meant a custom field of the table "item".
Custom fields of the table "product" and for you to select things in the backend. Custom fields of the table "item" are for the customer to select things on the product details page.
You can read more about custom fields here:
www.hikashop.com/support/documentation/4...shop-field-form.html

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

  • Posts: 49
  • Thank you received: 7
  • Hikashop Multisite
8 months 1 week ago #354596

Hi Nicolas,

No "sorry" needed, if anybody has to say sorry, that would be me. You should've guessed that I'm familiar with all kind of custom field possibilities by now, unfortunately I'm a slow learner on this subject. So the helping hand is not only highly appreciated but also very much needed. That's also the reason why I have such stupid questions now and then. I'm really very sorry for that!

Back to this issue: I've created a new custom item, it shows on the product pages where I need it. So far, so good. Issues now are:

  • two buttons "add to cart"
  • input amount shown twice
Please have a look at the afb1.png screen print.

I've tried to deactivate the input amount option in the display options of the product, but that gives another issue, please see afb2.png Now the calculated price isn't added up, it stays at the price of 1 product.

Last one [for now]: when using the button 'Add to cart' controlled by the plugin, I'm getting an error popup. I've tried searching on that perticulair error, but that makes me even more confused. The error is on afb3.png.

I'm really very sorry for the many issues I'm sharing with you, I wish I could handle it all by myself. So, thanks for the help!

Regards,
Ans

Attachments:

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

  • Posts: 81563
  • Thank you received: 13071
  • MODERATOR
8 months 1 week ago #354600

Hi,

The button below the dropdown displays because you have the "add new values" setting activated in the custom field settings page.
This setting is turned off by default and should be left turned off for custom item fields as you don't want to allow customers to add new values to custom item fields. That's also why the button doesn't work since we didn't implement that capability on the frontend.

I don't see two input amount. The custom item field dropdown is to select the number of persons for each cake, and the quantity input is to select the number of cakes like that to be added to the cart at once.
Now, if you don't want to allow the customer to select the number of cakes, because it will always be 1, then you can select "none" in the "quantity input" setting of the product.
If that causes the price calculation to not work, we would need to look at the situation on the page. Could you provide a link to the page with the issue ?

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

  • Posts: 49
  • Thank you received: 7
  • Hikashop Multisite
8 months 6 days ago #354615

Hi Nicolas,

You're right, my mistake, the "add new values" setting is now off, much better!

Let me be clear with the Calculated price option: once the product is send to the cart, the price is correct. Only the calculated price underneath the dropdown shows only €2,90 capture.dropbox.com/FEnXXjmcLGfQGTkm

The products involved are only the ones with 30 persons and over, ie. mitz.westerbos.nl/index.php/webshop/taar...erkant-vanaf-30-pers

Thank you very much for all the help!

Regards,
Ans

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

  • Posts: 49
  • Thank you received: 7
  • Hikashop Multisite
8 months 6 days ago #354622

Hi Nicolas,

I just noticed the updated Price calculation plugin. It now works perfectly!

One [last, at least I hope] question. I've created a custom item field, single dropdown item type. There are numeric options to choose from. Each should cost €0,30 cents. At the Price calculation plugin I've tried to use the formula {cart_product_quantity}*{price}*{kaarsjes} That doesn't work for obvious reasons. Not the quantity of the product needs to be calculated but the €0,30
Do I have to use the Price calculation plugin for this [or maybe the Fees plugin?], and if so, what formula is best to use?

Thank you very much for your much appreciated help [and patience!].

Regards,
Ans

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

  • Posts: 81563
  • Thank you received: 13071
  • MODERATOR
8 months 6 days ago #354625

Hi,

Yes, I published a new version based on what I found on your website. I was about to write to you about it.

Regarding the new issue, I'm afraid I don't understand what you mean.
Please provide more context.

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

  • Posts: 49
  • Thank you received: 7
  • Hikashop Multisite
8 months 5 days ago #354635

nicolas wrote: Yes, I published a new version based on what I found on your website. I was about to write to you about it.

It was a coincidence that I found the updated file before your notification. And it works perfect now, so again: thank you very much for that.

nicolas wrote: Regarding the new issue, I'm afraid I don't understand what you mean.
Please provide more context.

You're right, that wasn't to the point information, I'm sorry.

On most of the products in the "Taarten en Vlaaien" category, the customer can select options. For example "kaarsjes" [candles]. You can order 1 or 30, or any other number in the dropdown field. Each candle will add €0.30 to the calculated price. So when a customer wants to order a cake which costs €28,-, and besides that 10 candles, then the calculated price should be an extra €3,-. In total: €31,-
This is only one option, but there are more of those. For example: sparkling fireworks [€2,40], a plate, fork and napkin [€0,25]. These examples are all selectable with a dropdown. Or, if you have a better idea/solution, something else.

And then there is the very last option for this category: people may want a text on their cake. Up to 25 characters is possible, which costs €2,95. So, if possible it needs a custom field with an input field, and than the €2,95 costs added to the calculated price.

I hope it is clear now, if not, please let me know. Perhaps you can take a look at the current [live] page, there you can see the 'extra options' in action. shorturl.at/uvRZ9
[Please note that the current website has another way of the "Text on cake" option. Right now: first you select "Yes/Ja" which adds the €2,95. When at the checkout, the customer can put the text in a special requests box.

Screenshot [of current live website] with some additional information:
capture.dropbox.com/Q9Zr0LyJThNd8RS4

Regards,
Ans

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

  • Posts: 81563
  • Thank you received: 13071
  • MODERATOR
8 months 5 days ago #354641

Hi,

Only one price calculation formula can be used per product.
So if you're already using as explained previously, and that formula applies to the product, the other formula won't be considered.
I think that's why your test didn't work with the "kaarsjes" custom field.
Instead of creating a new formula, you would have to modify the existing one, like so:

{cart_product_quantity}*({price}*{aantalpersonen}+{kaarsjes})
Note however that for each value of the custom field, you need to enter the price in the "value" column. So for example, 1 candle would have the value 0.3, 2 candles would have the value 0.6, etc
And you can do the same for other custom fields.
For example, to handle the candle custom field, the upload field from the beginning of this thread, the ijsfontein field of your link and a "text on tart" field (type "text area"), you would have a formula like so:
{cart_product_quantity}*({price}*{aantalpersonen}+{kaarsjes}+boolval(strlen({uploadafbeelding}))*8.5+{ijsfontein}+boolval(strlen({tekstoptaart}))*2.95)

So you can have many custom fields of different types and the system will calculate the total price based on the different values provided by the customer in those fields thanks to one formula.

The following user(s) said Thank You: Ans van Tongeren

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

  • Posts: 49
  • Thank you received: 7
  • Hikashop Multisite
8 months 4 days ago #354662

Hi Nicolas,

Thank you so much for you detailed explanation, I'm going to give this a try later today. I'll keep you posted!

Regards,

Ans

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

  • Posts: 49
  • Thank you received: 7
  • Hikashop Multisite
8 months 3 days ago #354719

Hi Nicolas,

I'm very sorry, but I just can't get it to produce the right price. These are the custom fields column names:

  • uploadafbeelding > item field + file
  • personen30 > item field + single dropdown
  • kaarsjes > item field + single dropdown
  • ijsfontein2 > item field + single dropdown
  • bvs > item field + single dropdown
  • [tot > item field + text area/li]

Your formula uses a few other column names, so I've changed them in the used formula. This is what I got right now:
{cart_product_quantity}*({price}*{personen30}+{kaarsjes}+boolval(strlen({uploadafbeelding}))*8.5+{ijsfontein2}+{bvs}+boolval(strlen({tot}))*2.95)

Question, one probably from the category very stupid: right now there is only this formula, no other formulas are being used in the Price Calculations Plugin. Is that how it should be?

Regards,

Ans

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

  • Posts: 81563
  • Thank you received: 13071
  • MODERATOR
8 months 3 days ago #354721

Hi,

I said that only one formula would apply for one product, but you can have different formulas for different products.

There is no uploadafbeelding and no personen30 custom fields on the product page of your URL.
So the formula in your post will be discarded by the plugin for that product.
The plugin will only process the formula where all the tags match with custom fields displayed on the page. So you will need different formulas for different products if they have different custom item fields.

Last edit: 8 months 3 days ago by nicolas.

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

Time to create page: 0.100 seconds
Powered by Kunena Forum