Results 1 to 5 of 5

Thread: adding another option to my cart

  1. #1
    Join Date
    Jan 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default adding another option to my cart

    Hi, Not sure if ive posted this in the right place, sorry in advance if its not in the right place. I currently have a website that was designed for me, the site works great for me but i want to add something to the personal cart page. the code for the page i want to change is

    <?php

    include "include/config.inc.php";
    include "include/functions.inc.php";
    db();
    $breadcrumbs=array('index.php'=>'home','personal_cart.php'=>'shopping basket');

    $leather_table=array();
    $sql="SELECT * FROM leather ORDER BY leather_sequence_id";
    if (!($result=mysql_query($sql))) DBerror();
    while ($row=mysql_fetch_assoc($result)) $leather_table[$row['ID']]=$row;

    $wood_table=array();
    $sql="SELECT * FROM wood ORDER BY wood_sequence_id";
    if (!($result=mysql_query($sql))) DBerror();
    while ($row=mysql_fetch_assoc($result)) $wood_table[$row['ID']]=$row;

    @$cart=unserialize(stripslashes($_COOKIE['cart']));
    if (!$cart) $cart=array();

    foreach (array('destination_country','collect_furniture') as $cn) {
    if (isset($_POST[$cn])) {
    setcookie($cn,$_POST[$cn]);
    $_COOKIE[$cn]=$_POST[$cn];
    }
    }

    switch (@$_REQUEST['action']) {
    case 'add':
    $item=&$cart[$_REQUEST['id']];
    $item['leather']=$_REQUEST['leather'];
    $item['wood']=$_REQUEST['wood'];
    $item['qty']=array();
    for ($i=1;$i<=8;$i++) {
    $item['qty'][$i]=(int)@$_REQUEST["qty-$i"];
    }
    unset($item);
    break;
    case 'change':
    $ids=array_keys($cart);
    foreach ($ids as $id) {
    $data=&$cart[$id];
    for ($i=1;$i<=8;$i++) {
    $data['qty'][$i]=(int)@$_REQUEST["qty-$id-$i"];
    }
    unset($data);
    }
    break;
    }
    // remove:
    $ids=array_keys($cart);
    foreach ($ids as $id) {
    $data=&$cart[$id];
    for ($i=1;$i<=6;$i++) {
    if (isset($_REQUEST["remove-$id-$i"])) $data['qty'][$i]=0;
    }
    unset($data);
    }

    setcookie('cart',serialize($cart));

    include "include/header.inc.php";

    echo "<h1>YOUR BASKET</h1>\n";

    //if ($cart=="") {
    $cart_empty=true;
    $occasional=false;
    $not_occasional=false;

    foreach ($cart as $id=>$data) {
    foreach ($data['qty'] as $i=>$qty) {
    if (!$qty) continue;
    $cart_empty=false;
    }
    }

    if ($cart_empty) {
    echo ("<br>
    <font size=\"2\" face=\"Arial, Helvetica, sans-serif\"><center><b>Your personal cart is empty.<br><br>
    <a href=\"javascript: window.history.go(-1)\">Back</a></B></center></font>");
    } else {
    // echo "here";
    echo "<div class='cart'>";
    echo "<center>";
    echo "<form action=\"".basename($PHP_SELF)."\" method=\"post\">";

    $cart_total=$delivery_charge_total=0;

    foreach ($cart as $id=>$data) {
    foreach ($data['qty'] as $i=>$qty) {
    if (!$qty) continue;
    echo show_cart_item($id,$data,$i,TRUE);
    }
    }

    //echo "occasional 2 ".$occasional."<br>";
    echo show_total_line(TRUE);

    echo "<br><br><b>Please choose Country of destination and click UPDATE below: </b>&nbsp;&nbsp; ";
    dropdown_display(
    $countries,
    @$_COOKIE['destination_country'],
    " name='destination_country'"
    );
    echo "<br><br><br>";

    echo ("<br>
    <table width=450 border=0 cellspacing=0><tr><td align=right width=300 valign=top>
    <input type=\"Hidden\" name=\"action\" value=\"change\">
    <input type=\"Submit\" value=\"Update\" class=\"submit \">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></form><form action=\"complete_order.php\" method=\"GET\"><td align=right><input type=\"Submit\" value=\"CHECKOUT\" class=\"submit \">
    </tr></tr></form>
    <tr><Td colspan=2> <br><br><br><br>
    </TD></tr>
    </table>
    ");

    echo "</center>";
    echo "</div>";
    } // ENd of cart=''
    include "include/footer.inc.php";

    ?>



    the address for my site is www.classic-designs.co.uk

    in the personal cart i want to add the option for a cutsomer to purchase a cleaning kit. and preferably have some sort of link so it pops up a window that shows them a picture of the cleanng kit and some info about it

    hope ive explained everything above, if nothing makes sence please let me know and i will try and re-explain

    Thanxs in advance for any help

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Honestly, I'm just too tired right now (6am/still up) to really be of help with the PHP code.

    However, I'm pretty sure we would need more information. How would they choose this? A checkbox? Link? Adding a link to a popup window is really easy, but it all depends on how/where you want it. More details would be great.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jan 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default more info

    i wanted a drop down list so they could select quantity. we currently have an option where they can select to collect there furniture and it just ads a cost in to the total. i just wanted something similar to that.

  4. #4
    Join Date
    Jan 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    just wandering if anyone has had chance to think about what i asked above? is it going to be hard to do or is it quite easy?

    thanxs in advance

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    It really doesn't sound complex at all. Just copy the code, change the prices/names and variable names, then you've got it. I think. (PLUS any server side coding, like storing the order, etc etc.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

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