Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

customer cancel an order


desa80

Recommended Posts

Posted

Hello!

I searched for a contribution "cancel order" but i didn't find. Is there anyway that i can put a CANCEL order link in customers "my account page"?

Posted
Hello!

I searched for a contribution "cancel order" but i didn't find. Is there anyway that i can put a CANCEL order link in customers "my account page"?

 

 

in account_history_info.php :

 

just after this (the back button stuff) :

 

<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 this (add a cancel order button only if the status is right):

 

<?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);

 

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

 

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') . tep_draw_hidden_field('oID', $HTTP_GET_VARS['order_id']) . '</td>';

}

?>

 

 

in application_top.php :

 

just after (basically any of the case statements):

 

case 'buy_now' : if (isset($_GET['products_id'])) {

if (tep_has_product_attributes($_GET['products_id'])) {

tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['products_id']));

} else {

$cart->add_cart($_GET['products_id'], $cart->get_quantity($_GET['products_id'])+1);

}

}

tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

break;

 

 

You add :

 

//**********************

 

case 'cancel_order':

$oID = tep_db_prepare_input($_POST['oID']);

$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)$oID . "'");

 

$check_status = tep_db_fetch_array($check_status_query);

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

 

if (

($check_status['customers_id'] == $_SESSION['customer_id']) // just to be sure

and (in_array($check_status['orders_status'], $order_cancel_ok))

) {

tep_db_query("update " . TABLE_ORDERS . "

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

last_modified = now()

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

 

// 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)$oID . "'");

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

$product = $ordered_products['products_id'];

$qty = $ordered_products['products_quantity'];

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)$oID . "', '" . '4' . "', now(), '" . ($customer_notified) . "', '" . 'Cancelled by Customer' . "')");

 

}

break;

 

//**********************

 

 

you could add a confirmation cycle but for now I have not done so.

Treasurer MFC

Posted

Thanks!

I tried but the cancel order button is not url active, i mean- when i click it nothing happens there is no open link and open in new window when i click right mouse.

May be something is missed?

 

in account_history_info.php :

 

just after this (the back button stuff) :

 

<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 this (add a cancel order button only if the status is right):

 

<?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);

 

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

 

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') . tep_draw_hidden_field('oID', $HTTP_GET_VARS['order_id']) . '</td>';

}

?>

  • 1 year later...
  • 1 year later...
Posted
Did you ever get this to work???

Hi

 

I tried this today and got the same url not active problem, nothing happens when you pick on the button.

 

Can someone look over the code and give us a hint as where to look.

 

Cheers

 

Ian

Posted
Hi

 

I tried this today and got the same url not active problem, nothing happens when you pick on the button.

 

Can someone look over the code and give us a hint as where to look.

 

Cheers

 

Ian

 

Hi

 

Still need an answer on this and I still can't get it to work. I managed to find this contrib. I have tested it and the cancel part seems to work. Need to do more testing tho. There is another option for the customer to edit the order which adds the items in the order back into the cart but this bit doesn't work for me. Maybe some kind person can look at it for me.

 

Cheers

 

Ian

Posted
Hi

 

Still need an answer on this and I still can't get it to work. I managed to find this contrib. I have tested it and the cancel part seems to work. Need to do more testing tho. There is another option for the customer to edit the order which adds the items in the order back into the cart but this bit doesn't work for me. Maybe some kind person can look at it for me.

 

Cheers

 

Ian

Well, me to the rescue again. I am just so gooood. :thumbsup: How do I do it?? I'm not even a programmer. I'll give myself 12 gold, no, platinum stars for effort.

 

I've been playing with the contrib and got it all working customer side. AND I fixed a few, what I saw as bugs in the contrib. I have modified my shopping cart class and php files and there was a bug which stopped the items being added back in to the cart. Replaced with original file, changed the bit I wanted and works now.

 

The restore back into shopping cart still doesn't work admin side but I'm working on it.

 

See ya in another 2-3 days

 

Ian

Archived

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

×
×
  • Create New...