We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,939 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

how to sum the price of multiple produts with its different shipping charge

hi all.. pls help me..

i want to sum the price of multiple products with its quantity and shipping charges.
in my products table all the products have different shipping charges.

    for ex: product1 shipping charges.       product2 shipping charges.
              shipping to US = $10.99         shipping to US = $14.99 
            shipping outside US = $20.99      shipping outside US = $34.99

if there is two product1 in the cart and shipping value is US, then it should be
like this total price= (quantity * shipping to US) + (quantity * product price).
how could i do this???

tnx in advnc....

3
Contributors
5
Replies
20 Hours
Discussion Span
5 Months Ago
Last Updated
7
Views
amiyar
Junior Poster in Training
55 posts since Nov 2012
Reputation Points: 0
Solved Threads: 1
Skill Endorsements: 0

Show the structure of your table(s) and some data.

pritaeas
Posting Prodigy
Moderator
9,285 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,457
Skill Endorsements: 86

tnx 4 ur reply pritaeas..
and u mean screenshot of the table????

amiyar
Junior Poster in Training
55 posts since Nov 2012
Reputation Points: 0
Solved Threads: 1
Skill Endorsements: 0

Screenshot, or sqldump, whichever is easier. If it's clear what you have, it's easier to find a solution.

pritaeas
Posting Prodigy
Moderator
9,285 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,457
Skill Endorsements: 86

You seem to have given the calculation yourself. What exactly are you struggling with?

diafol
Keep Smiling
Moderator
10,647 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,509
Skill Endorsements: 57

hi pritaeas..& diafol
this is my table product structure..
db

here is some code that i have been done in calculation part and this is working only after getting sum of total price for all the products with the given shipping costs. But actually what i needed is to fetch the shipping costs from the database for the corresponding prod_id's then calculate the total for each product and get total of all.

        $order_total=$_POST['total_payment'];
        $shipping_outside= 34.99;
        $shipping_us=14.95;
        echo $s_country;
        if(trim($s_country)=='US' || trim($s_country=='United States' )){
            $shipping_cost1=$shipping_us;
        }else{
            $shipping_cost1=$shipping_outside;

        }




  $sales_tax=$order_total*10/100;

        if($s_country=='US'  && $s_state=='IL' || $s_country=='United States'&& $s_state=='IL'|| $state=='IL'){
            $totalprice=$order_total+$shipping_cost1+$sales_tax;    

        }
        elseif($s_country=='US' && $s_state !='IL' || $s_country=='United States'&&  $s_state !='IL' || $state !='IL'){
        $totalprice=$order_total+$shipping_cost1;
            }

        else{
        $totalprice=$order_total+$shipping_cost1;
            }   
        $totalprice=number_format($totalprice, 2, '.', '');

pls help.......

Attachments db.jpg 144.92KB
amiyar
Junior Poster in Training
55 posts since Nov 2012
Reputation Points: 0
Solved Threads: 1
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0888 seconds using 2.76MB