Process user reply for order

When the order cannot be delivered because of insufficient stocks, the user receives an e-mail message offering two options: to cancel the order or to wait until resupply. Each of these options is materialized by a page: one that deletes the order - for cancel, and one that updates the order status - for the waiting option.

In what follows, you will create/build these pages in the site root:

Building the 'delete_order' page

The delete_order is called when the user wants to cancel its order and receives, as an URL parameter, the order's associated session ID. Similar to the clear_order page, not only direct order details from the order_ord page are to be deleted, but also the detail records in the order_product_opr table, storing pairs of orders - products. What is not similar to the clear_order page is the fact that the session variable no longer exists.

To build the page, follow the next steps:

  1. Open the delete_order page in Dreamweaver.

  2. Apply the Delete Record Wizard from the MX Kollection tab of the Insert bar. Configure it to use the database connection defined at the beginning of this tutorial (connOrders) and to delete records from the order_ord table. For the record primary key use the sesid_ord column and set it to equal the ordid URL parameter. The ordid parameter is passed from the e-mail message created in the previous section. After delete, the thankyou.htm page will be opened.


     

  3. Close the wizard by clicking the OK button. The delete transaction will be added to the page.

  4. Next apply the Delete Detail Records server behavior to remove the related records from the order_product_opr table. You can access it from the Server Behaviors tab > + >MX Kollection > Form Validation.

  5. The master table and primary key is automatically selected from the delete transaction on page, and all that remains is to select the detail table (order_product_opr) and the detail foreign key (the column storing the order ID - idord_opr).


     

  6. Click OK to add the server behavior on page. Then save and upload the page to the server.

Building the 'acknowledge_order' page

The next page to create is the one handling the status change for the order, when the user decides to keep the order and wait for new products. This page performs a transparent update, changing the status from "Waiting for acknowledgment" - code 2 into "Acknowledged" - code 3.

Similar to the delete_order page, it will receive the session ID associated to the order as an URL parameter. To build the acknowledgment page, follow the next steps:

  1. Open the acknowledge_order page in Dreamweaver.

  2. Apply the Update Record Transaction server behavior on the page. You can access this server behavior from the Server Behaviors > + > MX Kollection > Forms > Advanced. Configure the user interface options as follows:

  3. Now the acknowledgement page is completed. Save it and upload it to the server.

With this, the main front-end has been created. It allows users add products to their orders, clear or complete the order, and even take action if the order cannot be met. What is missing is a way for the user to view its current order, and this will be implemented next.