View Single Post
  #23  
Old 10-15-2011, 12:09 PM
 
Powertrain Powertrain is offline
 

Senior Member
  
Join Date: Mar 2011
Posts: 101
 

Default Re: Add special handling charge to cart totals

Quote:
Originally Posted by cflsystems
Because your code assigns new value to $handling_special with each loop without adding the old one to the cart. You need to also include in the foreach code to add the value to cart if any then go to the next one. Something like

foreach ($int_hdl as $handling_special) {

$handling_special = field_value;
cart_total += $handling_special;

}
}


replace cart_total with the actual cart total field (or the field you are adding value to)

Thank you so much Steve for taking time to look at this, it's a headache.

I actually got it to calculate subtotal that includes these extra charges with this code :

PHP Code:
$int_hdl func_query_first("SELECT * FROM $sql_tbl[extra_field_values] WHERE fieldid=1 AND productid=$product[productid]"); 
if (!empty(
$int_hdl["value"])) {

foreach (
$int_hdl as $handling_special) {

$handling_special $int_hdl['value'];
}
}

$subtotal += $handling_special

but for some reason if I add product that does not have the extra field, it adds extra charge to it as well and than ads discounted total line, subtracts one extra charge.
Than at the end shows total plus one extra charge.


Seems like the code needs to be somewhere where it calculates $product price, I don't know.
__________________
x-cart 4.4.2 Gold
Reply With Quote