2 replies [Last post]
fivepoints's picture
Offline
Getting busy with the Ubercode.
Joined: 09/26/2007
Juice: 258

hallo,
I have enabled an option that adds 2,00 euro to the product sell_price.
Now I have to calculate the shipping costs. I do this calculation simply with:

$total += $product->sell_price * $product->qty;

but I've noticed that $product->sell_price is not the total I see into the cart but is the product sell price without the "Default price" increment of the option, so the shipping cost is not well calculated.

how can I know the real price (sell price plus the option value that I've indicated into "Default price" field)?

thanks
nicola

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6841
Re: $product->sell_price when there is a Dafault price attribute

You need to get the item as it exists in the cart, which you can do with something like this:

<?php
$items
= uc_cart_get_contents(); // Current user's cart.

foreach ($items as $item) {
 
$total += $item->price + $item->qty;
}
?>

The attribute module adds the chosen option price to the product's sell price when it is added to the cart.

fivepoints's picture
Offline
Getting busy with the Ubercode.
Joined: 09/26/2007
Juice: 258
tahnks! now it works! nicola

tahnks! now it works!
nicola