chuckstar_za Posted April 23, 2010 Share Posted April 23, 2010 Hi.I'm looking at using PS as a new solution for the next stage in development of my canvas framing business. Currently I have numerous categories for every size canvas that I can make. Everything from 20cm x20cm up to 200cm x 200cm (and all permutations inbetween).Quite a few customers have remarked that this method can be confusing and too many clicks - this implies I'm losing a lot of sales. So I'd like to simplify the system.As each size is essentially the same product I'd like to have one product, but allow the customer to specify the size (width x height) which would change the cost accordingly (I have tables of each sizes' cost). Something like what they have done here would be fantastic: http://www.woodeos.com/product.php?id_product=15 (though that looks like some heavy JS coding with Away3D) In addition, each canvas can come in two variants - primed/unprimed and 38mm/50mm depth. These I'd like to have as +% increase attributes rather than fixed +£ increases because the cost of them increases as the bars get longer/surface area increases. Is such a thing possible with PS? (the JS solution obviously is, though may be an overly elegant solution to a fairly simple problem - and it uses PS as a back end.)Thanks for your input. Link to comment Share on other sites More sharing options...
chuckstar_za Posted April 26, 2010 Author Share Posted April 26, 2010 No one got an answer to this? Link to comment Share on other sites More sharing options...
rocky Posted April 27, 2010 Share Posted April 27, 2010 I think this could be quite tricky. I suggest looking at lines 1266-1267 of classes/Product.php (in Prestashop v1.2.5): if (isset($result['attribute_price'])) $price += $attribute_price; This code adds the attribute to the price. Try changing it to the following: if (isset($result['attribute_price'])) $price *= $attribute_price; If you enter the attribute price as 0.9, this code should reduce the price by 10% instead of adding $0.90 to the price. You may also need to edit the last section of the updateDisplay() function in js/product.js in your theme's directory for the price to work. Link to comment Share on other sites More sharing options...
chuckstar_za Posted April 27, 2010 Author Share Posted April 27, 2010 Thank you for the reply.I'll give that a go Link to comment Share on other sites More sharing options...
Prinfor Posted June 13, 2010 Share Posted June 13, 2010 I think this could be quite tricky. I suggest looking at lines 1266-1267 of classes/Product.php (in Prestashop v1.2.5): if (isset($result['attribute_price'])) $price += $attribute_price; This code adds the attribute to the price. Try changing it to the following: if (isset($result['attribute_price'])) $price *= $attribute_price; If you enter the attribute price as 0.9, this code should reduce the price by 10% instead of adding $0.90 to the price. You may also need to edit the last section of the updateDisplay() function in js/product.js in your theme's directory for the price to work.[/quoteI there Rocky, can you please tell what to change in product.js, i want to have attributes with increase of price by percentage, thanks a lot Link to comment Share on other sites More sharing options...
rocky Posted June 14, 2010 Share Posted June 14, 2010 Now that I look at it, I think you need to modify admin/tabs/AdminAttributeGenerator.php instead of product.js so that it multiplies instead of adding. Change line 26 from: $price += floatval($_POST['price_impact'][intval($attr)]); to: $price *= floatval($_POST['price_impact'][intval($attr)]); Link to comment Share on other sites More sharing options...
Prinfor Posted June 14, 2010 Share Posted June 14, 2010 Now that I look at it, I think you need to modify admin/tabs/AdminAttributeGenerator.php instead of product.js so that it multiplies instead of adding. Change line 26 from: $price += floatval($_POST['price_impact'][intval($attr)]); to: $price *= floatval($_POST['price_impact'][intval($attr)]); Thanks friend, but it still not working, maybe some other files to change? Thanks in advance Link to comment Share on other sites More sharing options...
rocky Posted June 14, 2010 Share Posted June 14, 2010 Did you go to the Product Combinations Generator and regenerate the combinations using percentage price impacts like 0.9 after making the code change? Link to comment Share on other sites More sharing options...
J. R. Leon Somovilla Posted July 9, 2010 Share Posted July 9, 2010 I´m making my investements about this post ;-), the code is written, now is time to make tests ;-).root/classes/Product.php if (isset($result['attribute_price'])) if ($attribute_price >0) { $price += $attribute_price; } else { $price *= $attribute_price; } root/admin/tabs/AdminAttributeGenerator.php if ($_POST['price_impact']>0) { $price += floatval($_POST['price_impact'][intval($attr)]) } else { $price *= floatval($_POST['price_impact'][intval($attr)]) } My idea is to make an hybrid solution..., if you put the atribute higher than 0, use the base method, but if you put an atribute percent like: 0.12, you use a percentage increase.What do you think about?, do you like it? ;-) Link to comment Share on other sites More sharing options...
rocky Posted July 9, 2010 Share Posted July 9, 2010 Sure, I would appreciate it if you could post a full solution to this "attribute as percentage increase" problem. I have someone asking me for a solution to this problem right now, but I don't feel like hacking PrestaShop at the moment. Link to comment Share on other sites More sharing options...
J. R. Leon Somovilla Posted July 14, 2010 Share Posted July 14, 2010 Another anotation:root/js/attributesBack.js if (price_impact < 0) { getE('attribute_price_impact').options[getE('attribute_price_impact').selectedIndex].value = -1; getE('attribute_price_impact').selectedIndex = 2; } else if (!price_impact) { getE('attribute_price_impact').options[getE('attribute_price_impact').selectedIndex].value = 0; getE('attribute_price_impact').selectedIndex = 0; } else if (price_impact > 0) { getE('attribute_price_impact').options[getE('attribute_price_impact').selectedIndex].value = 1; getE('attribute_price_impact').selectedIndex = 1; } if (weight_impact < 0) { getE('attribute_weight_impact').options[getE('attribute_weight_impact').selectedIndex].value = -1; getE('attribute_weight_impact').selectedIndex = 2; } I think, there´s the key ;-) Link to comment Share on other sites More sharing options...
jobatkin Posted July 26, 2010 Share Posted July 26, 2010 I know this topic is old now, but I found it really useful in accomplishing the same task - applying price impacts using multipliers instead of addition. My site has many items which can be bought singly or in bulk packs, and I needed to multiply the original price by a modifier instead of adding to it incrementally.I followed the above suggestions but could not get a complete solution. Here's all the changes I ended up making:In admin/tabs/AdminProducts.php, I slightly changed the user interface to reflect the new behaviour. I changed '.$this->l('of').' '.($currency->format == 1 ? $currency->sign.' ' : '').' to x In admin/tabs/AdminAttributeGenerator.php, I changed $price += floatval($_POST['price_impact'][intval($attr)]); to $price *= floatval($_POST['price_impact'][intval($attr)]); In classes/Product.php I changed $price += $attribute_price; to $price *= $attribute_price; and after doing this I thought I'd done it. But when viewing my product in the front end, the correct multiplied price would show for a few seconds, and then it would change back to the old added price when the javascript loaded. Took me a while to find where this was happening but eventually I changed themes//js/product.js var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) + productPriceWithoutReduction); to var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) * productPriceWithoutReduction); And now it all seems to be working well. Hope this helps someone else. 1 Link to comment Share on other sites More sharing options...
J. R. Leon Somovilla Posted July 26, 2010 Share Posted July 26, 2010 Thanks Jobatkin!.Tomorrow at first time in the morning, i will try it ;-).Best regards,J.R. León Link to comment Share on other sites More sharing options...
wills1234 Posted December 2, 2010 Share Posted December 2, 2010 Hi, first of all thanks for solution.I tried the Jobatkin solution for pplying price impacts using multipliers but I have a problem.It runs very fine in the products that have atributtes with price impact, but in products without atributtes or without atributtes with price impact the price showed is "0.00".This is a proble because I have a lots of products without atributtes.Can anyone help me to fix this.P.D. Sorry for my English. Link to comment Share on other sites More sharing options...
wills1234 Posted December 3, 2010 Share Posted December 3, 2010 Hi I try a modification to fix the problem with products without price impact. But don't worksA need a little help because i noob in all thisIn classes/Product.php I changed $price *= $attribute_price; to if (($attribute_price > 0) && ($attribute_price <= 1)) $price *= $attribute_price; else $price += $attribute_price; And i changed in themes//js/product.js var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) * productPriceWithoutReduction); to if (attribut_price_tmp > 0 && (attribut_price_tmp <=1)) var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) * productPriceWithoutReduction); else var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) + productPriceWithoutReduction); Anyone have a suggestion to do it better. Link to comment Share on other sites More sharing options...
wills1234 Posted December 3, 2010 Share Posted December 3, 2010 Finally think i got the solution, if you are interested can take a look at this post:http://www.prestashop.com/forums/viewthread/78364/discusin_general/generar_atributos_con_porcentaje_y_cantidad_simultneos_dot_/ Link to comment Share on other sites More sharing options...
bazsmith Posted February 14, 2011 Share Posted February 14, 2011 Hello All,I have coped very well so far with the installations using prestashop, sure beats OsComm!this being my first post as i have came up blank on this one.I have followed the following postshttp://www.prestashop.com/forums/viewthread/78364/and this one,i used the following mods to try to make this work:Change: admin/tabs/AdminProducts.php, '.$this->l('of').' '.($currency->format == 1 ? $currency->sign.' ' : '').' to x Change: admin/tabs/AdminAttributeGenerator.php, $price *= floatval($_POST['price_impact'][intval($attr)]); to: if (($attribute_price >= -1) && ($attribute_price < 0)) $price *= floatval($_POST['price_impact'][intval($attr)]); elseif (($attribute_price > 0) && ($attribute_price <= 1 )) $price *= floatval($_POST['price_impact'][intval($attr)]); else $price += floatval($_POST['price_impact'][intval($attr)]); Change: classes/Product.php $price += $attribute_price; to if (($attribute_price >= -1) && ($attribute_price < 0)) $price *= $attribute_price; elseif (($attribute_price > 0) && ($attribute_price <= 1 )) $price *= $attribute_price; else $price += $attribute_price; Change: themes//js/product.js var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) * productPriceWithoutReduction); to; if (attribut_price_tmp >= -1 && (attribut_price_tmp < 0)) var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) * productPriceWithoutReduction); else if (attribut_price_tmp > 0 && (attribut_price_tmp <= 1)) var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) * productPriceWithoutReduction); else var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) + productPriceWithoutReduction); My problem seems to be this.The attributes when input as a 0.1 will calculate a percentage of 10%but it is not adding this to the base price, instead it is just showing the percentage valueeg. £100 base price + 10% should show £110instead it is displaying £10any attribute with a 1> will add the value as normaleg. £100 base price + £25 shows £125So the only problem is, is that the percentage increment is not adding itself to the base price,can any one see where there may be a fix from the above code?or if i have missed anything out from the two posts.As I mentioned, i followed the two posts noted, and put together the above from all the chops and changes from the posts.I know this post is a little old, but I hope others out there are still reading this.Thanks in advance to all contributorsBaz. Link to comment Share on other sites More sharing options...
wills1234 Posted February 15, 2011 Share Posted February 15, 2011 Hi,The finally of this modifications is reduce the base price to a percentage of itself.If you want to reduce the base price, for example a discount of 15%, (base price = 100€ atribute price = 100€ - 15% = 85€) the price impact have to be 0.85 (1 - 0.15).Otherwise if you want to increase the price in a percentage you have to modifiy the code erasing the conditions that contains <=1 or >= -1:In AdminAttributeGenerator.php,Change if (($attribute_price >= -1) && ($attribute_price < 0)) $price *= floatval($_POST['price_impact'][intval($attr)]); elseif (($attribute_price > 0) && ($attribute_price <= 1 )) $price *= floatval($_POST['price_impact'][intval($attr)]); else $price += floatval($_POST['price_impact'][intval($attr)]); To if ($attribute_price < 0) $price *= floatval($_POST['price_impact'][intval($attr)]); elseif ($attribute_price > 0) $price *= floatval($_POST['price_impact'][intval($attr)]); else $price += floatval($_POST['price_impact'][intval($attr)]); In Product.phpChange if (($attribute_price >= -1) && ($attribute_price < 0)) $price *= $attribute_price; elseif (($attribute_price > 0) && ($attribute_price <= 1 )) $price *= $attribute_price; else $price += $attribute_price; To if ($attribute_price < 0) $price *= $attribute_price; elseif ($attribute_price > 0) $price *= $attribute_price; else $price += $attribute_price; And in product.jsChange if (attribut_price_tmp >= -1 && (attribut_price_tmp < 0)) var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) * productPriceWithoutReduction); else if (attribut_price_tmp > 0 && (attribut_price_tmp <= 1)) var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) * productPriceWithoutReduction); else var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) + productPriceWithoutReduction); to if (attribut_price_tmp < 0) var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) * productPriceWithoutReduction); else if (attribut_price_tmp > 0) var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) * productPriceWithoutReduction); else var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) + productPriceWithoutReduction); Now you can increase the price for example a 15% putting 1.15 in the input of price impact.I hope this help you.In fact this fix code is redundant now, i do it fast but i think it works, if don't works tellme and i'll take a look slowly. Link to comment Share on other sites More sharing options...
bazsmith Posted February 15, 2011 Share Posted February 15, 2011 Just tried this on a small amount of attributes, works a treat so far, i will test further with all attributes required.this should definatley be made into an installable moduleThanks for your quick response wills1234 :-) Link to comment Share on other sites More sharing options...
bazsmith Posted February 15, 2011 Share Posted February 15, 2011 Just another note to wills1234, you mention that this code is now redundant, does this mean there is an alternative for this, if so can you elaborate.ThanksBaz Link to comment Share on other sites More sharing options...
wills1234 Posted February 16, 2011 Share Posted February 16, 2011 Hi, How you surely always are going to use positive numbers you can erase the condition <0. In AdminAttributeGenerator.php,Change if ($attribute_price < 0) $price *= floatval($_POST['price_impact'][intval($attr)]); elseif ($attribute_price > 0) $price *= floatval($_POST['price_impact'][intval($attr)]); else $price += floatval($_POST['price_impact'][intval($attr)]); to if ($attribute_price > 0) $price *= floatval($_POST['price_impact'][intval($attr)]); else $price += floatval($_POST['price_impact'][intval($attr)]); In Product.phpChange if ($attribute_price < 0) $price *= $attribute_price; elseif ($attribute_price > 0) $price *= $attribute_price; else $price += $attribute_price; to if ($attribute_price > 0) $price *= $attribute_price; else $price += $attribute_price; And in product.jsChange if (attribut_price_tmp < 0) var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) * productPriceWithoutReduction); else if (attribut_price_tmp > 0) var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) * productPriceWithoutReduction); else var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) + productPriceWithoutReduction); to if (attribut_price_tmp > 0) var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) * productPriceWithoutReduction); else var productPriceWithoutReduction2 = (ps_round(attribut_price_tmp * currencyRate) + productPriceWithoutReduction); This is only a fix that solves specific needs, it is so far to become a module. I take a look at the last RC version and is still not possible to create attributes that change the price in a percentage.So. we will have to keep on waiting. Link to comment Share on other sites More sharing options...
pohodak Posted April 24, 2011 Share Posted April 24, 2011 How to solve this problem in version 1.4? Link to comment Share on other sites More sharing options...
wills1234 Posted April 24, 2011 Share Posted April 24, 2011 How to solve this problem in version 1.4? Sorry but i can't take a look to 1.4 yet. I will try to do it the next week. Link to comment Share on other sites More sharing options...
wills1234 Posted June 13, 2011 Share Posted June 13, 2011 Hi, first of all I apologize for take so long to post a replay, but i've been a little busy these days.I am testing prestashop 1.4.2.5 now, and a tried to make these modifications work on it doing the following changes to the originall files of prestashop 1.4.2.5.In admin/tabs/AdminAttributeGenerator.php,Change $price += (float)($_POST['price_impact_'.(int)($attr)]); $weight += (float)($_POST['weight_impact'][(int)($attr)]); to if (($attribute_price > 0)) $price *= (float)($_POST['price_impact'][(int)($attr)]); else $price += (float)($_POST['price_impact'][(int)($attr)]); $weight += (float)($_POST['weight_impact'][(int)($attr)]); In admin/tabs/AdminProducts.php,Change '.$this->l('of').' '.($currency->format % 2 != 0 ? $currency->sign.' ' : '').' to x In classes/Product.phpChange if ($id_product_attribute !== false) // If you want the default combination, please use NULL value instead $price += $attribute_price; to if (($attribute_price > 0)) $price *= $attribute_price; else $price += $attribute_price; so far i think it is all correct, i test a little and all seems to work fine. But i have problems to get the correct display price in the product page. I did the following.in themes//js/product.jsChange var taxExclPrice = (specific_price ? (specific_currency ? specific_price : specific_price * currencyRate) : productPriceTaxExcluded) + combination_add_price * currencyRate; to if (selectedCombination['price'] = 0 ) var taxExclPrice = (specific_price ? (specific_currency ? specific_price : specific_price * currencyRate) : productPriceTaxExcluded) + (combination_add_price * currencyRate); else var taxExclPrice = (specific_price ? (specific_currency ? specific_price : specific_price * currencyRate) : productPriceTaxExcluded) * combination_add_price * currencyRate; Whit this change the price displayed is correct when the attribute has a price impact different from zero.But when the price impact is equal to 0 the price displayed is 0.00, if you add to cart, in blockcart the price is correct. Now to get this work well, if you do not want that the attribute has an impact on the price, you have to define the price impact is equal to 1. I think it is better that if you don't to modify the price in an attribute ther price impact should be 0 but i can't get this.I am doing something wrong but i don't know what it is.If anyone that knows a little more than me about this code can take a look and give us any suggestions we would be so grateful.Best regards. Link to comment Share on other sites More sharing options...
betyonfire Posted November 5, 2012 Share Posted November 5, 2012 Anyone ever get the pricing to work by percent in 1.4, or now, 1.5? Thanks Link to comment Share on other sites More sharing options...
mrjsanderson Posted February 2, 2013 Share Posted February 2, 2013 I would love an update on this for 1.5. It looks like most of the hard work has been done. I just need some help applying this to the new files in 1.5. Link to comment Share on other sites More sharing options...
mysterion Posted February 27, 2013 Share Posted February 27, 2013 Anyone tested this on 1.5 yet? Link to comment Share on other sites More sharing options...
carras Posted May 22, 2013 Share Posted May 22, 2013 Does anyone have the key for this? Link to comment Share on other sites More sharing options...
mowax Posted September 30, 2014 Share Posted September 30, 2014 Does anyone know how to do this for PS1.5?? Link to comment Share on other sites More sharing options...
lier Posted September 21, 2015 Share Posted September 21, 2015 (edited) heloo, PS 1.6 ? Product.php its ok, but predoct.js, it is different like 1.4. SOLVED: product.js basePriceWithoutTax = basePriceWithoutTax + combination.price; to basePriceWithoutTax = basePriceWithoutTax * combination.price; Edited September 21, 2015 by lier (see edit history) Link to comment Share on other sites More sharing options...
szymmszy Posted December 12, 2015 Share Posted December 12, 2015 (edited) Had someone figured out this solution in PS 1.6 ? Anyone? Edited December 12, 2015 by szymmszy (see edit history) Link to comment Share on other sites More sharing options...
hatak Posted February 3, 2016 Share Posted February 3, 2016 Code for PS 1.6.1.2 change (or add override) Product.php // If you want the default combination, please use NULL value instead if ($id_product_attribute !== false) { $price += $attribute_price; } to // If you want the default combination, please use NULL value instead if ($id_product_attribute !== false) { if ($attribute_price==0 || $attribute_price >2) { $price += $attribute_price; } else { $price *= $attribute_price; } } change Product.js (in template directory) // Apply combination price impact (only if there is no specific price) // 0 by default, +x if price is inscreased, -x if price is decreased basePriceWithoutTax = basePriceWithoutTax + +combination.price; basePriceWithTax = basePriceWithTax + +combination.price * (taxRate/100 + 1); to // Apply combination price impact (only if there is no specific price) // 0 by default, +x if price is inscreased, -x if price is decreased if (combination.price==0 || combination.price >2) { basePriceWithoutTax = basePriceWithoutTax + +combination.price; basePriceWithTax = basePriceWithTax + +combination.price * (taxRate/100 + 1); } else { basePriceWithoutTax = basePriceWithoutTax * combination.price; basePriceWithTax = basePriceWithTax * combination.price * (taxRate/100 + 1); } Codes placed above don't work with specific price (in the same time with the same attribute) You have to use "increase" impact in range: 0.00<x<2.00 where i.e 0.90 is 90% and 1.10 is 110% of original price if u want to have wider range like 300% You have to change only number 2 to 3 in codes above. Link to comment Share on other sites More sharing options...
peterextras Posted May 6, 2016 Share Posted May 6, 2016 isnt work after change, my store wasnt unavalilable Link to comment Share on other sites More sharing options...
Paolo68 Posted October 14, 2016 Share Posted October 14, 2016 For prestashop 1.6.x I have change the file FILE CLASSE PRODOTTI.PHP Variazione calcolo riga 3041 FILE JS THEMA/JS/PRODUCT.JS Variazione calcolo riga 623 circa But I don't find where change AdminAttributeGenerator 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