Results 1 to 10 of 10

Thread: How to do shipping calculations

Threaded View

  1. #3

    Thread Starter
    Member
    Join Date
    Jan 2009
    Posts
    49

    Re: How to do shipping calculations

    Thank you kows

    My current while loop uses mysql_fetch_object as it needs to display the product picture:

    PHP Code:
    //retrieve cart items and details
    $sqlcart = ("SELECT * FROM orders, orderitem, product
            WHERE ....."
    ;

    $resultcart=@mysql_query($sqlcart);

    //show cart items
    while ($row mysql_fetch_object($resultcart)) {
            
    $quantity $row->OrderItemQuantity;
                    .......


    Now because of this I couldn't use your array one instead, so I used it inside the loop with some debugging code to see if it was calculating it correctly which it was so that was cool! The total was fine but it stuffed up the object loop and stopped it from display all records.

    So I tried using the array code AFTER the object loop but for some reason it didn't go through the cart items and show the debugging code in the loop - shipping stayed at 0.

    Its using the same $resultcart so I thought it would be doing the query ok.

    PHP Code:
    //sql query as above
    //then object while loop

    //set shipping value as zero  
     
    $shipping 0;
     
       while(
    $array mysql_fetch_array($resultcart)){
        
    //do not display as already have
        //just using loop for shipping value purposes

        //add onto the shipping value
        
    $shipping += $array['ProductShippingValue'];
         
        
    //debugging
        
    echo "shipping value = " $shipping;
      
      } 
    //end while here

    //show subtotal
    //show shipping
    //show total 
    I'm pretty sure I'm doing something stupid, please let me know if you are after different code examples.
    Last edited by buffy; Jan 9th, 2009 at 08:46 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width