cedric.v Posted June 6, 2012 Share Posted June 6, 2012 (edited) Hi evevryone. I'm trying to use smarty variables in my php. I wrote : global $cart;if ($cart->id == null) $cart->update(true); //Recupération de l'id du cart par Smarty $idcart = $cart->id; //Recupération de l'id du client par Smarty $idcustomer = $cart->id_customer; //Recupération du total à payer par Smarty // THIS DOESN'T WORK global $total; $total_pay = $total->value; The first two variables work perfectly because I cans then see them in my db. The Total doesn't work. I tested to know if I could assign it myself, and it worked, but that's not really what I want to do. I want to get the total price. Does anyone know ? Thank you in advance. Edited June 6, 2012 by cedric.v (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted June 7, 2012 Share Posted June 7, 2012 there is nothing in your code that is dealing with smarty. you are assigning a global variable called $total, and then trying to use it in an equation. what other code has set the value for $total in a global variable? Link to comment Share on other sites More sharing options...
cedric.v Posted June 7, 2012 Author Share Posted June 7, 2012 I did a little research and found out that there was no $total assigned in smarty. But what I would like to do is have the total amount of the cart. Link to comment Share on other sites More sharing options...
Jean-Pascal Posted June 7, 2012 Share Posted June 7, 2012 quick answer, as I didn't look at the file you are modding : call a "var_dump($cart);" ans process the page to see what is inside your cart object. Chances are you will find it as $cart->totalprice, or something like that, so you can call it directly in your script. Link to comment Share on other sites More sharing options...
cedric.v Posted June 7, 2012 Author Share Posted June 7, 2012 Actually, there isn't the price in the $cart. So I shouldn't do it that way. I need the variable to change the total price of the order, knowing that the order hasn't been done yet. Link to comment Share on other sites More sharing options...
bellini13 Posted June 7, 2012 Share Posted June 7, 2012 (edited) I did a little research and found out that there was no $total assigned in smarty. But what I would like to do is have the total amount of the cart. even if there was a total assigned in smarty, you are not accessing it the correct way. if the total was added as a smarty variable in some other code, such as ... $smarty->assign('total',$total); then you would need do this to fetch it global $smarty; $total = $smarty->getTemplateVars('total'); if you are just looking to get the total amount of the order, you would use the function getOrderTotal within the cart class. you will need to review that function since it supports alot of different order totals (with or without taxes, shipping, discounts etc) $cart->getOrderTotal() Edited June 7, 2012 by bellini13 (see edit history) Link to comment Share on other sites More sharing options...
cedric.v Posted June 7, 2012 Author Share Posted June 7, 2012 Thank you $cart->getOrderTotal() was all i needed cheers ! 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