Daveriser Posted March 8, 2010 Share Posted March 8, 2010 Hello!In the mails folder there's lots of cool html templates which are used for the emails which presta shop sends out. I am wanting to add a text field to 'order_conf.html' which basically does a calculation on the price, divides it by 11 and displays the result in another field. Using HTML and smarty in this document, how would this be possible?It seems in this document I can only use certain varaibles, for example.{total_paid}But as soon as I type in a variable that it doesn't recognise it displays it as text.I've tried this but it just displays as text:{math equation="total_paid / 11}I even tried going into Order.php in the classes folder and attempted to do the calculation there and send in a new variable, however when I tried to send in a new variable I get a hack attempt error, and I think it doesn't like me doing that.Any ideas?Thank you very much!David Link to comment Share on other sites More sharing options...
tomerg3 Posted March 9, 2010 Share Posted March 9, 2010 You cannot do it that way, you need to set a new variable in the same place that {total_paid} gets set.In there, you will be able to do math calculations.{total_paid} is not a smarty code, it's a swift email "code" Link to comment Share on other sites More sharing options...
Daveriser Posted March 10, 2010 Author Share Posted March 10, 2010 Thank you, when I set a new variable where total_paid is defined and pass it through with the array of other variables, I get the hack attempt error. Any ideas how I might go about fixing this? Link to comment Share on other sites More sharing options...
tomerg3 Posted March 10, 2010 Share Posted March 10, 2010 Thank you, when I set a new variable where total_paid is defined and pass it through with the array of other variables, I get the hack attempt error. Any ideas how I might go about fixing this? Can you paste the original code and the changes you made? Link to comment Share on other sites More sharing options...
Daveriser Posted March 10, 2010 Author Share Posted March 10, 2010 Sure!I made some small changes to 'Orders.php', I am attempting to get the variable total_GST passed through, even if it holds the same value as the price.It seems as soon as I make changes to $fieldsRequired, $fieldsSize and $fieldsValidate it gives me the hack attempt report.Thank you! Here are the changes: /** @var float Total really paid */ public $total_GST; /** @var float Total to pay */ public $total_paid; protected $fieldsRequired = array('id_address_delivery', 'id_address_invoice', 'id_cart', 'id_currency', 'id_lang', 'id_customer', 'id_carrier', 'payment', 'total_GST', 'total_paid', 'total_paid_real', 'total_products'); protected $fieldsSize = array('payment' => 33); protected $fieldsValidate = array( 'id_address_delivery' => 'isUnsignedId', 'id_address_invoice' => 'isUnsignedId', 'id_cart' => 'isUnsignedId', 'id_currency' => 'isUnsignedId', 'id_lang' => 'isUnsignedId', 'id_customer' => 'isUnsignedId', 'id_carrier' => 'isUnsignedId', 'secure_key' => 'isMd5', 'payment' => 'isGenericName', 'recyclable' => 'isBool', 'gift' => 'isBool', 'gift_message' => 'isMessage', 'total_discounts' => 'isPrice', 'total_GST' => 'isPrice', 'total_paid' => 'isPrice', 'total_paid_real' => 'isPrice', 'total_products' => 'isPrice', 'total_shipping' => 'isPrice', 'total_wrapping' => 'isPrice', 'shipping_number' => 'isUrl' ); public function getFields() { parent::validateFields(); $fields['id_address_delivery'] = intval($this->id_address_delivery); $fields['id_address_invoice'] = intval($this->id_address_invoice); $fields['id_cart'] = intval($this->id_cart); $fields['id_currency'] = intval($this->id_currency); $fields['id_lang'] = intval($this->id_lang); $fields['id_customer'] = intval($this->id_customer); $fields['id_carrier'] = intval($this->id_carrier); $fields['secure_key'] = pSQL($this->secure_key); $fields['payment'] = pSQL($this->payment); $fields['module'] = pSQL($this->module); $fields['recyclable'] = intval($this->recyclable); $fields['gift'] = intval($this->gift); $fields['gift_message'] = pSQL($this->gift_message); $fields['shipping_number'] = pSQL($this->shipping_number); $fields['total_discounts'] = floatval($this->total_discounts); $fields['total_GST'] = floatval($this->total_paid); $fields['total_paid'] = floatval($this->total_paid); $fields['total_paid_real'] = floatval($this->total_paid_real); $fields['total_products'] = floatval($this->total_products); $fields['total_shipping'] = floatval($this->total_shipping); $fields['total_wrapping'] = floatval($this->total_GST); $fields['invoice_number'] = intval($this->invoice_number); $fields['delivery_number'] = intval($this->delivery_number); $fields['invoice_date'] = pSQL($this->invoice_date); $fields['delivery_date'] = pSQL($this->delivery_date); $fields['valid'] = intval($this->valid) ? 1 : 0; $fields['date_add'] = pSQL($this->date_add); $fields['date_upd'] = pSQL($this->date_upd); return $fields; } Link to comment Share on other sites More sharing options...
tomerg3 Posted March 11, 2010 Share Posted March 11, 2010 You are trying to change the wrong place.The email variables for the order confirmations are set in /classes/PaymentModule.phpLine 330 is '{total_paid}' => Tools::displayPrice($order->total_paid, $currency, false, false), You can add '{total_paid}' => Tools::displayPrice($order->total_paid, $currency, false, false), '{total_GSM}' => Tools::displayPrice($order->total_paid / 10, $currency, false, false), I used / 10, but you can use any math calculation you need. Link to comment Share on other sites More sharing options...
Daveriser Posted March 19, 2010 Author Share Posted March 19, 2010 Thank you very much! Appreciate your help. Link to comment Share on other sites More sharing options...
caly16 Posted September 21, 2010 Share Posted September 21, 2010 I would like the same thingI try in Classes/PaymentModule.php: '{total_GSM}' => Tools::displayPrice($order->total_paid / 10, $currency, false, false), and mail : {total_GSM}It doesn't work (not convert)Can you help me please??? Link to comment Share on other sites More sharing options...
caly16 Posted October 5, 2010 Share Posted October 5, 2010 This email variables doesn't work .Can you help me again to math calculations please ? Link to comment Share on other sites More sharing options...
Telmo E. Julião Posted September 20, 2011 Share Posted September 20, 2011 Bump. I'm looking for this too. Link to comment Share on other sites More sharing options...
tomerg3 Posted September 20, 2011 Share Posted September 20, 2011 Can you be more specific, what do you need, did you try the solutions posted above? if you did, what was not working? Link to comment Share on other sites More sharing options...
caly16 Posted September 21, 2011 Share Posted September 21, 2011 I need the email variables for the order confirmationsPrestashop 2.5 when the order total is divided by 3, example : => order total : 99£ => 99/3 = 33£ In the email confirmation order : " Dear custommer Your paid 33£ per month" An then, if the total order is 100€ => 100£/3 = 33.33£ " Dear custommer Your paid 33,33£ per month" Link to comment Share on other sites More sharing options...
tomerg3 Posted September 21, 2011 Share Posted September 21, 2011 Did you read and follow the instructions in the posts above? Link to comment Share on other sites More sharing options...
caly16 Posted July 30, 2012 Share Posted July 30, 2012 Sorry for a long time I test follow instructions but doesn't work . I changed version of prestashop. I'm 1.4.8. In PaymentModule.php i add : '{total_GSM}' => Tools::displayPrice($order->total_paid/3, $currency, false), But in the mail automatic "Waiting for payment" {total_GSM} is not convert . To remember, i would like divide {total-paid} in the email customer's when he pass order 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