Page 1 of 1

help plaincart

Posted: Wed Jun 10, 2009 6:29 am
by staxman
Hello. I open this post here that I saw some serious problems with plaincart I also got it and I did new things, but the problem I'm having right now in the admin / order. Not accept all options only work order, but not that of (paid, news, shippign, etc.), here I leave the code to see if I'm lucky that someone can help me
processOrder.php

Code: Select all

<?php
require_once '../../library/config.php';
require_once '../library/functions.php';
 
checkUser();
 
$action = isset($_GET['action']) ? $_GET['action'] : '';
 
switch ($action) {
    case 'modify' :
        modifyOrder();
        break;
 
    default :
        // if action is not defined or unknown
        // move to main category page
        header('Location: index.php');
}
 
 
 
function modifyOrder()
{
    if (!isset($_GET['oid']) || (int)$_GET['oid'] <= 0
        || !isset($_GET['status']) || $_GET['status'] == '') {
        header('Location: index.php');
    }
    
    $orderId = (int)$_GET['oid'];
    $status  = $_GET['status'];
    
    $sql = "UPDATE tbl_order
            SET od_status = '$status', od_last_update = NOW()
            WHERE od_id = $orderId";
    $result = dbQuery($sql);
    
    header("Location: index.php?view=list&status=$status");    
}
 
?>


list.php

Code: Select all

<?php 
if (!defined('WEB_ROOT')) { 
    exit; 
} 
 
 
if (isset($_GET['status']) && $_GET['status'] != '') { 
    $status = $_GET['status']; 
    $sql2   = " AND od_status = '$status'"; 
    $queryString = "&status=$status"; 
} else { 
    $status = ''; 
    $sql2   = ''; 
    $queryString = ''; 
}     
 
// for paging 
// how many rows to show per page 
$rowsPerPage = 10; 
 
$sql = "SELECT o.od_id, o.od_shipping_first_name, od_shipping_last_name, od_date, od_status, 
               SUM(pd_price * od_qty) + od_shipping_cost AS od_amount 
        FROM tbl_order o, tbl_order_item oi, tbl_product p 
        WHERE oi.pd_id = p.pd_id and o.od_id = oi.od_id $sql2 
        GROUP BY od_id 
        ORDER BY od_id DESC"; 
$result     = dbQuery(getPagingQuery($sql, $rowsPerPage)); 
$pagingLink = getPagingLink($sql, $rowsPerPage, $queryString); 
 
$orderStatus = array('New', 'Paid', 'Shipped', 'Completed', 'Cancelled'); 
$orderOption = ''; 
foreach ($orderStatus as $stat) { 
    $orderOption .= "<option value=\"$stat\""; 
    if ($stat == $status) { 
        $orderOption .= " selected"; 
    } 
     
    $orderOption .= ">$stat</option>rn"; 
} 
?> 
<p>&nbsp;</p> 
<form action="processOrder.php" method="post"  name="frmOrderList" id="frmOrderList"> 
<table width="100%" border="0" cellspacing="0" cellpadding="2" class="text"> 
<tr align="center"> 
  <td align="right">View</td> 
  <td width="75"><select name="cboOrderStatus" class="box" id="cboOrderStatus" onChange="viewOrder();"> 
    <option value="" selected>All</option> 
    <?php echo $orderOption; ?> 
  </select></td> 
  </tr> 
</table> 
 
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="text"> 
  <tr align="center" id="listTableHeader"> 
   <td width="60">Order #</td> 
   <td>Customer Name</td> 
   <td width="60">Amount</td> 
   <td width="150">Order Time</td> 
   <td width="70">Status</td> 
  </tr> 
  <?php 
$parentId = 0; 
if (dbNumRows($result) > 0) { 
    $i = 0; 
     
    while($row = dbFetchAssoc($result)) { 
        extract($row); 
        $name = $od_shipping_first_name . ' ' . $od_shipping_last_name; 
         
        if ($i%2) { 
            $class = 'row1'; 
        } else { 
            $class = 'row2'; 
        } 
         
        $i += 1; 
?> 
  <tr class="<?php echo $class; ?>"> 
   <td width="60"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?view=detail&oid=<?php echo $od_id; ?>"><?php echo $od_id; ?></a></td> 
   <td><?php echo $name ?></td> 
   <td width="60" align="right"><?php echo displayAmount($od_amount); ?></td> 
   <td width="150" align="center"><?php echo $od_date; ?></td> 
   <td width="70" align="center"><?php echo $od_status; ?></td> 
  </tr> 
  <?php 
    } // end while 
 
?> 
  <tr> 
   <td colspan="5" align="center"> 
   <?php 
   echo $pagingLink; 
   ?></td> 
  </tr> 
<?php 
} else { 
?> 
  <tr> 
   <td colspan="5" align="center">No Orders Found </td> 
  </tr> 
  <?php 
} 
?> 
 
</table> 
<p>&nbsp;</p> 
</form>


Detail - here i cant change modifiq status

Code: Select all

<?php
if (!defined('WEB_ROOT')) {
    exit;
}
 
if (!isset($_GET['oid']) || (int)$_GET['oid'] <= 0) {
    header('Location: index.php');
}
 
$orderId = (int)$_GET['oid'];
 
// get ordered items
$sql = "SELECT pd_name, pd_price, od_qty
        FROM tbl_order_item oi, tbl_product p 
        WHERE oi.pd_id = p.pd_id and oi.od_id = $orderId
        ORDER BY od_id ASC";
 
$result = dbQuery($sql);
$orderedItem = array();
while ($row = dbFetchAssoc($result)) {
    $orderedItem[] = $row;
}
 
 
// get order information
$sql = "SELECT od_date, od_last_update, od_status, od_shipping_first_name, od_shipping_last_name, od_shipping_address1, 
               od_shipping_address2, od_shipping_phone, od_shipping_state, od_shipping_city, od_shipping_postal_code, od_shipping_cost, 
               od_payment_first_name, od_payment_last_name, od_payment_address1, od_payment_address2, od_payment_phone,
               od_payment_state, od_payment_city , od_payment_postal_code,
               od_memo
        FROM tbl_order 
        WHERE od_id = $orderId";
 
$result = dbQuery($sql);
extract(dbFetchAssoc($result));
 
$orderStatus = array('New', 'Paid', 'Shipped', 'Completed', 'Cancelled');
$orderOption = '';
foreach ($orderStatus as $status) {
    $orderOption .= "<option value=\"$status\"";
    if ($status == $od_status) {
        $orderOption .= " selected";
    }
    
    $orderOption .= ">$status</option>\r\n";
}
?>
<p>&nbsp;</p>
<form action="" method="get" name="frmOrder" id="frmOrder">
    <table width="550" border="0"  align="center" cellpadding="5" cellspacing="1" class="detailTable">
        <tr> 
            <td colspan="2" align="center" id="infoTableHeader">Detalles de la Orden</td>
        </tr>
        <tr> 
            <td width="150" class="label"> Numero de Orden</td>
            <td class="content"><?php echo $orderId; ?></td>
        </tr>
        <tr> 
            <td width="150" class="label">Datos de Orden</td>
            <td class="content"><?php echo $od_date; ?></td>
        </tr>
        <tr> 
            <td width="150" class="label">Ultima actualizacion</td>
            <td class="content"><?php echo $od_last_update; ?></td>
        </tr>
        <tr> 
            <td class="label">Estatus</td>
  <td class="content"> <select name="cboOrderStatus" id="cboOrderStatus" class="box">
                    <?php echo $orderOption; ?> </select> <input name="btnModify" type="button" id="btnModify" value="Modificar Estatus" class="box" onClick="modifyOrderStatus(<?php echo $orderId; ?>);"></td>
        </tr>
    </table>
</form>
<p>&nbsp;</p>
<table width="550" border="0"  align="center" cellpadding="5" cellspacing="1" class="detailTable">
    <tr id="infoTableHeader"> 
        <td colspan="3">Productos Ordenados</td>
    </tr>
    <tr align="center" class="label"> 
        <td>Productos</td>
        <td>Precio</td>
        <td>Total</td>
    </tr>
    <?php
$numItem  = count($orderedItem);
$subTotal = 0;
for ($i = 0; $i < $numItem; $i++) {
    extract($orderedItem[$i]);
    $subTotal += $pd_price * $od_qty;
?>
    <tr class="content"> 
        <td><?php echo "$od_qty X $pd_name"; ?></td>
        <td align="right"><?php echo displayAmount($pd_price); ?></td>
        <td align="right"><?php echo displayAmount($od_qty * $pd_price); ?></td>
    </tr>
    <?php
}
?>
    <tr class="content"> 
        <td colspan="2" align="right">Sub-total</td>
        <td align="right"><?php echo displayAmount($subTotal); ?></td>
    </tr>
    <tr class="content"> 
        <td colspan="2" align="right">&nbsp;</td>
      <td align="right"><?php echo displayAmount($od_shipping_cost); ?></td>
    </tr>
    <tr class="content"> 
        <td colspan="2" align="right">Total</td>
        <td align="right"><?php echo displayAmount($od_shipping_cost + $subTotal); ?></td>
    </tr>
</table>
<p>&nbsp;</p>
<table width="550" border="0"  align="center" cellpadding="5" cellspacing="1" class="detailTable">
    <tr id="infoTableHeader"> 
        <td colspan="2">Informacion de Envio</td>
  </tr>
    <tr> 
        <td width="150" class="label">Nombre / Apellido</td>
      <td class="content"><?php echo $od_shipping_first_name; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Empresa</td>
      <td class="content"><?php echo $od_shipping_last_name; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Direccion n.1</td>
      <td class="content"><?php echo $od_shipping_address1; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Direccion n.2</td>
      <td class="content"><?php echo $od_shipping_address2; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">N. telefonico/ Cel</td>
      <td class="content"><?php echo $od_shipping_phone; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Ciudad / Estado</td>
      <td class="content"><?php echo $od_shipping_state; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Pais</td>
      <td class="content"><?php echo $od_shipping_city; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Codigo Postal</td>
      <td class="content"><?php echo $od_shipping_postal_code; ?> </td>
    </tr>
</table>
<p>&nbsp;</p>
<table width="550" border="0"  align="center" cellpadding="5" cellspacing="1" class="detailTable">
    <tr id="infoTableHeader"> 
        <td colspan="2">Informacion de pago</td>
  </tr>
    <tr> 
        <td width="150" class="label">Nombre / Apellido</td>
      <td class="content"><?php echo $od_payment_first_name; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Empresa</td>
      <td class="content"><?php echo $od_payment_last_name; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Direccion n.1</td>
      <td class="content"><?php echo $od_payment_address1; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Direccion n.2</td>
      <td class="content"><?php echo $od_payment_address2; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">N. telefonico / Cel</td>
      <td class="content"><?php echo $od_payment_phone; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Ciudad / Estado</td>
      <td class="content"><?php echo $od_payment_state; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Pais</td>
      <td class="content"><?php echo $od_payment_city; ?> </td>
    </tr>
    <tr> 
        <td width="150" class="label">Codigo Postal</td>
      <td class="content"><?php echo $od_payment_postal_code; ?> </td>
    </tr>
</table>
<p>&nbsp;</p>
<table width="550" border="0"  align="center" cellpadding="5" cellspacing="1" class="detailTable">
    <tr id="infoTableHeader"> 
        <td colspan="2">Comprador </td>
    </tr>
    <tr> 
        <td colspan="2" class="label"><?php echo nl2br($od_memo); ?> </td>
    </tr>
</table>
<p>&nbsp;</p>
<p align="center"> 
    <input name="btnBack" type="button" id="btnBack" value="Atras" class="box" onClick="window.history.back();">
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>


order.js

Code: Select all

// JavaScript Document
 
function viewOrder()
{
    statusList = window.document.frmOrderList.cboOrderStatus;
    status     = statusList.options[statusList.selectedIndex].value;    
    
    if (status != '') {
        window.location.href = 'index.php?status=' + status;
    } else {
        window.location.href = 'index.php';
    }
}
 
function modifyOrderStatus(orderId)
{
    statusList = window.document.frmOrder.cboOrderStatus;
    status     = statusList.options[statusList.selectedIndex].value;
    window.location.href = 'processOrder.php?action=modify&oid=' + orderId + '&status=' + status;
}
 
function deleteOrder(orderId)
{
 
}

help plz

Re: help plaincart

Posted: Mon Jan 02, 2012 7:37 am
by slin31
I have the same problem ... can't change the order status in plaincart. Please help ! :?:

Re: help plaincart

Posted: Tue Apr 10, 2012 1:52 pm
by smurf
I to have the same problem. Do any of you have a solution yet? I have been "fighting" with this part for a while and hope that I could have a hint to move forward. Thanks

Re: help plaincart

Posted: Tue Apr 10, 2012 4:56 pm
by social_experiment
It might be better to contact the author of the code concerning the problem/s you are experiencing with the code

Re: help plaincart

Posted: Thu Sep 27, 2012 9:06 pm
by smurf
I finally realized that the browser is the problem and not the codes. IE suck! it works fine in Firefox. My issue here now is what make the codes not working correctly in IE. :banghead: :banghead: