sokpet Posted August 29, 2010 Share Posted August 29, 2010 Hello.Coming back to customized product page for On the fly calculation of Length and Width.1. There is a basic price of the item (in my case I consider it as price per 1 linear meter)So I regestered a new function in init.php $smarty->register_function('on_the_fly', array('Tools', 'displayPriceSmarty')); I added new function in js/tools.js (not in themes/../js/ tools.js!) as follows: function on_the_fly(formObj){ var length = new Number(formObj.frameLength.value); var width = new Number(formObj.frameWidth.value); var basePrice = ((2 * length) + (2 * width))/100; var price = basePrice * MainPrice; formObj.total.value = price.toFixed(2); ; } Afterwords I made some changes in product.tpl as follows:1. Adding new variable, so we can get BASE prive of the item var MainPrice = '{$product->getPrice(true, $smarty.const.NULL)}'; 2. Adding extra price (which is supposed to be Price for linear meter). In my case only has to work with certain categories! Changing class and id names seems to be important, so the attributes do not add on for this price. <!--Linear meter price only for Marcos a medida--> {if $category->id==8 || id==9 || id==10 || id==11 || id==12 || id==13 || id==14 || id==15 || id==16 || id==17} {l s='Metro lineal - '} {if !$priceDisplay || $priceDisplay == 2} {convertPrice price=$product->getPrice(true, $smarty.const.NULL)} {if $tax_enabled}{l s='tax incl.'}{/if} {/if} {/if} 3. Adding extra fields for Lengh and Width and Subtotal Price in the buy_block form <!-- on the fly calculator --> {if $category->id==8 || id==9 || id==10 || id==11 || id==12 || id==13 || id==14 || id==15 || id==16 || id==17} {l s='Altura (cm):'} <input type="text" name="frameLength"><span class="medida_example">(Ej: 80.27) {l s='Anchura (cm):'} <input type="text" name="frameWidth"><span class="medida_example">(Ej: 110.12) {l s='Subtotal'} <input id="total" name="total" disabled="disabled" value=""/> {/if} > 4. Moved Price with VAT after Attributes, so in my case it should work as TOTAL PRICE <!-- final price --> {l s='Precio total:'} {if !$priceDisplay || $priceDisplay == 2} {convertPrice price=$product->getPrice(true, $smarty.const.NULL)} {if $tax_enabled}{l s='tax incl.'}{/if} {/if} So now comes questions. Till now I get the result in <input id="total" name="total" disabled="disabled" value=""/> Till now it works correct. See the attachement print screen. But now I need to use this result.So, what is the best way to assign this result, frameWidth and frameLength as variable, so it can be used for further calculations? Because all attributes have to be added on the top of "Result price"Is it Product.php (classes) which is responsable for formula calculations?I need some help to continue. Link to comment Share on other sites More sharing options...
Optic Posted September 21, 2010 Share Posted September 21, 2010 I don't have the answer for you, but this functionality is badly needed! Link to comment Share on other sites More sharing options...
xfera Posted October 27, 2010 Share Posted October 27, 2010 Hello. I need this function. Please send the final version if it is ready and functional. Thanks. Link to comment Share on other sites More sharing options...
Pshopic Posted October 28, 2010 Share Posted October 28, 2010 That is great work. I liked it. It will be good if your publish your final version Link to comment Share on other sites More sharing options...
sintl Posted January 6, 2011 Share Posted January 6, 2011 Hi Sokpet,Have you made the module, i am interested working with together on similar need. Link to comment Share on other sites More sharing options...
tomlotgerink Posted March 11, 2011 Share Posted March 11, 2011 I like to buy the final module! Pleas contact me! Link to comment Share on other sites More sharing options...
Antoni0 Posted May 12, 2011 Share Posted May 12, 2011 Hola, alguien ha encontrado la solucion? Link to comment Share on other sites More sharing options...
BossThemes Posted July 16, 2011 Share Posted July 16, 2011 Hello, we have developed a solution for this, if anybody needs this functionality please send PM. Thank you. 1 Link to comment Share on other sites More sharing options...
simberak Posted February 17, 2012 Share Posted February 17, 2012 Hello it looks like you very understand this. I need simple thing - to display only base price on product-list.tpl, now it calculated like this: base price + attribute price impact, wich is bad... Can you help me please? I can send some money to your Paypal if it will works, but I am student, so I cant afford to much It would be very kind from you to help me... Thanks Link to comment Share on other sites More sharing options...
sergio555 Posted January 3, 2013 Share Posted January 3, 2013 Hello, price? Hello, we have developed a solution for this, if anybody needs this functionality please send PM. Thank you. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now