1. Trang chủ
  2. » Công Nghệ Thông Tin

PHP 5 e-commerce Development- P50 pptx

5 68 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 321,13 KB

Nội dung

Checkout [ 228 ] addTag('address_name', $address['address_name']); $this->registry->getObject('template')->getPage()-> addTag('address_lineone'], $address['address_lineone']); $this->registry->getObject('template')->getPage()-> addTag('address_linetwo'], $address['address_linetwo']); $this->registry->getObject('template')->getPage()-> addTag('address_city'], $address['address_city']); $this->registry->getObject('template')->getPage()-> addTag('address_postcode'], $address['address_postcode']); $this->registry->getObject('template')->getPage()-> addTag('address_country'], $address['address_country'] ); } } } Here's what our "delivery address conrmation" page will look like: Payment method The nal congurable option for the customer is the payment method. We simply need to generate a list of available payment methods, and present them to the customer. private function selectPayment() {// If the customer has set the payment method, we save that and then redirect the customer. if( isset( $_POST['eagle_payment'] ) ) { $method = intval( $_POST['payment_method']); $this->basket->setPaymentMethod( $method ); $this->registry->redirectUser('checkout/confirm/', 'Payment method saved', 'Your preferred payment method has been saved', false ); } This material is copyright and is licensed for the sole use by jackie tracey on 23rd February 2010 953 Quincy Drive, , Brick, , 08724 Chapter 10 [ 229 ] If the customer has not selected a payment method, we show them the list. else { $this->registry->getObject('template')->getPage()-> addTag('pagetitle', 'Select your payment method'); $this->registry->getObject('template')-> buildFromTemplates('header.tpl.php', 'checkout/payment.tpl.php','footer.tpl.php'); $methods_sql = "SELECT name as method_name, ID as method_id FROM payment_methods"; $this->registry->getObject('db')->executeQuery( $methods_sql ); $methods = array(); $selected = $this->basket->getPaymentMethod(); As the customer may have already selected a payment method, and then came back to this page to change it, we need to highlight the currently selected payment method. while( $method = $this->registry->getObject('db')->getRows() ) { if( $method['method_id'] == $id ) { $method['selected'] = "selected='selected'"; } else { $method['selected'] = ''; } $methods[] = $method; } $methodsCache = $this->registry->getObject('db')-> cacheData( $methods ); $this->registry->getObject('template')->getPage()-> addTag( 'payment_methods', array( 'DATA', $$methodsCache ) ); } } So here's what our "payment selection" page looks like this: This material is copyright and is licensed for the sole use by jackie tracey on 23rd February 2010 953 Quincy Drive, , Brick, , 08724 Checkout [ 230 ] Confirmation The nal stage, before payment, is to allow the customer to conrm their order. This involves displaying the order to the customer along with the selected shipping method, payment method, and delivery address. When the customer is happy with the order, we then must: Create a new order Create a new order item entry for each product in the basket Create a new order item attribute association entry for each attribute selected for each product in the basket Delete the contents of the user's basket Send the customer to the payment page Our conrmation page looks like this: Storing orders in the database The functionality we have developed in the course of this chapter, requires a number of new database tables to store orders. We need ve new tables; these are: Orders: To store the orders. Order statuses: To maintain a list of possible order statuses. Order items: To store items associated with each order. Order item attributes: To store item attributes associated with each item within an order. Payment methods: To store a list of payment methods. • • • • • • • • • • This material is copyright and is licensed for the sole use by jackie tracey on 23rd February 2010 953 Quincy Drive, , Brick, , 08724 Chapter 10 [ 231 ] Orders table Our orders table is used to relate all items in an order together, store their cost, status, and other information that is common for all items in the order, such as the delivery address. It is important that we store the cost and shipping cost in this table; one reason for this is that if a product price changes after an order has been processed, our orders won't add up. Field Type Description ID Integer, Primary Key, Auto Increment A unique reference for the order User Integer The ID of the user placing the order IP Varchar The user's IP address for security reasons Timestamp Timestamp The time the order was placed Status Integer Reference to the order status table, indicating the order status, for example awaiting payment, dispatched, and so on Comment Longtext We may wish to add space for the customer to add a note to their order Delivery_comment Longtext Same as above, but for special delivery instructions Shipping_method Integer The method to be used for shipping the order Payment_method Integer The method by which the customer wishes to pay Shipping_address_name Varchar The name of the recipient of the order Shipping_address_lineone Varchar The delivery address Shipping_address_linetwo Varchar The delivery address Shipping_address_city Varchar The delivery address Shipping_address_postcode Varchar The delivery address Shipping_address_country Varchar The delivery address Products_cost Float The total cost of products in the order Shipping_cost Float The total shipping cost for the order Voucher_code Integer A reference to any voucher code used for the order This material is copyright and is licensed for the sole use by jackie tracey on 23rd February 2010 953 Quincy Drive, , Brick, , 08724 Checkout [ 232 ] Order statuses As each order will have a status associated with it, we should maintain a list of these statuses in a separate table. We can also store some additional information so that we can detect if the customer needs to do something for the order to progress, for example to make a payment, or if the store owner needs to do something, like dispatch the order. Field Type Description ID Integer, Primary Key, Auto Increment The unique ID for the statusthe status status Name Varchar The status of the order Awaiting_customer Boolean Indicates if the order needs the customer to perform an action for the order to progress Awaiting_staff Boolean Indicates if the administrator needs to perform an action for the order to progress Completed Boolean Indicates that the order is complete Order items For each item in the order, we need to store details in a separate table. This table should essentially be the same as our basket contents table, except that instead of storing user details, we associate each row with an order. Field Type Description ID Integer, Auto Increment, Primary Key A unique reference for the order item Order_Id Integer The order the product is part of Quantity Integer The number of these products within the order Uploaded_le Varchar Path to a le uploaded as part of the order, if appropriate Custom_text_values Longtext A serialized array of custom text values Standard Boolean If the product was standard, or customized This material is copyright and is licensed for the sole use by jackie tracey on 23rd February 2010 953 Quincy Drive, , Brick, , 08724 . $this->registry->getObject('template')-> buildFromTemplates('header.tpl .php& apos;, 'checkout/payment.tpl .php& apos;,'footer.tpl .php& apos;); $methods_sql = "SELECT name as method_name,. material is copyright and is licensed for the sole use by jackie tracey on 23rd February 2010 953 Quincy Drive, , Brick, , 08724 Chapter 10 [ 229 ] If the customer has not selected a payment. material is copyright and is licensed for the sole use by jackie tracey on 23rd February 2010 953 Quincy Drive, , Brick, , 08724 Checkout [ 230 ] Confirmation The nal stage, before payment,

Ngày đăng: 07/07/2014, 10:20

w