Jump to content

Search the Community

Showing results for tags 'the original price'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 1 result

  1. hey, ok im trying to add the used price of an item within the cart that holds the original price. so i created a duplicated of the original price script so i can add the used price if (isset($_POST['pid'])) { $pid = $_POST['pid']; $wasFound = false; $i = 0; // If the cart session variable is not set or cart array is empty if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) { // RUN IF THE CART IS EMPTY OR NOT SET $_SESSION["cart_array"] = array(0 => array("item_id" => $pid, "quantity" => 1)); setcookie('id', $pid, time() + (86400 * 7)); setcookie('quantity', '1', time() + (86400 * 7)); } else { // RUN IF THE CART HAS AT LEAST ONE ITEM IN IT foreach ($_SESSION["cart_array"] as $each_item) { $i++; while (list($key, $value) = each($each_item)) { if ($key == "item_id" && $value == $pid) { // That item is in cart already so let's adjust its quantity using array_splice() array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $pid, "quantity" => $each_item['quantity'] + 1))); setcookie('id', $pid, time() + (86400 * 7)); setcookie('quantity', $each_item['quantity'], time() + (86400 * 7)); $wasFound = true; } // close if condition } // close while loop } // close foreach loop if ($wasFound == false) { array_push($_SESSION["cart_array"], array("item_id" => $pid, "quantity" => 1)); setcookie('id', $pid, time() + (86400 * 7)); setcookie('quantity', $each_item['quantity'], time() + (86400 * 7)); } } header("location: confirm.php"); exit(); } and this is the script for the used price if(isset($_POST['uid'])){ $use = $_POST['uid']; $use_product = $_POST['used']; $i = 0; $wasFound = false; if(!isset($_SESSION['cart_array']) || count($_SESSION['cart_array']) < 1){ $_SESSION['cart_array'] = array(0 => array("item_id" => $use, "quantity" => 1, "price" => $use_product)); header("location: confirm.php"); }else{ foreach($_SESSION['cart_array'] as $each_item){ $i++; while(list($key, $value) = each($each_item)){ if($key == "item_id" && $value == $use){ // that item is in the cart already adject quantity array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $use, "quantity" => $each_item["quantity"] + 1, "price" => $use_product))); $wasFound = true; header("location: confirm.php"); } } } // if no item is in the cart if($wasFound == false){ array_push($_SESSION['cart_array'], array("item_id" => $use, "quantity" => 1)); header("location: confirm.php"); } } } I probably dont need both of these script right? and how can i excuted these prices so both can be added to the cart and not just add the same price so pretty much original price is 20 and the used price is 10 but i keep on getting the total of 40 instead of 30 help please, no scripts please
×
×
  • Create New...