sebastiann Posted October 13, 2010 Share Posted October 13, 2010 Hello!I want to add a field in the cart/order that shows a custom field. Something like the tax-field but I want it to show how much of the order that goes to charity. Say 5% of the total order goes to charity, can I display this in the order/cart. Is this possible? Best regards! Link to comment Share on other sites More sharing options...
sebastiann Posted October 13, 2010 Author Share Posted October 13, 2010 There must be someway to get a certain % of the total order and display it. Have checked in the classes but I do not really know what to add or where. Do anyone know how to get % from order, I do not want to add it to the total, just display % of the order. Link to comment Share on other sites More sharing options...
gdinari Posted October 14, 2010 Share Posted October 14, 2010 This can be done by editing the shopping-cart.tpl (in theme folder) or by editing the shopping-cart.tpl and the Cart.php (classes folder). You have to add a new variable in the Cart file and add the new field you want in the shopping-cart file.In the shopping-cart file, first find out where you want the field to go. (In what order? Under the total, above total taxes, ect). You will have to look around it can get a little confusing. But once you've decided where you want to place your new field, insert something like this in the place you want: {l s='New Field Name:'} {NewVariableName}% If you want to have a set percentage that doesn't change, just add that number into the new field. No need to change the Cart file: {l s='New Field Name:'} 10% If you want to show a changing percentage based on a set amount from every order and the order total, then you change the Cart file. So in the Cart file (Right after line 1025), add something like this: 'NewVariableName' => ( 10 / ($this->getOrderTotal()) * 100), The 'NewVariableName' can be something like 'charity' in your case. The code after it is just the calculations for the charity percentage. The number 10 is the amount from every order that goes to charity. For example, you would change that number to 25 if $25 of every order would go to charity. Then you divide that by the order total ($this->getOrderTotal()) and multiply it by 100 to get the percentage for that particular order. With this method the percentages will be different because the order totals wont be the same and remember update the variable name in the shopping cart file.So now in the new field and new variable you created, every time an order is placed the cart will show that percentage amount in the new field. Link to comment Share on other sites More sharing options...
sebastiann Posted October 14, 2010 Author Share Posted October 14, 2010 Thanks for the help! I just wonder where I should add the 'NewVariableName' => ( 10 / ($this->getOrderTotal()) * 100),?In the cart file in classes? I appreciate the help!Edit: Sorry, found it in your post!Edit2: Would it be under getsummarydetails, return array? The 1025 line do not match with my file, it is changed a little bit since earlier. Link to comment Share on other sites More sharing options...
sebastiann Posted October 14, 2010 Author Share Posted October 14, 2010 Hm, the field is OK!But when I create the variable in classes it is OK until I call the variable from shopping-cart.tpl. Then the cart dissapears, I used your code, entered my variable under getsummarydetails. Any ideas of what gone wrong?Edit: I made it like this and then I get the ammount that goes to charity {l s='charity:'} {convertPrice price=$test} ' test' => (($this->getOrderTotal()) /10), Link to comment Share on other sites More sharing options...
gdinari Posted October 15, 2010 Share Posted October 15, 2010 Yeah the cart page will disappear if a variable is called that isn't defined in the Cart.php. What page are you trying to add the new field?For the shopping cart page, be sure to add the variable in the array in the Cart.php that starts around line 1008: return array( 'delivery' => $delivery, 'delivery_state' => State::getNameById($delivery->id_state), 'invoice' => $invoice, 'invoice_state' => State::getNameById($invoice->id_state), 'carrier' => new Carrier(intval($this->id_carrier), $cookie->id_lang), 'products' => $this->getProducts(false), 'discounts' => $this->getDiscounts(), 'total_discounts' => $this->getOrderTotal(true, 2), 'total_discounts_tax_exc' => $this->getOrderTotal(false, 2), 'total_wrapping' => $this->getOrderTotal(true, 6), 'total_wrapping_tax_exc' => $this->getOrderTotal(false, 6), 'total_shipping' => $this->getOrderShippingCost(), 'total_shipping_tax_exc' => $this->getOrderShippingCost(NULL, false), 'total_products_wt' => $this->getOrderTotal(true, 1), 'total_products' => $this->getOrderTotal(false, 1), 'total_price' => $this->getOrderTotal(), 'total_tax' => $this->getOrderTotal() - $this->getOrderTotal(false), 'total_price_without_tax' => $this->getOrderTotal(false)); } Make sure you add within the array and be careful with the ending. Add a comma "," after the last line and start a new line: 'total_price_without_tax' => $this->getOrderTotal(false), /*Begin new variable here*/ ); Adding variable here will show the value in the new field you created for the shopping cart page. Link to comment Share on other sites More sharing options...
zoomht1 Posted February 8, 2013 Share Posted February 8, 2013 Would like to have the param to add to google trusted store how can I get those params Thanks and Best Regards, Link to comment Share on other sites More sharing options...
zoomht1 Posted February 8, 2013 Share Posted February 8, 2013 Which variable represent the product ID, the Product price,..., in the cart? or how can I get these parameters in the shopping cart with js? Link to comment Share on other sites More sharing options...
zoomht1 Posted February 8, 2013 Share Posted February 8, 2013 I need to access Prestashop PHP constant values directly when someone place an order. How can you help? Regards, Link to comment Share on other sites More sharing options...
zoomht1 Posted February 9, 2013 Share Posted February 9, 2013 Which is the best way to get the user info like email, country, item, products,.., quantity before finalizing a transaction. like the one you have above? Link to comment Share on other sites More sharing options...
M.R.I Posted April 1, 2014 Share Posted April 1, 2014 Hello, I want to add a custom % field price in total price. how i add it? 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