Web Design Forum: E-Commerce Help/Advice - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

E-Commerce Help/Advice Built one myself but not sure on something.... Rate Topic: -----

#1 User is offline   lstables 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 441
  • Joined: 08-June 08
  • Reputation: 1
  • Gender:Male
  • Location:Yorkshire, UK
  • Experience:Intermediate
  • Area of Expertise:Designer/Coder

Posted 29 July 2009 - 10:31 AM

Hi All,

I have been working to put together a online shop for a moto x company, selling bikes, parts etc.
All is fine and working but no the client wants a delivery charge adding at the checkout using the following:

If the total price is under £50 a £5.50 delivery charge needs to be added, between £50-£100 a £10 delivery charge needs to be added and if the order is over £100 FREE delivery.

I built the shop using MySQL and PHP what would be the best and easiest way to do this.

Here's the code from my checkout page:
<?php

//connect to database

require_once('conn/db_conn.php');

mysql_select_db($database, $store);



$display_block = "<div id=\"cart\">";



//check for cart items based on user session id

$get_cart_sql = "SELECT st.id, si.item_code, si.item_price,  st.sel_item_qty, st.sel_item_size, item_image, st.sel_item_color, stock_available, item_delivery FROM store_shoppertrack AS st LEFT JOIN store_items AS si ON si.id = st.sel_item_id WHERE session_id = '".$_COOKIE["PHPSESSID"]."'";

$get_cart_res = mysql_query( $get_cart_sql) or die(mysql_error());







if (mysql_num_rows($get_cart_res) < 1) {

    //print message

    $display_block .= "<p>You have no items in your cart.<br />

    Please <a href=\"index.php\">click here</a> to continue to shop.</p>";

} else {

    //get info and build cart display$total_price + $Sub_Total

    

    while ($cart_info = mysql_fetch_array($get_cart_res)) {

   	    $id = $cart_info['id'];

   	    $item_title = stripslashes($cart_info['item_code']);

   	    $item_price = $cart_info['item_price'];

   	    $item_qty = $cart_info['sel_item_qty'];

   	    $item_color = $cart_info['sel_item_color'];

   	    $item_size = $cart_info['sel_item_size'];
   	    $item_desc = $cart_info['item_desc'];

	      $total_price = sprintf("%.02f", $item_price * $item_qty);

				$Sub_Total =  sprintf("%.02f", $total_price + $Sub_Total);

				$item_image = $cart_info['item_image'];

		

		 

	for($i=0; $i < count($get_cart_res); $i++){

$val ++;

 	echo "<input type='hidden' name='item_name_$val'value='".$item_title."'>";

	echo "<input type='hidden' name='amount_$val'value='".$item_price."'>";

 	echo "<input type='hidden' name='quantity_$val'value='".$item_qty."'>";

	echo "<input type='hidden' name='os1_$val' value='".$item_size."'>";



}			

		$display_block .= "

		<div id=\"cartOrder\">

		<p><img src=\"".$item_image."\"width=\"100\"\"height=\"100\"><br />

		<p><?php echo $item_desc; ?></p>

   	 Unit Price: <strong>&pound;$item_price</strong><br />

   	 Qty: <strong>$item_qty</strong><br />

     Total Price: <strong>&pound;$total_price</strong>
     <br />

   	 <a href=\"removefromcart.php?id=".$id."\"><img src=\"img/remove_cart.png\"border=\"0\"</a></p>

   	   <div id=\"subtotal\">
    	

		</div>";

	}

	

}

{

$display_block .= "
	<table width=\"5px\" border=\"0\"><tr>

		<td>

		<th align=\"left\"bgcolor=\"#fff\" class=\"wht\"><p>Total (incl del):</p><strong><p>&pound;$Sub_Total</p><strong><br/></th>

			</td>";

    $display_block .= "</table>";

   }



?> 



<?php echo $display_block; ?>

0

#2 User is offline   jason_shu 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 19-July 09
  • Reputation: 0

Posted 04 August 2009 - 07:27 AM

You give a page to you how to answer it, you use what the framework, there is still so relevant documents load. If you can find answers to www.comercexp.com
0

#3 User is offline   TopShopper 

  • Expert
  • PipPipPipPip
  • Group: Members
  • Posts: 878
  • Joined: 21-July 09
  • Reputation: 14
  • Gender:Male
  • Location:Cardiff, UK
  • Experience:Intermediate
  • Area of Expertise:Coder

Posted 20 August 2009 - 03:33 PM

How about something like:

$Delivery=0;
if ($Sub_Total<50){$Delivery=5.50;}
if (($Sub_Total>=50) && ($Sub_Total<100)){$Delivery=10;}
$Total=$Sub_Total + $Delivery;


regards
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users