ohno
Members-
Posts
127 -
Joined
-
Last visited
-
Days Won
1
Everything posted by ohno
-
I've posted on here in the past & had great help so I'm hoping someone can help again Basically what I was trying to do was make the add to cart button grey out and lose the add function if a product is marked as not available in the back end. I found this block of code :- //Displays the add to cart form. Requires product ID $sql = "SELECT code FROM products WHERE productid='".mysql_real_escape_string($_GET['id'])."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { $data = '<font size="2" face="Verdana, Arial, Helvetica, sans-serif"color="#000000"><form method="post" action="https://www.domain.com/s_addtocart.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.png" name="Submit" alt="Add To Cart" style="vertical-align:middle; border: none;" />Quantity: <input type="text" name="quantity" size="3" value="1" /></form></font>'; } break; which i then modified as follows & it all works as it should :- //Displays the add to cart form. Requires product ID $sql = "SELECT available, due, code FROM products WHERE productid='".mysql_real_escape_string($_GET['id'])."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { if ( $row['available'] == '1' ) { $data = '<font size="2" face="Verdana, Arial, Helvetica, sans-serif"color="#000000"><form method="post" action="https://www.domain.com/s_addtocart.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.png" hspace="5" name="Submit" alt="Add To Cart" style="vertical-align:middle; border: none;" />Quantity: <input type="text" name="quantity" size="3" value="1" /></form></font>'; } elseif ( $row['available'] == '0' ) { $data .= ' <img src="images/addtocartoutofstock.png" width="278" height="39" alt="Sorry, currently out of stock" width="23" height="20"><font color="#C70000" font size="3"><strong>OUT OF STOCK</strong></font><img src="images/outofstock.png" width="23" height="20"> <font size="2" face="Geneva, Arial, Helvetica, sans-serif" color="#000000">'.$row['due']; } } break; So what's the problem? Well, the actual code that is in use for the add to cart buttons actually has view cart, cross selling & cart summary in the code here is the code in use :- //Add to cart, view cart, cart summary, xselling all in one enhancement. Requires product ID $sql = "SELECT code FROM products WHERE productid='".mysql_real_escape_string($_GET['id'])."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { $prodcode = $row['code']; } $data = '<table border="0"><tr><td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"color="#000000"><form method="post" action="https://www.domain.com/s_addtocart.php" target="_blank"><input type="hidden" name="code" value="'.$prodcode.'" /><input type="image" src="images/add.png" name="Submit" alt="Add To Cart" style="vertical-align:middle; border: none;" hspace="2" /> Quantity: <input type="text" name="quantity" size="3" value="1" /></form></font></td></tr><tr><td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"color="#000000"><a href="https://www.domain.com/cart.php" target="_blank"><img src="images/viewcart.png" alt="View Cart" border="0px" style="vertical-align:middle" hspace="2" /></a></font></td><td>'; $data .= '<font size="2" face="Verdana, Arial, Helvetica, sans-serif"color="#000000">'; if ( !(isset($_SESSION['cartid'])) || ($_SESSION['cartid'] == "") ) //if ( (!isset($_COOKIE['RITD_Cart_ID'])) || ($_COOKIE['RITD_Cart_ID'] == '') ) { $data .= 'No items have been added to the cart yet.'; } else { $sql = "SELECT sub FROM carts WHERE cartid='".$_SESSION['cartid']."'"; //$sql = "SELECT orderno, sub FROM carts WHERE cartid='".$_COOKIE['RITD_Cart_ID']."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { if ( $row['sub'] == "" ) { $row['sub'] = "0.00"; } $orderno = $orderpre . ($orderstart+$_SESSION['cartid']); $data .= 'Order Number: '.$orderno.' with Sub-Total: £'.$row['sub']; $data = str_replace("&", "&", $data); } } $data .= '</font></td></tr></table>'; $xprods = array(); $sql = "SELECT xselling.xproductid FROM xselling, products WHERE xselling.xproductid=products.productid AND xselling.active='1' AND products.active='1' AND products.live='1' AND xselling.productid='".mysql_real_escape_string($_GET['id'])."'"; //$data .= $sql; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { array_push($xprods, $row['xproductid']); } if ( (count($xprods) <= 4) && (count($xprods) > 0) ) { $a = 0; $b = count($xprods); while ( $a < $b ) { $sql = "SELECT code, title, img, url, price FROM products WHERE active='1' AND live='1' AND productid='".$xprods[$a]."'"; $result = mysql_query($sql); switch ($a) { case 0: $row = mysql_fetch_assoc($result); $x1 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x1a = '£'.$row['price']; $x1b = '<form method="post" action="https://www.domain.com/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.png" name="Submit" alt="Add To Cart" /></form>'; break; case 1: $row = mysql_fetch_assoc($result); $x2 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x2a = '£'.$row['price']; $x2b = '<form method="post" action="https://www.domain.com/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.png" name="Submit" alt="Add To Cart" /></form>'; break; case 2: $row = mysql_fetch_assoc($result); $x3 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x3a = '£'.$row['price']; $x3b = '<form method="post" action="https://www.domain.com/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.png" name="Submit" alt="Add To Cart" /></form>'; break; case 3: $row = mysql_fetch_assoc($result); $x4 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x4a = '£'.$row['price']; $x4b = '<form method="post" action="https://www.domain.com/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.png" name="Submit" alt="Add To Cart" /></form>'; break; } $a++; } } elseif ( count($xprods) > 4 ) { $c = 0; while ( $c < 4 ) { $pick = rand(1,count($xprods)); $pick = $pick - 1; switch ($c) { case 0: $x1 = $xprods[$pick]; break; case 1: $x2 = $xprods[$pick]; break; case 2: $x3 = $xprods[$pick]; break; case 3: $x4 = $xprods[$pick]; break; } unset($xprods[$pick]); $xprods = array_values($xprods); $c++; } $sql = "SELECT code, title, img, url, price FROM products WHERE active='1' AND live='1' AND productid='".$x1."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { $x1 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x1a = '£'.$row['price']; $x1b = '<form method="post" action="https://www.domain.com/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.png" name="Submit" alt="Add To Cart" /></form>'; } $sql = "SELECT code, title, img, url, price FROM products WHERE active='1' AND live='1' AND productid='".$x2."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { $x2 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x2a = '£'.$row['price']; $x2b = '<form method="post" action="https://www.domain.com/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.png" name="Submit" alt="Add To Cart" /></form>'; } $sql = "SELECT code, title, img, url, price FROM products WHERE active='1' AND live='1' AND productid='".$x3."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { $x3 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x3a = '£'.$row['price']; $x3b = '<form method="post" action="https://www.domain.com/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.png" name="Submit" alt="Add To Cart" /></form>'; } $sql = "SELECT code, title, img, url, price FROM products WHERE active='1' AND live='1' AND productid='".$x4."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { $x4 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x4a = '£'.$row['price']; $x4b = '<form method="post" action="https://www.domain.com/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.png" name="Submit" alt="Add To Cart" /></form>'; } } $data .= ' </font> <table border="0" width="600px"> <tr style="background-color: #2658C8; color:#FFFFFF; font-weight: bold; font-size: 15px; font-family:Verdana, Arial, Helvetica, sans-serif;"> <td colspan="4">You may also be interested in these products...</td> </tr> <tr> <td align="center" style="vertical-align:top; font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x1.'</td> <td align="center" style="vertical-align:top; font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x2.'</td> <td align="center" style="vertical-align:top; font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x3.'</td> <td align="center" style="vertical-align:top; font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x4.'</td> </tr> <tr> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x1a.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x2a.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x3a.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x4a.'</td> </tr> <tr> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x1b.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x2b.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x3b.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x4b.'</td> </tr> </table> '; break; I'd like to get that code to work in the same way, ie, if the back end DB has the not available flag set to yes the add to cart button is replaced as in my second code snippet. Hope someone can help! Thanks
-
You sir are a genius! It now passes the correct amount, will that line of code only affect the $centinel_total string? The tax amount isn't used by them but their logs show an incorrect amount there too, would I just add the same sort of thing above the $centinel_vatamont string?
-
Hi David, I'm really glad you replied as you helped me out in the past! I lost your contact details as my hard drive failed and the backup I had failed too! I lost all my emails & contacts and baby photo's etc. Anyway, I'll give that a go, I think you are on the right lines as it seems weird why it would all work under £1000 but go completely wrong when £1000 or above. If that doesn't work would you be interested in looking into it for me? Obviously I'll pay you for your time Thanks, Dave
-
$subtotal = $row[0]; $delivery = $row[1]; $discount = $row[2]; $vatrate = $row[3]; $totalex = str_replace(",","",$subtotal) + str_replace(",","",$delivery); $vatamount = ($totalex - $discount) * ($vatrate/100); $vatamount = number_format($vatamount, 2, '.', ','); $total = $row[4]; $centinel_total = $total * 100; $centinel_delivery = $delivery * 100; $centinel_vatamount = $vatamount * 100; I've got a custom written cart system which for some reason is not passing the correct amounts to our 3D secure processor (Cardinel commerce). I'm not a programmer but looking at how it seems to work I think the issue is with this code. From the processor logs we are passing the tax value with a negative amount and the total is always £1 when the total is above £1000. It all works fine as it should if the total amount is LESS than £1000! Anyone got any ideas what's going on? I'm more than happy to pay someone to fix this!!
-
Thanks, so i need to change code in this section?? $sql = "UPDATE cartitems SET quantity='".$_POST['quantity']."' WHERE cartitemid='".mysql_real_escape_string($_POST['cartitem'])."'"; mysql_query($sql); } header ("Location: cart.php"); } ?? Thanks again.
-
I’m trying to make the update qty script for our cart work so it stays on the page you are on, eg, if the qty is changed at stage 3 of the cart the qty updates & you stay on cart 3. Currently it would take you back to cart stage 1! The code currently looks like this :- <?php session_start(); if ( $_SESSION['locked'] != 1 ) { include_once("config.php"); if ( ( !isset($_POST['cartitem']) ) || ( $_POST['cartitem'] == '' ) ) { include_once("top.php"); echo 'Please go back and select a product to change the quantity of from your cart.'; include_once("bottom.php"); } else { if ( $_POST['quantity'] == '0' ) { $sql = "UPDATE cartitems SET active='0' WHERE cartitemid='".mysql_real_escape_string($_POST['cartitem'])."'"; mysql_query($sql); } else { $sql = "UPDATE cartitems SET quantity='".$_POST['quantity']."' WHERE cartitemid='".mysql_real_escape_string($_POST['cartitem'])."'"; mysql_query($sql); } header ("Location: cart.php"); } } else { header ("Location: cart.php"); } ?> I tried modifying the link on each cart page so rather than the script called as <form method="post" action="s_updateqty.php"> I changed it to <form method="post" action="s_updateqty.php?cartpage=a"> for cart1.php then cartpage=b for cart2.php etc. I then modified the script attached as follows :- include_once("bottom.php"); } else { if ( $_POST['quantity'] == '0' ) { $sql = "UPDATE cartitems SET active='0' WHERE cartitemid='".mysql_real_escape_string($_POST['cartitem'])."'"; mysql_query($sql); } else { $sql = "UPDATE cartitems SET quantity='".$_POST['quantity']."' WHERE cartitemid='".mysql_real_escape_string($_POST['cartitem'])."'"; mysql_query($sql); } header ("Location: cart.php"); } } else { if ( $_GET['cartpage'] == "a" ) { header ("Location: cart.php"); } if ( $_GET['cartpage'] == "b" ) { header ("Location: cart2.php"); } if ( $_GET['cartpage'] == "c" ) { header ("Location: cart3.php"); } } ?> But it didn't work, can anyone suggest how I can get this to work. I know nothing about PHP so i'm just trying my best here. Developers don't want to know as the job is too small Thanks for any help anyone can offer
-
Many moons ago we had a custom cart written, works great but I need to make some changes, just can't seem to get them to work! There is a file called data.php which has this code :- case 20: //Displays the add to cart form & cross selling info. Requires product ID $sql = "SELECT code FROM products WHERE productid='".mysql_real_escape_string($_GET['id'])."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { $data = '<font size="2" face="Verdana, Arial, Helvetica, sans-serif"color="#000000"><form method="post" action="https://www.domain.co.uk/s_addtocart.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" style="vertical-align:middle; border: none;" />Quantity: <input type="text" name="quantity" size="3" value="1" /></form></font>'; } //Displays cross selling information. Requires product ID $xprods = array(); $sql = "SELECT xselling.xproductid FROM xselling, products WHERE xselling.xproductid=products.productid AND xselling.active='1' AND products.active='1' AND products.live='1' AND xselling.productid='".mysql_real_escape_string($_GET['id'])."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { array_push($xprods, $row['xproductid']); } if ( (count($xprods) <= 4) && (count($xprods) > 0) ) { $a = 0; $b = count($xprods); while ( $a < $b ) { $sql = "SELECT code, title, img, url, price FROM products WHERE active='1' AND live='1' AND productid='".$xprods[$a]."'"; $result = mysql_query($sql); switch ($a) { case 0: $row = mysql_fetch_assoc($result); $x1 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x1a = '£'.$row['price']; $x1b = '<form method="post" action="https://www.domain.co.uk/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" /></form>'; break; case 1: $row = mysql_fetch_assoc($result); $x2 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x2a = '£'.$row['price']; $x2b = '<form method="post" action="https://www.domain.co.uk/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" /></form>'; break; case 2: $row = mysql_fetch_assoc($result); $x3 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x3a = '£'.$row['price']; $x3b = '<form method="post" action="https://www.domain.co.uk/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" /></form>'; break; case 3: $row = mysql_fetch_assoc($result); $x4 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x4a = '£'.$row['price']; $x4b = '<form method="post" action="https://www.domain.co.uk/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" /></form>'; break; } $a++; } } elseif ( count($xprods) > 4 ) { $c = 0; while ( $c < 4 ) { $pick = rand(1,count($xprods)); $pick = $pick - 1; switch ($c) { case 0: $x1 = $xprods[$pick]; break; case 1: $x2 = $xprods[$pick]; break; case 2: $x3 = $xprods[$pick]; break; case 3: $x4 = $xprods[$pick]; break; } unset($xprods[$pick]); $xprods = array_values($xprods); $c++; } $sql = "SELECT code, title, img, url, price FROM products WHERE active='1' AND live='1' AND productid='".$x1."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { $x1 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x1a = '£'.$row['price']; $x1b = '<form method="post" action="https://www.domain.co.uk/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" /></form>'; } $sql = "SELECT code, title, img, url, price FROM products WHERE active='1' AND live='1' AND productid='".$x2."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { $x2 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x2a = '£'.$row['price']; $x2b = '<form method="post" action="https://www.domain.co.uk/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" /></form>'; } $sql = "SELECT code, title, img, url, price FROM products WHERE active='1' AND live='1' AND productid='".$x3."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { $x3 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x3a = '£'.$row['price']; $x3b = '<form method="post" action="https://www.domain.co.uk/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" /></form>'; } $sql = "SELECT code, title, img, url, price FROM products WHERE active='1' AND live='1' AND productid='".$x4."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { $x4 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x4a = '£'.$row['price']; $x4b = '<form method="post" action="https://www.domain.co.uk/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" /></form>'; } } $data .= ' <table border="0" width="600px"> <tr style="background-color: #999999; color:#FFFFFF; font-weight: bold; font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;"> <td colspan="4">You may also be interested in....</td> </tr> <tr> <td align="center" style="vertical-align:top; font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x1.'</td> <td align="center" style="vertical-align:top; font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x2.'</td> <td align="center" style="vertical-align:top; font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x3.'</td> <td align="center" style="vertical-align:top; font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x4.'</td> </tr> <tr> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x1a.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x2a.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x3a.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x4a.'</td> </tr> <tr> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x1b.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x2b.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x3b.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x4b.'</td> </tr> </table> '; break; } } I was trying to merge that case with this one :- case 19: //Displays the cart summary with icons. The id of the cart comes from the session variables $sql = "SELECT cartid FROM carts WHERE progress='0' AND ipaddress='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."' AND browser='".mysql_real_escape_string($_SERVER['HTTP_USER_AGENT'])."' AND datestarted >= '".mysql_real_escape_string(date("Y-m-d H:i:s", mktime(date("H"),(date("i")-$timedelay),date("s"),date("m"),date("d"),date("Y"))))."' ORDER BY cartid DESC LIMIT 1"; $result = mysql_query($sql); if ( mysql_num_rows($result) != 0 ) { $row = mysql_fetch_row($result); $_SESSION['cartid'] = $row[0]; } $data = '<font size="2" face="Verdana, Arial, Helvetica, sans-serif"color="#000000">'; if ( !(isset($_SESSION['cartid'])) || ($_SESSION['cartid'] == "") ) //if ( (!isset($_COOKIE['RITD_Cart_ID'])) || ($_COOKIE['RITD_Cart_ID'] == '') ) { $data .= '<img src="images/cart.jpg" alt="Cart is empty" width="27" height="15" hspace="2">'; $data .= 'No items have been added to the cart yet.'; } else { $sql = "SELECT sub FROM carts WHERE cartid='".$_SESSION['cartid']."'"; //$sql = "SELECT orderno, sub FROM carts WHERE cartid='".$_COOKIE['RITD_Cart_ID']."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { if ( $row['sub'] == "" ) { $row['sub'] = "0.00"; } $orderno = $orderpre . ($orderstart+$_SESSION['cartid']); $data .= '<img src="images/cart.jpg" alt="Items in cart" width="27" height="15" hspace="2">'; $data .= 'Order Number: '.$orderno.' with Sub-Total: £'.$row['sub']; $data = str_replace("&", "&", $data); } } $data .= '</font>'; break; Which resulted in me making a new case 21 which was this :- case 21: //Displays the add to cart form & cross selling info. Requires product ID $sql = "SELECT code FROM products WHERE productid='".mysql_real_escape_string($_GET['id'])."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { $data = '<font size="2" face="Verdana, Arial, Helvetica, sans-serif"color="#000000"><form method="post" action="https://www.domain.co.uk/s_addtocart.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" style="vertical-align:middle; border: none;" />Quantity: <input type="text" name="quantity" size="3" value="1" /></form></font>'; } //Displays cross selling information. Requires product ID $xprods = array(); $sql = "SELECT xselling.xproductid FROM xselling, products WHERE xselling.xproductid=products.productid AND xselling.active='1' AND products.active='1' AND products.live='1' AND xselling.productid='".mysql_real_escape_string($_GET['id'])."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { array_push($xprods, $row['xproductid']); } if ( (count($xprods) <= 4) && (count($xprods) > 0) ) { $a = 0; $b = count($xprods); while ( $a < $b ) { $sql = "SELECT code, title, img, url, price FROM products WHERE active='1' AND live='1' AND productid='".$xprods[$a]."'"; $result = mysql_query($sql); switch ($a) { case 0: $row = mysql_fetch_assoc($result); $x1 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x1a = '£'.$row['price']; $x1b = '<form method="post" action="https://www.domain.co.uk/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" /></form>'; break; case 1: $row = mysql_fetch_assoc($result); $x2 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x2a = '£'.$row['price']; $x2b = '<form method="post" action="https://www.domain.co.uk/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" /></form>'; break; case 2: $row = mysql_fetch_assoc($result); $x3 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x3a = '£'.$row['price']; $x3b = '<form method="post" action="https://www.domain.co.uk/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" /></form>'; break; case 3: $row = mysql_fetch_assoc($result); $x4 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x4a = '£'.$row['price']; $x4b = '<form method="post" action="https://www.domain.co.uk/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" /></form>'; break; } $a++; } } elseif ( count($xprods) > 4 ) { $c = 0; while ( $c < 4 ) { $pick = rand(1,count($xprods)); $pick = $pick - 1; switch ($c) { case 0: $x1 = $xprods[$pick]; break; case 1: $x2 = $xprods[$pick]; break; case 2: $x3 = $xprods[$pick]; break; case 3: $x4 = $xprods[$pick]; break; } unset($xprods[$pick]); $xprods = array_values($xprods); $c++; } $sql = "SELECT code, title, img, url, price FROM products WHERE active='1' AND live='1' AND productid='".$x1."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { $x1 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x1a = '£'.$row['price']; $x1b = '<form method="post" action="https://www.domain.co.uk/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" /></form>'; } $sql = "SELECT code, title, img, url, price FROM products WHERE active='1' AND live='1' AND productid='".$x2."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { $x2 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x2a = '£'.$row['price']; $x2b = '<form method="post" action="https://www.domain.co.uk/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" /></form>'; } $sql = "SELECT code, title, img, url, price FROM products WHERE active='1' AND live='1' AND productid='".$x3."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { $x3 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x3a = '£'.$row['price']; $x3b = '<form method="post" action="https://www.domain.co.uk/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" /></form>'; } $sql = "SELECT code, title, img, url, price FROM products WHERE active='1' AND live='1' AND productid='".$x4."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { $x4 = '<a href="'.$producturl.$row['url'].'" style="color:#0000FF;"><img src="'.$imageurl.$row['img'].'" border="none" alt="'.$row['title'].'" /><br />'.$row['title'].'</a>'; $x4a = '£'.$row['price']; $x4b = '<form method="post" action="https://www.domain.co.uk/s_quickadd.php" target="_blank"><input type="hidden" name="code" value="'.$row['code'].'" /><input type="image" src="images/add.gif" name="Submit" alt="Add To Cart" /></form>'; } } $data .= ' <table border="0" width="600px"> <tr style="background-color: #999999; color:#FFFFFF; font-weight: bold; font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;"> <td colspan="4">You may also be interested in....</td> </tr> <tr> <td align="center" style="vertical-align:top; font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x1.'</td> <td align="center" style="vertical-align:top; font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x2.'</td> <td align="center" style="vertical-align:top; font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x3.'</td> <td align="center" style="vertical-align:top; font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x4.'</td> </tr> <tr> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x1a.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x2a.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x3a.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x4a.'</td> </tr> <tr> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x1b.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x2b.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x3b.'</td> <td align="center" style="font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif;">'.$x4b.'</td> </tr> </table> '; //Displays the cart summary with icons. The id of the cart comes from the session variables $sql = "SELECT cartid FROM carts WHERE progress='0' AND ipaddress='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."' AND browser='".mysql_real_escape_string($_SERVER['HTTP_USER_AGENT'])."' AND datestarted >= '".mysql_real_escape_string(date("Y-m-d H:i:s", mktime(date("H"),(date("i")-$timedelay),date("s"),date("m"),date("d"),date("Y"))))."' ORDER BY cartid DESC LIMIT 1"; $result = mysql_query($sql); if ( mysql_num_rows($result) != 0 ) { $row = mysql_fetch_row($result); $_SESSION['cartid'] = $row[0]; } $data = '<font size="2" face="Verdana, Arial, Helvetica, sans-serif"color="#000000">'; if ( !(isset($_SESSION['cartid'])) || ($_SESSION['cartid'] == "") ) //if ( (!isset($_COOKIE['RITD_Cart_ID'])) || ($_COOKIE['RITD_Cart_ID'] == '') ) { $data .= '<img src="images/cart.jpg" alt="Cart is empty" width="27" height="15" hspace="2">'; $data .= 'No items have been added to the cart yet.'; } else { $sql = "SELECT sub FROM carts WHERE cartid='".$_SESSION['cartid']."'"; //$sql = "SELECT orderno, sub FROM carts WHERE cartid='".$_COOKIE['RITD_Cart_ID']."'"; $result = mysql_query($sql); while ( $row = @mysql_fetch_array($result, MYSQL_BOTH) ) { if ( $row['sub'] == "" ) { $row['sub'] = "0.00"; } $orderno = $orderpre . ($orderstart+$_SESSION['cartid']); $data .= '<img src="images/cart.jpg" alt="Items in cart" width="27" height="15" hspace="2">'; $data .= 'Order Number: '.$orderno.' with Sub-Total: £'.$row['sub']; $data = str_replace("&", "&", $data); } } $data .= '</font>'; break; } } But all that displays on the webpage is the info from the original case 19. Any ideas? Thanks
-
Thanks for all of your help David, it works
-
Thanks again for your time with this, i'll take another look later today
-
That's all well & good but I know NOTHING about programming! I'm an electrician, if someone asks a question on electrics to me I explain what they need to do. I don't expect them to learn how to rewire an entire house & fully understand all the circuits involved! Yes I'd like to learn a bit of PHP but obviously this is not for me, if a block of code needs changing & find & replace is no use for this I'm already stumped! (to me it's like having a tool that doesn't do what it says, ie, modify a block of code).
-
Hi, Thanks for your reply, i'll try some editing on Monday & let you know.
-
Hi, Sorry but since you've edited the post I can't find the block of code using find & replace in DW??
-
Not sure how to post it with line number but in the block of code :- //Add E-mail Address $sql6 = "SELECT email FROM carts WHERE cartid='".$cart."'"; $result6 = mysql_query($sql6); $emailaddress = ''; while ( $row6 = @mysql_fetch_array($result6, MYSQL_BOTH) ) { $addemail .= ' <form method="post" action="cart2.php" name="emailform"> '; $addemail .= ' E-mail Address: <input type="text" name="email" value="'.$row6['email'].'" size="19" /><input type="hidden" name="cartid" value="'.$cart.'" />'; if ( $emailerror != '' ) { $addemail .= '<img src="images/email_error.png" width="16" height="16" hspace="4" alt="E-mail Error" />'; } $addemail .= ' <input type="image" name="Add E-mail Address" alt="Add E-mail Address" src="images/confirmemail.gif" style="vertical-align:middle" /> </form> '; *******LINE 868******* if ( $row6['email'] == '' ) { $emailpresent = 0; } else { $emailpresent = 1; } } $addemail .= ' </td> </tr> '; } ?> <?php Line 868 as above. Thanks
-
OK, i did a find & replace in DW so it looks like this :- //Add E-mail Address $sql6 = "SELECT email FROM carts WHERE cartid='".$cart."'"; $result6 = mysql_query($sql6); $emailaddress = ''; while ( $row6 = @mysql_fetch_array($result6, MYSQL_BOTH) ) { $addemail .= ' <form method="post" action="cart2.php" name="emailform"> '; if ($emailerror =='') $addemail .= ' E-mail Address: <input type="text" style="background:#cfc" "border-color": "#0c0" name="email" value="'.$row6['email'].'" size="19" /><input type="hidden" name="cartid" value="'.$cart.'" />'; else { $addemail .= E-mail Address: <input type="text" style="background:#f00" "border-color": "#0c0" name="email" value="'.$row6['email'].'" size="19" /><input type="hidden" name="cartid" value="'.$cart.'" />'<img src="images/email_error.png" width="16" height="16" hspace="4" alt="E-mail Error" />'; } $addemail .= ' <input type="image" name="Add E-mail Address" alt="Add E-mail Address" src="images/confirmemail.gif" style="vertical-align:middle" /> </form> '; if ( $row6['email'] == '' ) { $emailpresent = 0; } else { $emailpresent = 1; } } $addemail .= ' </td> </tr> '; } ?> I now get a server 500 error, log says :- [01-Mar-2013 11:55:26 UTC] PHP Parse error: syntax error, unexpected T_STRING in /home/domainname/public_html/cart2.php on line 868
-
Thanks for your reply, I'll give it a go later today & let you know OT, is PHP a hard language to learn? I know NOTHING about programming but find this interesting, maybe time to get learning but haven't a clue where to start!!
-
//Add E-mail Address $sql6 = "SELECT email FROM carts WHERE cartid='".$cart."'"; $result6 = mysql_query($sql6); $emailaddress = ''; while ( $row6 = @mysql_fetch_array($result6, MYSQL_BOTH) ) { $addemail .= ' <form method="post" action="cart2.php" name="emailform"> '; $addemail .= ' E-mail Address: <input type="text" style="background:#cfc" "border-color": "#0c0" name="email" value="'.$row6['email'].'" size="19" /><input type="hidden" name="cartid" value="'.$cart.'" />'; if ( $emailerror != '' ) { $addemail .= '<img src="images/email_error.png" width="16" height="16" hspace="4" alt="E-mail Error" />'; } $addemail .= ' <input type="image" name="Add E-mail Address" alt="Add E-mail Address" src="images/confirmemail.gif" style="vertical-align:middle" /> </form> '; if ( $row6['email'] == '' ) { $emailpresent = 0; } else { $emailpresent = 1; } } $addemail .= ' </td> </tr> '; } ?> Sorry, done as above, can you let me know what I need to change? I know nothing about php. Thanks for your time
-
Hi, I have a page that was custom written by a developer some time ago, the page has an email entry text area which currently has some form of checking on it but as to how it works I do not know! The code is as follows :- //Add E-mail Address $sql6 = "SELECT email FROM carts WHERE cartid='".$cart."'"; $result6 = mysql_query($sql6); $emailaddress = ''; while ( $row6 = @mysql_fetch_array($result6, MYSQL_BOTH) ) { $addemail .= ' <form method="post" action="cart2.php" name="emailform"> '; $addemail .= ' E-mail Address: <input type="text" style="background:#cfc" "border-color": "#0c0" name="email" value="'.$row6['email'].'" size="19" /><input type="hidden" name="cartid" value="'.$cart.'" />'; if ( $emailerror != '' ) { $addemail .= '<img src="images/email_error.png" width="16" height="16" hspace="4" alt="E-mail Error" />'; } $addemail .= ' <input type="image" name="Add E-mail Address" alt="Add E-mail Address" src="images/confirmemail.gif" style="vertical-align:middle" /> </form> '; if ( $row6['email'] == '' ) { $emailpresent = 0; } else { $emailpresent = 1; } } $addemail .= ' </td> </tr> '; } ?> The text input box has a green background, if the email address is invalid the page reloads but an error image appears next to the text box. What I'd also like to do is if this happens change the colour of the text box. Is this possible? I'm not a programmer, just trying to get my way through this. Thanks for any help
-
Hmm, it may be worth an email to Pay Pal MTS to see if this happens in any way, I doubt it though! Thanks again for your help.
- 8 replies
-
- php
- javascript
-
(and 1 more)
Tagged with:
-
OK, thanks. So there really is no way to detect anything on an iFrame that resides on a different domain? Be it a click or height change or another window opening?
- 8 replies
-
- php
- javascript
-
(and 1 more)
Tagged with:
-
I found this code when looking around :- function iframeClickHandler() { alert("Iframe clicked"); } var iframe = document.getElementById("myIframe"); var iframeDoc = iframe.contentDocument || iframe.contentwindow.document; if (typeof iframeDoc.addEventListener != "undefined") { iframeDoc.addEventListener("click", iframeClickHandler, false); } else if (typeof iframeDoc.attachEvent != "undefined") { iframeDoc.attachEvent ("onclick", iframeClickHandler); } Which claims it can detect a click in an iFrame? If that is correct then if this could be made to detect the click then call the sql function this would work??
- 8 replies
-
- php
- javascript
-
(and 1 more)
Tagged with:
-
hmm, back to the iFrame issue. Looking at the process further what happens is the card payment info opens in an iFrame, once that stage is complete the 3DS info opens another iFrame, so an iFrame in an iFrame! Is there a way to detect that happeing? We don't need to know what the URL is or anything like that just the fact a second iFrame has opened in the iFrame(!!). Or does the fact that this happens in an iFrame mean we can't detect anyhting? Sorry if these are dumb questions but I know nothing about this, just trying to finish what a pro started.
- 8 replies
-
- php
- javascript
-
(and 1 more)
Tagged with:
-
Oh well, that's a shame. Seems strange the programmer did not know this The status updates once the payment is complete as it redirects to another page, shame the 3DS does not have that ability as we could then fix this issue. I do have another problem(!). We also have JS validation on one of the entry pages(hosted on our server this time), it uses a script called Fvalidator which has been modified so we can switch the JS on & off from our back end system. I'd like to add this to another page for an email entry text box, if anyone fancies earning some beer money please drop me a message! TIA
- 8 replies
-
- php
- javascript
-
(and 1 more)
Tagged with:
-
Just a quick hello, I'm not a programmer & know nothing about PHP! I found this website via a Google search, seems the right place to get help on PHP issues (which I have , see my first post!). Looking around I wish I'd taken up programming rather than hardware
-
Not even sure if this is possible, I know nothing about programming!! Basically our developer disappeared mid job, never good but hey. Anyway, I've bungled my way through most of the issues that were outstanding with help from others which in a way has been good fun On to the problem, we have a payment page which takes users details such as address etc. When the user clicks "make payment" the page changes to the payment screen where the card data appears in an iFrame (it's a Pay Pal Hosted solution). The issue is the cart progress is reported in our admin section, the line of code I can see is as follows :- $sql = "UPDATE carts SET progress='19' WHERE cartid='".$_SESSION['cartid']."'"; mysql_query($sql); I can see the set progress number is pulled from another file which features code such as :- elseif ( $row['progress'] == '19' ) { echo 'iFrame Payment Page'; This works all well & good. The problem is the iFrame has two stages, the first stage is card data like number & expiry, once this is submitted the iFrame changes to 3D Secure (Mastercard Secure code or Verfied by Visa). What I don't know how to do is get the progress to report this? It seems it is possible as the code is there ready & waiting :- elseif ( $row['progress'] == '15' ) { echo '3Ds iframe Page'; I "just" don't know how to get the sql output? I tried adding :- $sql = "UPDATE carts SET progress='15' WHERE cartid='".$_SESSION['cartid']."'"; mysql_query($sql); Below the iFrame code but of course that just chages the progress status when the iFrame loads NOT when the iFrame changes. I guess I need some way of detecting the iFrame refresh or page change? Any help would be great, or if someone can fix this for some beer money then feel free to contact me. A web design company say they can do it but it would take around 4 hours @ £25 PH, not really worth me spending £100 to get a status changed in an admin system!(especially as this is the back up payment method that rarely gets used, it's just me wanting to fix the "bugs"!!) Thanks for any help
- 8 replies
-
- php
- javascript
-
(and 1 more)
Tagged with: