Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Order cancelling by the customer?


dougweile

Recommended Posts

Posted

Is there a way to allow customers to cancel orders that have not been shipped yet? I'm having trouble finding this option anywhere in osCommerce, or the support forums.

Posted
Is there a way to allow customers to cancel orders that have not been shipped yet? I'm having trouble finding this option anywhere in osCommerce, or the support forums.

 

 

 

 

account_history_info:

 

 

1)in the top add:

 

$order_cancel_ok2 = array(1); // stati which allow cancelling, 1 = pending

 

 

 

2)in the action switch add:

 

case 'cancel_order':

$order_id = tep_db_prepare_input($_GET['order_id']);

$check_status_query = tep_db_query("select customers_name,

customers_id,

customers_email_address,

orders_status,

date_purchased

from " . TABLE_ORDERS . "

where orders_id = '" . (int)$order_id . "'");

$check_status = tep_db_fetch_array($check_status_query);

if (

($check_status['customers_id'] == $_SESSION['customer_id']) // check if this is his/her order

and (in_array($check_status['orders_status'],$order_cancel_ok2)) // is it ok to cancel?

) {

// status 4 = cancelled

tep_db_query("update " . TABLE_ORDERS . "

set orders_status = '" . tep_db_input(4) . "',

last_modified = now()

where orders_id = '" . (int)$order_id . "'");

 

// update stock and status if order is cancelled

$products_query = tep_db_query("select products_id,

products_quantity

from " . TABLE_ORDERS_PRODUCTS . "

where orders_id = '" . (int)$order_id . "'");

while ($ordered_products = tep_db_fetch_array($products_query)) {

$product = $ordered_products['products_id'];

$qty = $ordered_products['products_quantity'];

$rem_qty_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product . "'");

$rem_qty_array = tep_db_fetch_array($rem_qty_query);

$rem_qty = $rem_qty_array['products_quantity'];

if ($rem_qty == -1) $qty = $qty + 1;

tep_db_query("update " . TABLE_PRODUCTS . "

set products_quantity = products_quantity+'" . $qty . "',

products_status = '" . 1 . "'

where products_id = '" . $product . "'");

}

tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . (int)$order_id . "', '" . '4' . "', now(), '" . ($customer_notified) . "', '" . 'Cancelled by Customer' . "')");

}

break;

}

 

 

 

3) next to the back button add:

 

echo tep_draw_form('order_update', tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $_GET['order_id'] . '&action=cancel_order')); ?>

$statquery = tep_db_query("select orders_status from " . TABLE_ORDERS . "

where orders_id = '" . (int)$_GET['order_id'] . "'");

$status_array = tep_db_fetch_array($statquery);

$order_cancel_ok = array(1);

 

if (in_array($status_array['orders_status'], $order_cancel_ok)) {

echo '<td width="140px" valign="middle" align="center">' . tep_image_submit('button_cancel_order.gif', 'Cancel Order','','update_button') . '</td>';

}

echo '</form>';

Treasurer MFC

Posted
can you please be more explicit?

i`m interested in that but i`m a noob

 

thank you

 

this is the entire code, how more explicit would you require?

 

before :

 

switch ($_GET['action']) {

 

you add:

 

$order_cancel_ok = array(1); // stati which allow cancelling, 1 = pending

 

after :

 

switch ($_GET['action']) {

 

you add:

 

case 'cancel_order':

$order_id = tep_db_prepare_input($_GET['order_id']);

$check_status_query = tep_db_query("select customers_name,

customers_id,

customers_email_address,

orders_status,

date_purchased

from " . TABLE_ORDERS . "

where orders_id = '" . (int)$order_id . "'");

$check_status = tep_db_fetch_array($check_status_query);

if (

($check_status['customers_id'] == $_SESSION['customer_id']) // check if this is his/her order

and (in_array($check_status['orders_status'],$order_cancel_ok)) // is it ok to cancel?

) {

// status 4 = cancelled

tep_db_query("update " . TABLE_ORDERS . "

set orders_status = '" . tep_db_input(4) . "',

last_modified = now()

where orders_id = '" . (int)$order_id . "'");

 

// update stock and status if order is cancelled

$products_query = tep_db_query("select products_id,

products_quantity

from " . TABLE_ORDERS_PRODUCTS . "

where orders_id = '" . (int)$order_id . "'");

while ($ordered_products = tep_db_fetch_array($products_query)) {

$product = $ordered_products['products_id'];

$qty = $ordered_products['products_quantity'];

$rem_qty_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product . "'");

$rem_qty_array = tep_db_fetch_array($rem_qty_query);

$rem_qty = $rem_qty_array['products_quantity'];

if ($rem_qty == -1) $qty = $qty + 1;

tep_db_query("update " . TABLE_PRODUCTS . "

set products_quantity = products_quantity+'" . $qty . "',

products_status = '" . 1 . "'

where products_id = '" . $product . "'");

}

tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . (int)$order_id . "', '" . '4' . "', now(), '" . ($customer_notified) . "', '" . 'Cancelled by Customer' . "')");

}

break;

}

 

after :

 

<td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY, tep_get_all_get_params(array('order_id')), 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>

 

 

you add:

 

<?php

$statquery = tep_db_query("select orders_status from " . TABLE_ORDERS . "

where orders_id = '" . (int)$_GET['order_id'] . "'");

$status_array = tep_db_fetch_array($statquery);

if (in_array($status_array['orders_status'], $order_cancel_ok)) {

echo '<td width="140px" valign="middle" align="center">' . tep_image_submit('button_cancel_order.gif', 'Cancel Order','','update_button') . '</td>';

}

echo '</form>';

?>

Treasurer MFC

Posted
this is the entire code, how more explicit would you require?

 

before :

 

switch ($_GET['action']) {

 

you add:

 

$order_cancel_ok = array(1); // stati which allow cancelling, 1 = pending

 

after :

 

switch ($_GET['action']) {

 

you add:

 

case 'cancel_order':

$order_id = tep_db_prepare_input($_GET['order_id']);

$check_status_query = tep_db_query("select customers_name,

customers_id,

customers_email_address,

orders_status,

date_purchased

from " . TABLE_ORDERS . "

where orders_id = '" . (int)$order_id . "'");

$check_status = tep_db_fetch_array($check_status_query);

if (

($check_status['customers_id'] == $_SESSION['customer_id']) // check if this is his/her order

and (in_array($check_status['orders_status'],$order_cancel_ok)) // is it ok to cancel?

) {

// status 4 = cancelled

tep_db_query("update " . TABLE_ORDERS . "

set orders_status = '" . tep_db_input(4) . "',

last_modified = now()

where orders_id = '" . (int)$order_id . "'");

 

// update stock and status if order is cancelled

$products_query = tep_db_query("select products_id,

products_quantity

from " . TABLE_ORDERS_PRODUCTS . "

where orders_id = '" . (int)$order_id . "'");

while ($ordered_products = tep_db_fetch_array($products_query)) {

$product = $ordered_products['products_id'];

$qty = $ordered_products['products_quantity'];

$rem_qty_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product . "'");

$rem_qty_array = tep_db_fetch_array($rem_qty_query);

$rem_qty = $rem_qty_array['products_quantity'];

if ($rem_qty == -1) $qty = $qty + 1;

tep_db_query("update " . TABLE_PRODUCTS . "

set products_quantity = products_quantity+'" . $qty . "',

products_status = '" . 1 . "'

where products_id = '" . $product . "'");

}

tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . (int)$order_id . "', '" . '4' . "', now(), '" . ($customer_notified) . "', '" . 'Cancelled by Customer' . "')");

}

break;

}

 

after :

 

<td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY, tep_get_all_get_params(array('order_id')), 'SSL') . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>

you add:

 

<?php

echo tep_draw_form('order_update', tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $_GET['order_id'] . '&action=cancel_order'));

$statquery = tep_db_query("select orders_status from " . TABLE_ORDERS . "

where orders_id = '" . (int)$_GET['order_id'] . "'");

$status_array = tep_db_fetch_array($statquery);

if (in_array($status_array['orders_status'], $order_cancel_ok)) {

echo '<td width="140px" valign="middle" align="center">' . tep_image_submit('button_cancel_order.gif', 'Cancel Order','','update_button') . '</td>';

}

echo '</form>';

?>

Treasurer MFC

Posted
I believe the big switch Amanda is refering to is in application_top not order_history_info ?

I wonder why some people have to be narcky? (slang word for getting slightly angry with or sarcastic etc)

The person explained they are new. I'm a little more farmiliar with php and even I was a little confused as to where the code went.

Posted

as I read it it's order_history_info and its clear enough in Amanda's first post. If you need a ready plugin then specify you're looking for a contribution.

Posted
I wonder why some people have to be narcky? (slang word for getting slightly angry with or sarcastic etc)

The person explained they are new. I'm a little more farmiliar with php and even I was a little confused as to where the code went.

 

where? No switches in my /catalog/account_history_info.php. Don't have a order_history_info.php

Thanks

 

Mike

Posted

yes, its account_history_info.php (was incorrect in my post). All the code as I understand goes there. And you create the action case at the beginning of the file after the order validation check; something like

 

  if ( isset($HTTP_POST_VARS['action']) {
switch ($HTTP_POST_VARS['action']) {
 case 'cancel_order':
// switch action code here
  break;
default:
break;
}
 }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...