product quantity should multiply shipping price

Hi can any body help me with the following code on shopping cart?

I want shipping price increase/multiply with the product quantity.
I set a shipping price to a product. When the product quantity increases the shipping price should also be increased. (shipping price x product quantity) and this should be added to the Grand Total.

here is the code;

$cart_sub_total = 0;
$cart_total = 0;
$cart_shipping = 0;
foreach($cart_products as $product_id => $product){
$quantity = max(1,(int)$product[‘quantity’]);
$product_total = $product[‘price’] * $quantity;
$cart_sub_total += $product_total;
if(isset($product[‘product_settings’][‘shipping’]) && $product[‘product_settings’][‘shipping’]>0){
$cart_shipping += $product[‘product_settings’][‘shipping’];
}
}
$cart_total = $cart_sub_total + $cart_shipping;
$member = isset($_SESSION[’_cart_member_data’]) ? $_SESSION[’_cart_member_data’] : array();

Thanks in advance.
nrkar

Perhaps I do not understand your question, but, you have this:
$cart_shipping += $product[‘product_settings’][‘shipping’];

Shouldn’t it be something like this:
$cart_shipping += $product[‘product_settings’][‘shipping’] * $quantity;

You added the shipping costs but did not use the quantity of items.

Hope that solves it… Good luck!

Sponsor our Newsletter | Privacy Policy | Terms of Service