Jump to content

How to use smarty


cedric.v

Recommended Posts

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 by cedric.v (see edit history)
Link to comment
Share on other sites

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

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 by bellini13 (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...