Try the Demo

Magento

eCommerce Software for Online Growth

Magento Forum

Our new hosted solution for small & emerging businesses
   
Page 1 of 3
dynamic calculation of a price
 
skrime
Jr. Member
 
Total Posts:  24
Joined:  2009-07-09
 

Hi everybody,
I am a beginner on Magento and I need some help !

- I ve got a product with 2 options (width and length), is it possible to make a dynamic multiplication of this 2 values and to multiplicate this by a price ?
(ex : width 1200 mm height 1000mm
surface = 1200*1000 = 1200000
price on mm² = 0.00001€
price = 0.00001*1200000 = 12€

Thank for your help

 
Magento Community Magento Community
Magento Community
Magento Community
 
jroakes
Jr. Member
 
Total Posts:  19
Joined:  2008-08-09
 

There is nothing for this.  If there were I would be jumping up and down and doing cartwheels right now.  I don’t ever see this happening unless you pay someone to hack the software for you.  There have been a number of people asking for this for a long while and no dice from the developers or extension developers.

 
Magento Community Magento Community
Magento Community
Magento Community
 
skrime
Jr. Member
 
Total Posts:  24
Joined:  2009-07-09
 

thanks a lot, I have adapted your script and it works, but when I add the product to the cart this is the original price (not the price calculate dynamicly)
How can I change the price in the cart ? or the inserted price ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
skrime
Jr. Member
 
Total Posts:  24
Joined:  2009-07-09
 

Hi, thanks for you reply, I will assign 25€ as the base price…
thanks in advance

 
Magento Community Magento Community
Magento Community
Magento Community
 
skrime
Jr. Member
 
Total Posts:  24
Joined:  2009-07-09
 

No, it will be : (25 + (height custom option x width custom option x 0.00001))

 
Magento Community Magento Community
Magento Community
Magento Community
 
skrime
Jr. Member
 
Total Posts:  24
Joined:  2009-07-09
 

yes it’s true

no problems smile thanks for your help

 
Magento Community Magento Community
Magento Community
Magento Community
 
skrime
Jr. Member
 
Total Posts:  24
Joined:  2009-07-09
 

Thanks a lot for your reply ! It works !

 
Magento Community Magento Community
Magento Community
Magento Community
 
Sam Granger
Member
 
Total Posts:  65
Joined:  2007-09-13
 

Nice stuff guys!

Just a few questions about this code. Does it take Tier Pricing into consideration, ifnot, how can I get this code to do so? And secondly, isn’t it a bad idea to medit core code? Isn’t it a better idea to extend the class in local?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Sam Granger
Member
 
Total Posts:  65
Joined:  2007-09-13
 

dd_gi, that would be awesome if you could!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brother Bui
Jr. Member
 
Total Posts:  14
Joined:  2009-05-06
 

Thank you very much for your post.

And I have a question, wish you help me to answer.

I need to be able to set a minimum and maximum width, minimum and
maximum height. How do I validate the width and height input
by the customer? And of course, if the value is not valid, the customer
cannot continue.

Thanks in advance

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brother Bui
Jr. Member
 
Total Posts:  14
Joined:  2009-05-06
 
dd_gi - 17 September 2009 10:55 AM

Would all products that have height/width custom options have the same limits?

No, each product type has its own limits.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brother Bui
Jr. Member
 
Total Posts:  14
Joined:  2009-05-06
 
dd_gi - 17 September 2009 07:32 PM

In that case you will need to use product attributes to define those limits, the easiest way to add those are when you are viewing a product, select a tab in the product’s details where you want to add the limits, then select add.  You would add width_min width_max height_min height_max

Then we can use those in the code.  How do you want the front-end entry to be accomplished (text input, select list)?
If you want select list, what increment do you want as you go from low to high (0.01)?

Dear dd_gi,
Yes, we should add the min and max width, height for products.
I have two product types:
The first one is fixed width (the customer can select width from dropdown list, such as: 10cm, 20cm, 30cm.... This width list I will add for products in admin, and of course it’s fixed list) and he must type the height he wants in a textbox. In this case, we need only validate the height.
The second one is dynamic width and height, it means, the customer can input any width and height in textbox.

I need to validate the value input by the customer, the condition is: min <= inputvalue <= max.

And the customer can input any inputvalue, it can be: 50, 63.5, even 70.546....

I need only validate the value to meet the condition above. And produce the errors if it not meet.

Thank you.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brother Bui
Jr. Member
 
Total Posts:  14
Joined:  2009-05-06
 
dd_gi - 17 September 2009 09:51 PM

This should be workable, I will need to look at how Varien does the front-end validation, possibly we can call those functions for this task.  It would be easy enough to feed this info by the way of a var that we dynamically assign based on existence and value of the min/max attributes.  I likely won’t be able to work on this for a couple days but I will look at this and it should be an easy enough fix.

I look forward to hear from you soon.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Sam Granger
Member
 
Total Posts:  65
Joined:  2007-09-13
 

I uploaded the options.phtml & js, now, when I add the custom options and try to add the product I get the following error: Can not add item to shopping cart

Weird right? :(

Anyone know what might be causing this? Thanks for the code so far! smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
Sam Granger
Member
 
Total Posts:  65
Joined:  2007-09-13
 

Please ignore my previous post, it’s wqorking now, guess it was a database quirk on my side smile Just the dynamic js price update doesnt want to work :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
Sam Granger
Member
 
Total Posts:  65
Joined:  2007-09-13
 

Sorry sorry sorry, I’m an idiot. I have a local version and a live version, I uploaded the js and phtml to the luve version and not the local version. I’m a dipstick! Please excuse my sillyness, it works like a charm! Thank you very much for helping! Great work!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 1 of 3
 
© Copyright Magento Inc.
Privacy Policy|Terms of Service
Magento Community Count
819302 users|768 users currently online|519717 forum posts