3cubes Posted April 7, 2014 Share Posted April 7, 2014 Hello everyone,in prestashop on product detail page I have created a form wizard asking the customer some questions about customizing the product. All answers are stored in variables via javascript. In this js file there is also a new final price of the product calculated as product customization depends on customer input of width and lenght of the product.So finally I have a form with some hidden input fields which fetch all the values of the custom wishes like custom width, custom height, custom shape, custom price and so on which could be send to cart controller. <form {if $PS_CATALOG_MODE AND !isset($groups) AND $product->quantity > 0}class="hidden"{/if} action="{$link->getPageLink('cart')}" method="post"> <input type="hidden" name="token" value="{$static_token}" /> <input type="hidden" name="id_product" value="{$product->id|intval}" id="product_page_product_id" /> <input type="hidden" name="add" value="1" /> <input type="hidden" name="id_product_attribute" id="idCombination" value="" /> <input type="hidden" name="customordertext" id="customordertext" value="" /> <input type="hidden" name="customfinalprice" id="customfinalprice" value="" /> <label>Menge: </label><input type="text" name="qty" id="quantity_wanted" class="text" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 1}{$product->minimal_quantity}{else}1{/if}{/if}" size="2" maxlength="3" {if $product->minimal_quantity > 1}onkeyup="checkMinimalQuantity({$product->minimal_quantity});"{/if} /> <input type="submit" value="In den Warenkorb" name="submit" class="exclusive"> </form> But now when I click on "add to cart" of course the standard product is added to the cart with standard price. How can I achieve that custom final price is added to the cart along with my custom input variables like mentioned above??I just dont know to send my additional data created with javascript to cart. I thought of creating new rows withing database table of cart or cart_product to save custom price and custom text (just a text string with custom options) when adding product to cart. Same time in cart controller I think I have to override one or more methods to check if recently added product to cart has value for custom price saved in database so the controller can change the price in cart with the custom price. Also I have to show my custom text in the cart.I just dont know where to start and how to save my custom price and custom text which are beeing generated by the javascript file I have created into the database and after that how to push them into the cart.Can we somehow create an instance of the product added to cart and change variables like price, attribute text etc. on the fly like it is possible with magento observer model afer adding product to cart??Could anyone give me some needable ideas in the right direction please...Thank you very much Link to comment Share on other sites More sharing options...
3cubes Posted April 7, 2014 Author Share Posted April 7, 2014 No one any ideas how to send additional data to cartcontroller?? I have found a paid module from user BELVG (http://module-presta.com/custom-price.html) where user can set own custom price on product page. So in fact my idea is in fact possible. Please just need some advise in the right direction. Link to comment Share on other sites More sharing options...
freuxbang Posted February 5, 2015 Share Posted February 5, 2015 Sorry for my poor English. I too am trying to do your very same thing, and I can not find a solution to solve this problem. The form that you have shown in your last response fails to send the cart a price decided by the customer, but if known well, the module creates a product, the catalog prestashop, with that particular price. So in the basket are sending a clone of that product, you just created by clicking on add to cart. I think that this solution can create a lot of confusion in the product catalog. Link to comment Share on other sites More sharing options...
icedfox Posted May 26, 2016 Share Posted May 26, 2016 Very interested too! Link to comment Share on other sites More sharing options...
Lorem Ipsum Posted March 9, 2017 Share Posted March 9, 2017 Same here, anybody found a solution? Link to comment Share on other sites More sharing options...
abdess Posted March 9, 2017 Share Posted March 9, 2017 have same problem any help! plzzzzzz Link to comment Share on other sites More sharing options...
Lorem Ipsum Posted March 9, 2017 Share Posted March 9, 2017 I found a solution using the specificPriceRule, here it is : $cart->updateQty(1, $product_id, $product->getDefaultAttribute($product->id)); $specific_price_rule = new SpecificPriceRule(); $specific_price_rule->name = 'Price rule name here'; $specific_price_rule->id_shop = (int)$context->shop->id; $specific_price_rule->id_currency = 0; $specific_price_rule->id_country = 0; $specific_price_rule->id_group = 0; $specific_price_rule->from_quantity = 1; $specific_price_rule->price = 2.5; $specific_price_rule->reduction = 0; $specific_price_rule->reduction_tax = 0; $specific_price_rule->reduction_type = 'amount'; $specific_price_rule->from = date("Y-m-d H:i:s"); $specific_price_rule->to = date("Y-m-d").' 23:59:59'; $specific_price_rule->add(); $specific_price = new SpecificPrice(); $specific_price->id_product = (int)$product_id; // choosen product id $specific_price->id_product_attribute = $product->getDefaultAttribute($product->id); $specific_price->id_cart = (int)$cart->id; $specific_price->id_shop = (int)$context->shop->id; $specific_price->id_currency = 0; $specific_price->id_country = 0; $specific_price->id_group = 0; $specific_price->id_customer = 0; $specific_price->from_quantity = 1; $specific_price->price = 2.5; $specific_price->reduction_type = 'amount'; $specific_price->reduction_tax = 1; $specific_price->reduction = 0; $specific_price->from = date("Y-m-d H:i:s"); $specific_price->to = date("Y-m-d").' 23:59:59'; // or set date x days from now $specific_price->id_specific_price_rule = $specific_price_rule->id; $specific_price->add(); It's a work in progress, this code can be optimiezd but it's working for what I have to do. Hope it helps! 1 Link to comment Share on other sites More sharing options...
Mickael Boulat Posted July 5, 2017 Share Posted July 5, 2017 Hello, I'm working on a similar module. Please tell me where you did put that code ? Did you override Cart methods or used the hookActionCartSave() ?? Thank you ! Link to comment Share on other sites More sharing options...
Lorem Ipsum Posted July 6, 2017 Share Posted July 6, 2017 Hi, I've put that code directly in my module controller. Basically, you just have to put it where you need it. Link to comment Share on other sites More sharing options...
hartvigmorten Posted July 10, 2017 Share Posted July 10, 2017 You should probably remove the "customfinalprice" from the form. Anyone could manipulate your sales price when the price is submitted client-side (either remove it, or add a serverside calculation that have to match the values (and when doing that, you don't need the first one) 1 Link to comment Share on other sites More sharing options...
LauraPresta Posted June 8, 2018 Share Posted June 8, 2018 hello Lorem Ipsum, thanks for your solution. To me it works by only using $specific_price (so i dont use $specific_price_rule). Did i miss something or $specific_price_rule is not usefull ? Link to comment Share on other sites More sharing options...
Lorem Ipsum Posted June 8, 2018 Share Posted June 8, 2018 I guess in the theory it would work without the $specific_price_rule but it may not be logical in the database side. Link to comment Share on other sites More sharing options...
LauraPresta Posted June 14, 2018 Share Posted June 14, 2018 Guys im not so sure about the setspecificprice way, because if you do this then if customer add 2 differents customized priced products with same id then both will be same price in cart ? Tell me if im wrong but this is what im checking actually. Link to comment Share on other sites More sharing options...
IronMan0803 Posted July 8, 2020 Share Posted July 8, 2020 Did you experience that it will not reflect immediately? You need to refresh and wait for more seconds for the specific price will reflect. Can anyone help me with the issue? Link to comment Share on other sites More sharing options...
Dj.nik87 Posted March 29, 2021 Share Posted March 29, 2021 On 7/8/2020 at 3:17 AM, IronMan0803 said: Did you experience that it will not reflect immediately? You need to refresh and wait for more seconds for the specific price will reflect. Can anyone help me with the issue? It happens to me too, how did you solve it? Link to comment Share on other sites More sharing options...
Dj.nik87 Posted March 30, 2021 Share Posted March 30, 2021 I solved the problem by setting the start date 5 minutes earlier 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