Manipulating user input for price calculations

  • Posts: 57
  • Thank you received: 1
4 years 2 months ago #327841

Hi guys,

I have the height/width plugin installed to be able to calculate the price on cm2. This works fine, but the price should be just a little bit different and so I wish to "manipulate" the users input.

I cut signs for on cars/vans and I buy my supplies on a roll that's either 30.5cm wide of 61cm wide.
If someone wants to order a sign that's 100x10cm, I will have to purchase a 30.5cm roll. With my current price per cm2 I will therefor spend more then I will earn and will have to charge the customer atleast 100x15cm. Therefor I need to "recalculate" the height that's been given by the customer with the following:

roundup( height / 15 ) * 15 (with 10cm as height it will return 15, with 16 as height it will return 30 and so on) but only when all items are being put in the cart ofcourse.

and use that to multiply by the width for the total cm2 and multiply that by the price per cm2.

This would mean that the price of one 100x15cm will be the same as three 100x5cm, so finally, I want to add an x amount per quantity ordered.

My cutter won't really mind making one of 100x15cm of three of 100x5cm, but I will have the handling cost for applying the transfer tape.

After all these calculations, I give 15% discount for 5+ and 25% discount for 10+, but I recon I can make a coupon for that to take care of that.

I wonder if this can be done.

[Moderator :] Please, don't edit your message a long time after have posted it. This can mess up with ticket system, and will result in longer response.
Thanks for your attention times

Last edit: 4 years 2 months ago by Philip.

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

  • Posts: 83404
  • Thank you received: 13498
  • MODERATOR
4 years 2 months ago #327843

Hi,

It sure can be done. You need to edit the main file of the height/width plugin and add custom code to modify the value of the custom fields based on your specific rules.
A PHP developer should have no problem working on that for you if you're not a developer yourself.
We have a list of developers you can contact here if necessary:
www.hikashop.com/home/our-partners.html

The following user(s) said Thank You: Borburgh

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

  • Posts: 57
  • Thank you received: 1
4 years 2 months ago #327854

Thanks Nicolas,

I've now edited the file and changed the two lines to

$quantity = $quantity*$product->length*round(($product->width/15),0)*15;

That works, but will test some more when having multiple items in the cart.

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

  • Posts: 57
  • Thank you received: 1
4 years 2 months ago #327859

Got it all working now :) Thanks for the pointer in the right direction.

Would it be wise to completely rename the plugin to have it work with 2 different custom fields to make sure it won't interfere with future calculations?

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

  • Posts: 83404
  • Thank you received: 13498
  • MODERATOR
4 years 2 months ago #327860

Hi,

You could rename the plugin. However, there is no auto update system for the plugins of our marketplace so you won't get your changes overwritten in the future unless you yourself manually install again the install package of that plugin without the modifications. So it should not be necessary.

The following user(s) said Thank You: Borburgh

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

  • Posts: 57
  • Thank you received: 1
4 years 2 months ago #327866

Thanks Nicolas.
Have a great new year and best wishes for the team for 2021. A year in which I will bother you again ;)

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

  • Posts: 83404
  • Thank you received: 13498
  • MODERATOR
4 years 2 months ago #327874

Hi,

Thanks ! Have a great new year too and best wishes for 2021 ! Hopefully, it will be better than 2020 !

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

Time to create page: 0.065 seconds
Powered by Kunena Forum