<?php include 'book_sc_fns.php'; // The shopping cart needs sessions, so start one session_start(); do_html_header("Checkout"); // create short variable names $name = $_POST['name']; $address = $_POST['address']; $city = $_POST['city']; $zip = $_POST['zip']; $country = $_POST['country']; // if filled out if ($_SESSION['cart'] && $name && $address && $city && $zip && $country) { // able to insert into database if (insert_order($_POST) != false) { //display cart, not allowing changes and without pictures display_cart($_SESSION['cart'], false, 0); display_shipping(calculate_shipping_cost()); //get credit card details display_card_form($name); display_button('show_cart.php', 'continue-shopping', 'Continue Shopping'); } else { echo 'Could not store data, please try again.'; display_button('checkout.php', 'back', 'Back'); } } else { echo 'You did not fill in all the fields, please try again.<hr />'; display_button('checkout.php', 'back', 'Back'); } do_html_footer();
unset($_SESSION['cart'][$isbn]); } else { $_SESSION['cart'][$isbn] = $_POST[$isbn]; } // Cập nhật số lượng mới } $_SESSION['total_price'] = calculate_price($_SESSION['cart']); $_SESSION['items'] = calculate_items($_SESSION['cart']); } ?> <?php /*echo "<pre>"; // print_r($_SESSION); echo "</pre>";*/ // Tiếp bài học 19.11.2015 if ($_SESSION['cart']) { display_cart($_SESSION['cart']); } else { echo "<p>Giỏ hàng rỗng</p>"; echo "<hr>"; } $url = "index.php?dk=loaisach"; if ($new) { $detail = get_book_details($new); if ($detail[catid]) { $url = "index.php?dk=show_cart&catid={$detail['catid']}"; } } display_button($url, 'continue-shopping', 'Continue Shopping'); display_button('index.php?dk=checkout', 'go-to-checkout', 'Go-To-Checkout');
function eshop_cart_callback($array) { global $eshopoptions, $blog_id; if (isset($_SESSION['eshopcart' . $blog_id])) { echo display_cart($_SESSION['eshopcart' . $blog_id], false, $eshopoptions['checkout'], 'widget'); } die; }
function eshop_checkout($espost) { $espost = stripslashes_deep($espost); global $blog_id, $eshopoptions, $wpdb; $contineproceed = '1'; //cache eshop_cache(); $echoit = ''; include_once ABSPATH . 'wp-includes/wp-db.php'; include_once WP_PLUGIN_DIR . "/eshop/cart-functions.php"; if (isset($espost['eshop_payment'])) { $_SESSION['eshop_payment' . $blog_id] = preg_replace('/[^a-zA-Z0-9\\-_]/', '', $espost['eshop_payment']); } if (!isset($_SESSION['eshop_payment' . $blog_id])) { $paymentmethod = 'paypal'; } else { $paymentmethod = $_SESSION['eshop_payment' . $blog_id]; } //left over from previous script, leaving in just in case another payment method is used. $chkerror = 0; $numberofproducts = 0; //filter for plugin merchant gateways $eshopmgincpath = apply_filters('eshop_mg_inc_path', WP_PLUGIN_DIR . '/eshop/' . $paymentmethod . '.php', $paymentmethod); // if everything went ok do the following, hopefully the rest won't happen! if (isset($_GET['eshopaction'])) { if ($_GET['eshopaction'] == 'success') { include_once $eshopmgincpath; } } //filter for plugin merchant gateways $eshopmgincidxpath = apply_filters('eshop_mg_inc_idx_path', WP_PLUGIN_DIR . '/eshop/' . $paymentmethod . '/index.php', $paymentmethod); if (file_exists($eshopmgincidxpath)) { include_once $eshopmgincidxpath; } if (isset($_SESSION['eshopcart' . $blog_id])) { $shopcart = $_SESSION['eshopcart' . $blog_id]; $numberofproducts = sizeof($_SESSION['eshopcart' . $blog_id]); /* unused code? $productsandqty=''; while (list ($product, $amount) = each ($_SESSION['eshopcart'.$blog_id])){ $productsandqty.=" $product-$amount"; $productsandqty=trim($productsandqty); } */ $keys = array_keys($_SESSION['eshopcart' . $blog_id]); $productidkeys = implode(",", $keys); $productidkeys = trim($productidkeys); //reqd for shipping - finds the correct state for working out shipping, and set things up for later usage. if (isset($espost['ship_name'])) { if ($espost['ship_name'] != '' || $espost['ship_address'] != '' || $espost['ship_city'] != '' || $espost['ship_postcode'] != '' || $espost['ship_company'] != '' || $espost['ship_phone'] != '' || $espost['ship_country'] != '' || $espost['ship_state'] != '') { if ($espost['ship_name'] == '') { $espost['ship_name'] = $espost['first_name'] . " " . $espost['last_name']; } if ($espost['ship_company'] == '') { $espost['ship_company'] = $espost['company']; } if ($espost['ship_phone'] == '') { $espost['ship_phone'] = $espost['phone']; } if ($espost['ship_address'] == '') { $espost['ship_address'] = $espost['address1']; if ($espost['address2'] != '') { $espost['ship_address'] .= ", " . $espost['address2']; } } if ($espost['ship_city'] == '') { $espost['ship_city'] = $espost['city']; } if ($espost['ship_postcode'] == '') { $espost['ship_postcode'] = $espost['zip']; } if ($espost['ship_country'] == '') { $espost['ship_country'] = $espost['country']; } if ($espost['ship_state'] == '') { $espost['ship_state'] = $espost['state']; } if ($espost['ship_altstate'] == '') { $espost['ship_altstate'] = $espost['altstate']; } } else { $espost['ship_name'] = $espost['first_name'] . " " . $espost['last_name']; $espost['ship_company'] = $espost['company']; $espost['ship_phone'] = $espost['phone']; if ($espost['ship_address'] == '') { $espost['ship_address'] = $espost['address1']; if ($espost['address2'] != '') { $espost['ship_address'] .= ", " . $espost['address2']; } } $espost['ship_city'] = $espost['city']; $espost['ship_postcode'] = $espost['zip']; $espost['ship_country'] = $espost['country']; $espost['ship_state'] = $espost['state']; $espost['ship_altstate'] = $espost['altstate']; } $tablecountries = $wpdb->prefix . 'eshop_countries'; $tablestates = $wpdb->prefix . 'eshop_states'; $shippingzone = $eshopoptions['shipping_zone']; if (isset($espost['eshop_shiptype']) && $espost['eshop_shiptype'] != '0') { $sztype = $espost['eshop_shiptype']; $shippingzone = $wpdb->get_var("SELECT area FROM " . $wpdb->prefix . "eshop_rates WHERE rate_type='ship_weight' && class='{$sztype}' LIMIT 1"); } $pzoneid = ''; //$eshopoptions['unknown_state']; if ($shippingzone == 'country') { if (isset($espost['ship_country']) && $espost['ship_country'] != '') { $pzoneid = $espost['ship_country']; } elseif (isset($espost['country']) && $espost['country'] != '') { $pzoneid = $espost['country']; } $pzone = $wpdb->get_var("SELECT zone FROM {$tablecountries} WHERE code='{$pzoneid}' LIMIT 1"); } else { if (isset($espost['state']) && $espost['state'] != '') { $pzoneid = $espost['state']; } if (isset($espost['ship_state']) && $espost['ship_state'] != '') { $pzoneid = $espost['ship_state']; } $pzone = $wpdb->get_var("SELECT zone FROM {$tablestates} WHERE id='{$pzoneid}' LIMIT 1"); if (isset($espost['altstate']) && $espost['altstate'] != '') { $pzone = $eshopoptions['unknown_state']; } if (isset($espost['ship_altstate']) && $espost['ship_altstate'] != '') { $pzone = $eshopoptions['unknown_state']; } } $_SESSION['shiptocountry' . $blog_id] = $eshopoptions['location']; if (isset($espost['ship_country']) && $espost['ship_country'] != '') { $_SESSION['shiptocountry' . $blog_id] = $espost['ship_country']; } elseif (isset($espost['country']) && $espost['country'] != '') { $_SESSION['shiptocountry' . $blog_id] = $espost['country']; } } else { $pzoneid = ''; //$eshopoptions['unknown_state']; $tablecountries = $wpdb->prefix . 'eshop_countries'; $tablestates = $wpdb->prefix . 'eshop_states'; $shippingzone = $eshopoptions['shipping_zone']; if (isset($espost['eshop_shiptype'])) { $sztype = $espost['eshop_shiptype']; $shippingzone = $wpdb->get_var("SELECT area FROM " . $wpdb->prefix . "eshop_rates WHERE rate_type='ship_weight' && class='{$sztype}' LIMIT 1"); } if ($shippingzone == 'country') { if (isset($espost['ship_country']) && $espost['ship_country'] != '') { $pzoneid = $espost['ship_country']; } elseif (isset($espost['country']) && $espost['country'] != '') { $pzoneid = $espost['country']; } $pzone = $wpdb->get_var("SELECT zone FROM {$tablecountries} WHERE code='{$pzoneid}' LIMIT 1"); } else { if (isset($espost['ship_state']) && $espost['ship_state'] != '') { $pzoneid = $espost['ship_state']; } if (isset($espost['state']) && $espost['state'] != '') { $pzoneid = $espost['state']; } $pzone = $wpdb->get_var("SELECT zone FROM {$tablestates} WHERE id='{$pzoneid}' LIMIT 1"); if (isset($espost['altstate']) && $espost['altstate'] != '') { $pzone = $eshopoptions['unknown_state']; } if (isset($espost['ship_altstate']) && $espost['ship_altstate'] != '') { $pzone = $eshopoptions['unknown_state']; } } } // $shiparray = array(); $eshopcartarray = $_SESSION['eshopcart' . $blog_id]; foreach ($eshopcartarray as $productid => $opt) { if (is_array($opt)) { switch ($eshopoptions['shipping']) { case '1': //( per quantity of 1, prices reduced for additional items ) for ($i = 1; $i <= $opt['qty']; $i++) { array_push($shiparray, $opt["pclas"]); } break; case '2': //( once per shipping class no matter what quantity is ordered ) if (!in_array($opt["pclas"], $shiparray)) { array_push($shiparray, $opt["pclas"]); } break; case '3': //( one overall charge no matter how many are ordered ) if (!in_array($opt["pclas"], $shiparray)) { if ($opt["pclas"] != 'F') { array_push($shiparray, 'A'); } } break; case '4': //( weight ) if (isset($espost['eshop_shiptype'])) { unset($shiparray); $shiparray = $espost['eshop_shiptype']; } break; } } } //need an extra check if ($eshopoptions['shipping'] == '4' && 'no' == $eshopoptions['downloads_only'] && isset($espost['submit']) && !isset($espost['eshop_shiptype']) && !eshop_only_downloads()) { $pzone = ''; } //need to check the discount codes here as well: if (eshop_discount_codes_check()) { $_SESSION['eshop_discount' . $blog_id] = ''; unset($_SESSION['eshop_discount' . $blog_id]); if (isset($espost['eshop_discount']) && $espost['eshop_discount'] != '') { $chkcode = valid_eshop_discount_code($espost['eshop_discount']); if ($chkcode) { $_SESSION['eshop_discount' . $blog_id] = $espost['eshop_discount']; } } } //show the cart if (isset($_GET['eshopaction']) && $_GET['eshopaction'] != 'redirect' || !isset($_GET['eshopaction'])) { $echoit .= display_cart($_SESSION['eshopcart' . $blog_id], false, $eshopoptions['checkout'], $pzone, $shiparray); } } $error = ''; if (isset($espost['submit'])) { //form handling foreach ($espost as $key => $value) { $key = $value; } //setupshipping arrays $reqdvalues = array('shipping', 'first_name', 'last_name', 'email', 'phone', 'address', 'city', 'zip', 'pay'); if ($eshopoptions['shipping'] != '4') { if ($eshopoptions['shipping_zone'] == 'country') { $reqdvalues[] = 'country'; } else { $reqdvalues[] = 'state'; } } else { $creqd = ''; $dtable = $wpdb->prefix . 'eshop_rates'; $query = $wpdb->get_results("SELECT DISTINCT(area) from {$dtable} where rate_type='ship_weight'"); foreach ($query as $k) { $reqdvalues[] = $k->area; } } $linkattr = apply_filters('eShopCheckoutLinksAttr', ''); $reqdarray = apply_filters('eshopCheckoutReqd', $reqdvalues); if ($eshopoptions['shipping'] == '4' && 'no' == $eshopoptions['downloads_only'] && !isset($espost['eshop_shiptype']) && !eshop_only_downloads()) { $error .= '<li>' . __('<strong>Shipping</strong> - not selected.', 'eshop') . '</li>'; } if (isset($espost['first_name'])) { $valid = checkAlpha($espost['first_name']); if ($valid == FALSE && eshop_checkreqd($reqdarray, 'first_name')) { $error .= '<li>' . __('<strong>First name</strong> - missing or incorrect.', 'eshop') . '</li>'; } } if (isset($espost['last_name'])) { $valid = checkAlpha($espost['last_name']); if ($valid == FALSE && eshop_checkreqd($reqdarray, 'last_name')) { $error .= '<li>' . __('<strong>Last name</strong> - missing or incorrect.', 'eshop') . '</li>'; } } if (isset($espost['email'])) { $valid = checkEmail($espost['email']); if ($valid == FALSE && eshop_checkreqd($reqdarray, 'email')) { $error .= '<li>' . __('<strong>Email address</strong> - missing or incorrect.', 'eshop') . '</li>'; } } if (isset($espost['phone'])) { $valid = checkPhone($espost['phone']); if ($valid == FALSE && eshop_checkreqd($reqdarray, 'phone')) { $error .= '<li>' . __('<strong>Phone Number</strong> - missing or incorrect', 'eshop') . '.</li>'; } } if (isset($espost['address1'])) { $valid = checkAlpha($espost['address1']); if ($valid == FALSE && eshop_checkreqd($reqdarray, 'address')) { $error .= '<li>' . __('<strong>Address</strong> - missing or incorrect.', 'eshop') . '</li>'; } } if (isset($espost['city'])) { $valid = checkAlpha($espost['city']); if ($valid == FALSE && eshop_checkreqd($reqdarray, 'city')) { $error .= '<li>' . __('<strong>City or town</strong> - missing or incorrect.', 'eshop') . '</li>'; } } if (eshop_checkreqd($reqdarray, 'state')) { if (isset($espost['state']) && $espost['state'] == '' && $espost['altstate'] == '') { $error .= '<li>' . __('<strong>State/County/Province</strong> - missing or incorrect.', 'eshop') . '</li>'; } } if (eshop_checkreqd($reqdarray, 'country')) { if (isset($espost['country'])) { $valid = checkAlpha($espost['country']); if ($valid == FALSE) { $error .= '<li>' . __('<strong>Country</strong> - missing or incorrect.', 'eshop') . '</li>'; } } } if (isset($espost['country']) && $espost['country'] == 'US' && $espost['state'] == '' && $espost['altstate'] == '') { //must pick a state for US deliveries $error .= '<li>' . __('<strong><abbr title="United States">US</abbr> State</strong> - missing or incorrect.', 'eshop') . '</li>'; } if (isset($espost['zip'])) { $valid = checkAlphaNum($espost['zip']); if ($valid == FALSE && eshop_checkreqd($reqdarray, 'zip')) { $error .= '<li>' . __('<strong>Zip/Post code</strong> - missing or incorrect.', 'eshop') . '</li>'; } } if (isset($espost['reference'])) { if ($espost['reference'] == '' && eshop_checkreqd($reqdarray, 'ref')) { $error .= '<li>' . __('<strong>Reference</strong> - missing.', 'eshop') . '</li>'; } } if (isset($espost['comments'])) { if ($espost['comments'] == '' && eshop_checkreqd($reqdarray, 'comments')) { $error .= '<li>' . __('<strong>Comments</strong> - missing.', 'eshop') . '</li>'; } } if (isset($eshopoptions['users']) && $eshopoptions['users'] == 'yes' && !is_user_logged_in()) { if (!isset($espost['eshop_users']) && eshop_checkreqd($reqdarray, 'signup')) { $error .= '<li>' . __('<strong>Sign Up</strong> - not checked.', 'eshop') . '</li>'; } } //add in error checking for any new values here $temperror = apply_filters('eshoperrorcheckout', $espost); if (!is_array($temperror)) { $error .= $temperror; } //////////////////////////////////////////////// if ('yes' == $eshopoptions['tandc_use']) { if (!isset($espost['eshop_tandc'])) { $error .= '<li><strong>' . $eshopoptions['tandc'] . '</strong>' . __(' - not checked.', 'eshop') . '</li>'; } } if (!isset($espost['eshop_payment'])) { $error .= '<li>' . __('You have not chosen a <strong>payment option</strong>.', 'eshop') . '</li>'; } if (eshop_discount_codes_check()) { $_SESSION['eshop_discount' . $blog_id] = ''; unset($_SESSION['eshop_discount' . $blog_id]); if (isset($espost['eshop_discount']) && $espost['eshop_discount'] != '') { $chkcode = valid_eshop_discount_code($espost['eshop_discount']); if (!$chkcode) { $error .= '<li>' . __('<strong>Discount Code</strong> - is not valid.', 'eshop') . '</li>'; } else { $_SESSION['eshop_discount' . $blog_id] = $espost['eshop_discount']; } } } if (isset($eshopoptions['users']) && $eshopoptions['users'] == 'yes' && isset($espost['eshop_users']) && !is_user_logged_in()) { $_SESSION['eshop_user' . $blog_id] = '1'; } if ($error != '') { $echoit .= "<p><strong class=\"eshoperror error\">" . __('There were some errors in the details you entered…', 'eshop') . "</strong></p><ul class=\"eshoperrors errors\">" . $error . '</ul>'; $first_name = $last_name = $company = $phone = $reference = ''; $email = $address1 = $address2 = $city = $country = ''; $state = $altstate = $zip = $ship_name = $ship_company = ''; $ship_phone = $ship_address = $ship_city = $ship_postcode = ''; $ship_country = $ship_state = $ship_altstate = $comments = ''; if (isset($espost['first_name'])) { $first_name = $espost['first_name']; } if (isset($espost['last_name'])) { $last_name = $espost['last_name']; } if (isset($espost['phone'])) { $phone = $espost['phone']; } if (isset($espost['reference'])) { $reference = $espost['reference']; } if (isset($espost['email'])) { $email = $espost['email']; } if (isset($espost['address1'])) { $address1 = $espost['address1']; } if (isset($espost['address2'])) { $address2 = $espost['address2']; } if (isset($espost['city'])) { $city = $espost['city']; } if (isset($espost['country'])) { $country = $espost['country']; } if (isset($espost['state'])) { $state = $espost['state']; } if (isset($espost['altstate'])) { $altstate = $espost['altstate']; } if (isset($espost['zip'])) { $zip = $espost['zip']; } if (isset($espost['ship_name'])) { $ship_name = $espost['ship_name']; } if (isset($espost['ship_company'])) { $ship_company = $espost['ship_company']; } if (isset($espost['ship_phone'])) { $ship_phone = $espost['ship_phone']; } if (isset($espost['ship_address'])) { $ship_address = $espost['ship_address']; } if (isset($espost['ship_city'])) { $ship_city = $espost['ship_city']; } if (isset($espost['ship_country'])) { $ship_country = $espost['ship_country']; } if (isset($espost['ship_state'])) { $ship_state = $espost['ship_state']; } if (isset($espost['ship_altstate'])) { $ship_altstate = $espost['ship_altstate']; } if (isset($espost['ship_postcode'])) { $ship_postcode = $espost['ship_postcode']; } if (isset($espost['comments'])) { $comments = $espost['comments']; } $chkerror = '1'; } else { if (!isset($_GET['eshopaction'])) { $shipping = 0; $echoit .= "<div class=\"hr\"></div><div class=\"eshopcheckoutconf\"><h3>" . __('<span class="noprint">Please Confirm </span>Your Details', 'eshop') . '</h3>'; // create a custom id, and shove details in database $date = date('YmdHis'); $_SESSION['date' . $blog_id] = $date; $fprice = number_format($_SESSION['final_price' . $blog_id], 2, '.', ''); $espost['amount'] = $fprice; $espost['custom'] = $date; $espost['numberofproducts'] = sizeof($_SESSION['eshopcart' . $blog_id]); //shipping if (isset($_SESSION['shipping' . $blog_id])) { $shipping = eshopShipTaxAmt(); } //discount shipping if (is_shipfree(calculate_total())) { $shipping = 0; } //shipping $espost['shipping_1'] = $shipping; $ctable = $wpdb->prefix . 'eshop_countries'; $stable = $wpdb->prefix . 'eshop_states'; if ('no' == $eshopoptions['downloads_only']) { $echoit .= '<h4>' . __('Mailing Address', 'eshop') . '</h4><ul class="eshop confirm">'; } else { $echoit .= '<h4>' . __('Contact Details', 'eshop') . '</h4><ul class="eshop confirm">'; } $echoit .= "<li><span class=\"items fullname\">" . __('Full name:', 'eshop') . "</span> " . $espost['first_name'] . " " . $espost['last_name'] . "</li>\n"; if ('no' == $eshopoptions['downloads_only']) { $echoit .= "<li class=\"company\"><span class=\"items\">" . __('Company:', 'eshop') . "</span> " . $espost['company'] . "</li>\n"; } $echoit .= "<li class=\"email\"><span class=\"items\">" . __('Email:', 'eshop') . "</span> " . $espost['email'] . "</li>\n"; if ('no' == $eshopoptions['downloads_only']) { $echoit .= "<li class=\"phone\"><span class=\"items\">" . __('Phone:', 'eshop') . "</span> " . $espost['phone'] . "</li>\n"; $echoit .= "<li class=\"address\"><span class=\"items\">" . __('Address:', 'eshop') . "</span> " . $espost['address1'] . " " . $espost['address2'] . "</li>\n"; $echoit .= "<li class=\"city\"><span class=\"items\">" . __('City or town:', 'eshop') . "</span> " . $espost['city'] . "</li>\n"; $qcode = $wpdb->escape($espost['state']); $qstate = $wpdb->get_var("SELECT stateName FROM {$stable} WHERE id='{$qcode}' limit 1"); if ($espost['altstate'] != '') { $echoit .= "<li class=\"state\"><span class=\"items\">" . __('State/County/Province:', 'eshop') . "</span> " . $espost['altstate'] . "</li>\n"; } elseif ($qstate != '') { $echoit .= "<li class=\"state\"><span class=\"items\">" . __('State/County/Province:', 'eshop') . "</span> " . $qstate . "</li>\n"; } $echoit .= "<li class=\"zip\"><span class=\"items\">" . __('Zip/Post code:', 'eshop') . "</span> " . $espost['zip'] . "</li>\n"; $qccode = $wpdb->escape($espost['country']); $qcountry = $wpdb->get_var("SELECT country FROM {$ctable} WHERE code='{$qccode}' limit 1"); $echoit .= "<li class=\"country\"><span class=\"items\">" . __('Country:', 'eshop') . "</span> " . $qcountry . "</li>\n"; } $echoit .= "</ul>\n"; // $temp = apply_filters('eshopconfcheckout', $espost); if (!is_array($temp)) { $echoit .= $temp; } // if (!isset($espost['reference'])) { $espost['reference'] = ''; } if (!isset($espost['comments'])) { $espost['comments'] = ''; } if (trim($espost['reference']) != '' && trim($espost['comments']) == '') { $echoit .= "<div class=\"eshop fld3\"><h4>" . __('Additional information', 'eshop') . "</h4>\n<ul class=\"eshop confirmref\">\n"; $echoit .= '<li><span class="items">' . __('Reference or <abbr title="Purchase Order number">PO</abbr>', 'eshop') . '</span> ' . $espost['reference'] . '</li>' . "\n"; $echoit .= '</ul></div>' . "\n"; } if (trim($espost['reference']) == '' && trim($espost['comments']) != '') { $echoit .= "<div class=\"eshop fld3\"><h4>" . __('Additional information', 'eshop') . "</h4>\n<ul class=\"eshop confirmref\">\n"; $echoit .= '<li><span class="items">' . __('Comments or instructions:', 'eshop') . '</span> ' . $espost['comments'] . '</li>' . "\n"; $echoit .= '</ul></div>' . "\n"; } if (trim($espost['reference']) != '' && trim($espost['comments']) != '') { $echoit .= "<div class=\"eshop fld3\"><h4>" . __('Additional information', 'eshop') . "</h4>\n<ul class=\"eshop confirmref\">\n"; $echoit .= '<li><span class="items">' . __('Reference or PO:', 'eshop') . '</span> ' . $espost['reference'] . '</li>' . "\n"; $echoit .= '<li><span class="items">' . __('Comments or instructions:', 'eshop') . '</span> ' . $espost['comments'] . '</li>' . "\n"; $echoit .= '</ul></div>' . "\n"; } if ('no' == $eshopoptions['downloads_only']) { if ('yes' != $eshopoptions['hide_shipping']) { if ($espost['ship_name'] != '' || $espost['ship_address'] != '' || $espost['ship_city'] != '' || $espost['ship_postcode'] != '') { $echoit .= "<div class=\"eshop fld4\"><h4>" . __('Shipping Address', 'eshop') . "</h4>\n<ul class=\"eshop confirmship\">\n"; $echoit .= "<li><span class=\"items\">" . __('Full name:', 'eshop') . "</span> " . $espost['ship_name'] . "</li>\n"; $echoit .= "<li class=\"ship_company\"><span class=\"items\">" . __('Company:', 'eshop') . "</span> " . $espost['ship_company'] . "</li>\n"; $echoit .= "<li><span class=\"items\">" . __('Phone:', 'eshop') . "</span> " . $espost['ship_phone'] . "</li>\n"; $echoit .= "<li><span class=\"items\">" . __('Address:', 'eshop') . "</span> " . $espost['ship_address'] . "</li>\n"; $echoit .= "<li><span class=\"items\">" . __('City or town:', 'eshop') . "</span> " . $espost['ship_city'] . "</li>\n"; $qcode = $wpdb->escape($espost['ship_state']); $qstate = $wpdb->get_var("SELECT stateName FROM {$stable} WHERE id='{$qcode}' limit 1"); if ($espost['ship_altstate'] != '') { $echoit .= "<li class=\"ship_state\"><span class=\"items\">" . __('State/County/Province:', 'eshop') . "</span> " . $espost['ship_altstate'] . "</li>\n"; } elseif ($qstate != '') { $echoit .= "<li class=\"ship_state\"><span class=\"items\">" . __('State/County/Province:', 'eshop') . "</span> " . $qstate . "</li>\n"; } $echoit .= "<li><span class=\"items\">" . __('Zip/Post code:', 'eshop') . "</span> " . $espost['ship_postcode'] . "</li>\n"; $qccode = $wpdb->escape($espost['ship_country']); $qcountry = $wpdb->get_var("SELECT country FROM {$ctable} WHERE code='{$qccode}' limit 1"); $echoit .= "<li class=\"shipcountry\"><span class=\"items\">" . __('Country:', 'eshop') . "</span> " . $qcountry . "</li>\n"; $echoit .= "</ul></div>\n"; } } } $echoit .= "\n"; $echoit .= "</div>\n"; } //add to a session to store address: $_SESSION['addy' . $blog_id]['first_name'] = $espost['first_name']; $_SESSION['addy' . $blog_id]['last_name'] = $espost['last_name']; $_SESSION['addy' . $blog_id]['email'] = $espost['email']; if (isset($espost['company'])) { $_SESSION['addy' . $blog_id]['company'] = $espost['company']; } else { $_SESSION['addy' . $blog_id]['company'] = ''; } if (isset($espost['phone'])) { $_SESSION['addy' . $blog_id]['phone'] = $espost['phone']; } else { $_SESSION['addy' . $blog_id]['phone'] = ''; } if (isset($espost['reference'])) { $_SESSION['addy' . $blog_id]['reference'] = $espost['reference']; } else { $_SESSION['addy' . $blog_id]['reference'] = ''; } if (isset($espost['address1'])) { $_SESSION['addy' . $blog_id]['address1'] = $espost['address1']; } else { $_SESSION['addy' . $blog_id]['address1'] = ''; } if (isset($espost['address2'])) { $_SESSION['addy' . $blog_id]['address2'] = $espost['address2']; } else { $_SESSION['addy' . $blog_id]['address2'] = ''; } if (isset($espost['city'])) { $_SESSION['addy' . $blog_id]['city'] = $espost['city']; } if (isset($espost['country'])) { $_SESSION['addy' . $blog_id]['country'] = $espost['country']; } else { $_SESSION['addy' . $blog_id]['country'] = ''; } if (isset($espost['state'])) { $_SESSION['addy' . $blog_id]['state'] = $espost['state']; } else { $_SESSION['addy' . $blog_id]['state'] = ''; } if (isset($espost['altstate']) && $espost['altstate'] != '') { $_SESSION['addy' . $blog_id]['state'] = $espost['altstate']; } if (isset($espost['zip'])) { $_SESSION['addy' . $blog_id]['zip'] = $espost['zip']; } else { $_SESSION['addy' . $blog_id]['zip'] = ''; } if (isset($espost['ship_name'])) { $_SESSION['addy' . $blog_id]['ship_name'] = $espost['ship_name']; $_SESSION['addy' . $blog_id]['ship_company'] = $espost['ship_company']; $_SESSION['addy' . $blog_id]['ship_phone'] = $espost['ship_phone']; $_SESSION['addy' . $blog_id]['ship_address'] = $espost['ship_address']; $_SESSION['addy' . $blog_id]['ship_city'] = $espost['ship_city']; $_SESSION['addy' . $blog_id]['ship_country'] = $espost['ship_country']; $_SESSION['addy' . $blog_id]['ship_state'] = $espost['ship_state']; if (isset($espost['ship_altstate']) && $espost['ship_altstate'] != '') { $_SESSION['addy' . $blog_id]['ship_state'] = $espost['ship_altstate']; } $_SESSION['addy' . $blog_id]['ship_postcode'] = $espost['ship_postcode']; } if (isset($espost['comments'])) { $_SESSION['addy' . $blog_id]['comments'] = $espost['comments']; } else { $_SESSION['addy' . $blog_id]['comments'] = ''; } if (!isset($_SESSION['shipping' . $blog_id])) { $_SESSION['shipping' . $blog_id]['cost'] = $shipping; } //grab all the POST variables and store in cookie $array = $espost; //but first make a few extra equal nothing //add others in here if needed $array['comments'] = $array['reference'] = ''; $eshopsetcookie = apply_filters('eshop_use_cookie', true); if ($eshopsetcookie == true) { $biscuits = eshop_build_cookie($array); setcookie("eshopcart", $biscuits, time() + 60 * 60 * 24 * 365); } $eshopmgincpath = apply_filters('eshop_mg_inc_path', WP_PLUGIN_DIR . '/eshop/' . $paymentmethod . '.php', $paymentmethod); include_once $eshopmgincpath; $contineproceed = '3'; } } else { //for first time form usage. if (isset($_SESSION['addy' . $blog_id])) { $first_name = $_SESSION['addy' . $blog_id]['first_name']; $last_name = $_SESSION['addy' . $blog_id]['last_name']; $company = $_SESSION['addy' . $blog_id]['company']; $phone = $_SESSION['addy' . $blog_id]['phone']; $reference = $_SESSION['addy' . $blog_id]['reference']; $email = $_SESSION['addy' . $blog_id]['email']; $address1 = $_SESSION['addy' . $blog_id]['address1']; $address2 = $_SESSION['addy' . $blog_id]['address2']; $city = ''; if (isset($_SESSION['addy' . $blog_id]['city'])) { $city = $_SESSION['addy' . $blog_id]['city']; } $country = $_SESSION['addy' . $blog_id]['country']; $state = $_SESSION['addy' . $blog_id]['state']; if (!is_numeric($state)) { $li = $wpdb->escape($state); $table = $wpdb->prefix . 'eshop_states'; $stateList = $wpdb->get_var("SELECT id FROM {$table} WHERE code='{$li}' limit 1"); $state = $stateList; } if (isset($_SESSION['addy' . $blog_id]['altstate'])) { $altstate = $_SESSION['addy' . $blog_id]['altstate']; } else { $altstate = ''; } $zip = $_SESSION['addy' . $blog_id]['zip']; /* defaults */ $ship_name = $ship_company = ''; $ship_phone = $ship_address = $ship_city = $ship_postcode = ''; $ship_country = $ship_state = $ship_altstate = $comments = ''; if (isset($_SESSION['addy' . $blog_id]['ship_name'])) { $ship_name = $_SESSION['addy' . $blog_id]['ship_name']; } if (isset($_SESSION['addy' . $blog_id]['ship_company'])) { $ship_company = $_SESSION['addy' . $blog_id]['ship_company']; } if (isset($_SESSION['addy' . $blog_id]['ship_phone'])) { $ship_phone = $_SESSION['addy' . $blog_id]['ship_phone']; } if (isset($_SESSION['addy' . $blog_id]['ship_address'])) { $ship_address = $_SESSION['addy' . $blog_id]['ship_address']; } if (isset($_SESSION['addy' . $blog_id]['ship_city'])) { $ship_city = $_SESSION['addy' . $blog_id]['ship_city']; } if (isset($_SESSION['addy' . $blog_id]['ship_country'])) { $ship_country = $_SESSION['addy' . $blog_id]['ship_country']; } if (isset($_SESSION['addy' . $blog_id]['ship_state'])) { $ship_state = $_SESSION['addy' . $blog_id]['ship_state']; if (!is_numeric($ship_state)) { $li = $wpdb->escape($ship_state); $table = $wpdb->prefix . 'eshop_states'; $stateSList = $wpdb->get_var("SELECT id FROM {$table} WHERE code='{$li}' limit 1"); $ship_state = $stateSList; } } if (isset($_SESSION['addy' . $blog_id]['ship_altstate'])) { $ship_altstate = $_SESSION['addy' . $blog_id]['ship_altstate']; } else { $ship_altstate = ''; } if (isset($_SESSION['addy' . $blog_id]['ship_postcode'])) { $ship_postcode = $_SESSION['addy' . $blog_id]['ship_postcode']; } if (isset($_SESSION['addy' . $blog_id]['comments'])) { $comments = $_SESSION['addy' . $blog_id]['comments']; } } else { $first_name = $last_name = $company = $phone = $reference = ''; $email = $address1 = $address2 = $city = $country = ''; $state = $altstate = $zip = $ship_name = $ship_company = ''; $ship_phone = $ship_address = $ship_city = $ship_postcode = ''; $ship_country = $ship_state = $ship_altstate = $comments = ''; $eshopsetcookie = apply_filters('eshop_use_cookie', true); if (isset($_COOKIE["eshopcart"]) && calculate_items() != 0 && $eshopsetcookie == true) { $crumbs = eshop_break_cookie($_COOKIE["eshopcart"]); foreach ($crumbs as $k => $v) { ${$k} = $v; } } if (is_user_logged_in() && isset($eshopoptions['users']) && 'yes' == $eshopoptions['users']) { global $current_user; get_currentuserinfo(); $crumbs = stripslashes_deep(get_the_author_meta('eshop', $current_user->ID)); if (is_array($crumbs)) { foreach ($crumbs as $k => $v) { ${$k} = esc_attr($v); } $first_name = esc_attr($current_user->user_firstname); $last_name = esc_attr($current_user->user_lastname); $email = esc_attr($current_user->user_email); } } } } if ($chkerror != 0 || !isset($espost['submit']) && $numberofproducts >= 1) { // only show form if not filled in. $echoit .= eshopShowform($first_name, $last_name, $company, $phone, $email, $address1, $address2, $city, $state, $altstate, $zip, $country, $reference, $comments, $ship_name, $ship_company, $ship_phone, $ship_address, $ship_city, $ship_postcode, $ship_state, $ship_altstate, $ship_country); } if (isset($_SESSION['eshopcart' . $blog_id])) { switch ($contineproceed) { case '1': $echoit .= '<ul class="continue-proceed eshopcp1"><li class="editcart"><a href="' . get_permalink($eshopoptions['cart']) . '">' . __('« Edit Cart or Continue Shopping', 'eshop') . '</a></li></ul>'; break; case '2': $echoit .= '<ul class="continue-proceed redirect eshopcp2"><li class="editcheckout"><a href="' . get_permalink($eshopoptions['checkout']) . '">' . __('« Edit Details or Continue Shopping', 'eshop') . '</a></li></ul>'; break; case '3': $echoit .= '<ul class="continue-proceed redirect eshopcp3"><li class="editcheckout"><a href="' . get_permalink($eshopoptions['checkout']) . '">' . __('« Edit Details or Continue Shopping', 'eshop') . '</a></li></ul>'; break; } } else { $echoit .= "<p><strong class=\"eshoperror error\">" . __('Your shopping cart is currently empty.', 'eshop') . "</strong></p>"; } return $echoit; }
<?php include 'book_sc_fns.php'; // The shopping cart needs sessions, so start one session_start(); do_html_header('Checkout'); $card_type = $HTTP_POST_VARS['card_type']; $card_number = $HTTP_POST_VARS['card_number']; $card_month = $HTTP_POST_VARS['card_month']; $card_year = $HTTP_POST_VARS['card_year']; $card_name = $HTTP_POST_VARS['card_name']; if ($HTTP_SESSION_VARS['cart'] && $card_type && $card_number && $card_month && $card_year && $card_name) { //display cart, not allowing changes and without pictures display_cart($HTTP_SESSION_VARS['cart'], false, 0); display_shipping(calculate_shipping_cost()); if (process_card($HTTP_POST_VARS)) { //empty shopping cart session_destroy(); echo 'Thankyou for shopping with us. Your order has been placed.'; display_button('index.php', 'continue-shopping', 'Continue Shopping'); } else { echo 'Could not process your card. '; echo 'Please contact the card issuer or try again.'; display_button('purchase.php', 'back', 'Back'); } } else { echo 'You did not fill in all the fields, please try again.<hr />'; display_button('purchase.php', 'back', 'Back'); } do_html_footer();
*/ include_once "display_cart.php"; include_once "table.php"; include_once "Catalog/catalog.php"; include_once "customer.php"; session_start(); ?> <html> <head> <title>Cart</title> </head> <body> <p> <?php if (isset($_SESSION['cart'])) { // pick up the old cart if there is one, else get a new one $cart = $_SESSION['cart']; echo "<b>Your cart:</b><br/><br/>"; display_cart($cart); display_customer_form(); } else { echo "Cart not found </br>"; } ?> <p> <a href="welcome.php">Home</a> </body> </html>
$_SESSION['items'] = 0; $_SESSION['total_price'] = 0.0; } if (isset($_SESSION['cart'][$new])) { $_SESSION['cart'][$new]++; } else { $_SESSION['cart'][$new] = 1; } $_SESSION['total_price'] = calculate_price($_SESSION['cart']); $_SESSION['items'] = calculate_items($_SESSION['cart']); } if ($_POST['submit']) { foreach ($_SESSION['cart'] as $isbn => $qty) { if ($_POST[$isbn] == '0') { unset($_SESSION['cart'][$isbn]); } else { $_SESSION['cart'][$isbn] = $_POST[$isbn]; } } $_SESSION['total_price'] = calculate_price($_SESSION['cart']); $_SESSION['items'] = calculate_items($_SESSION['cart']); } do_html_header("购物车"); do_html_top(); if ($_SESSION['cart'] && array_count_values($_SESSION['cart'])) { display_cart($_SESSION['cart'], true); display_button('checkout.php', '结算'); } else { echo "还没有商品添加到购物车"; } do_html_footer();
function widget($args, $instance) { extract($args); global $blog_id, $eshopoptions; $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $show = apply_filters('widget_text', $instance['show'], $instance); $showwhat = apply_filters('widget_text', $instance['showwhat'], $instance); $text = apply_filters('widget_text', $instance['text'], $instance); $items = apply_filters('widget_text', $instance['items'], $instance); $qty = apply_filters('widget_text', $instance['qty'], $instance); $total = apply_filters('widget_text', $instance['total'], $instance); //$fc=apply_filters( 'widget_text', $instance['fc'], $instance ); //$fcimg=apply_filters( 'widget_text', $instance['fcimg'], $instance ); $currsymbol = $eshopoptions['currency_symbol']; if (isset($_SESSION['eshopcart' . $blog_id])) { $eshopsize = 0; $eshopqty = 0; $thetotal = 0; if (isset($_SESSION['eshopcart' . $blog_id])) { $eshopsize = sizeof($_SESSION['eshopcart' . $blog_id]); foreach ($_SESSION['eshopcart' . $blog_id] as $eshopdo => $eshopwop) { $eshopqty += $eshopwop['qty']; } if (isset($_SESSION['final_price' . $blog_id])) { $thetotal = $_SESSION['final_price' . $blog_id]; } $eshoptotal = sprintf(__('%1$s%2$s', 'eshop'), $currsymbol, number_format_i18n($_SESSION['final_price' . $blog_id], __('2', 'eshop'))); if ($showwhat == 'full') { $eecho = '<div class="eshopcartwidget"><div class="ajaxcart">' . display_cart($_SESSION['eshopcart' . $blog_id], false, $eshopoptions['checkout'], 'widget') . ''; $eecho .= '</div></div>'; } else { $any = 0; $eecho = '<p class="eshopwidget">'; if (isset($items) & $items == '1') { $eecho .= sprintf(_n('<span>%d</span> product in cart.', '<span>%d</span> products in cart.', $eshopsize, 'eshop'), $eshopsize); $any++; } if (isset($qty) & $qty == '1') { if ($any > 0) { $eecho .= '<br />'; } $eecho .= sprintf(_n('<span>%d</span> item in cart.', '<span>%d</span> items in cart.', $eshopqty, 'eshop'), $eshopqty); $any++; } if (isset($total) & $total == '1') { if ($any > 0) { $eecho .= '<br />'; } $eecho .= sprintf(__('<span>%s</span> cart total.', 'eshop'), $eshoptotal); } $eecho .= '<br /><a class="cartlink" href="' . get_permalink($eshopoptions['cart']) . '">' . __('View Cart', 'eshop') . '</a>'; $eecho .= '<br /><a class="checkoutlink" href="' . get_permalink($eshopoptions['checkout']) . '">' . __('Checkout', 'eshop') . '</a>'; $eecho .= '</p>'; } echo $before_widget; echo $before_title . $title . $after_title; echo $eecho; echo $after_widget; } } elseif ($show != 'no') { $eecho = ''; if ($showwhat == 'full') { $eecho .= '<div class="ajaxcart">'; } $eecho .= '<div class="eshopcartwidget"><p>' . $text . '</p><p><a class="cartlink" href="' . get_permalink($eshopoptions['cart']) . '">' . __('View Cart', 'eshop') . '</a>'; $eecho .= '<br /><a class="checkoutlink" href="' . get_permalink($eshopoptions['checkout']) . '">' . __('Checkout', 'eshop') . '</a></p></div>'; if ($showwhat == 'full') { $eecho .= '</div>'; } echo $before_widget; echo $before_title . $title . $after_title; echo $eecho; echo $after_widget; } else { if ($showwhat == 'full') { echo $before_widget; //echo $before_title.$title.$after_title; echo '<div class="eshopcartwidget"><div class="ajaxcart"></div></div>'; echo $after_widget; } } }
function eshop_show_cart() { global $wpdb, $blog_id, $wp_query, $eshopoptions; $echo = ''; include "cart-functions.php"; //cache eshop_cache(); if (isset($_SESSION['eshopcart' . $blog_id]['error'])) { $echo .= $_SESSION['eshopcart' . $blog_id]['error']; unset($_SESSION['eshopcart' . $blog_id]['error']); } if (isset($_SESSION['eshopcart' . $blog_id]['enote'])) { $echo .= $_SESSION['eshopcart' . $blog_id]['enote']; unset($_SESSION['eshopcart' . $blog_id]['enote']); } if (isset($_SESSION['eshopcart' . $blog_id])) { if (isset($wp_query->query_vars['eshopaction']) && urldecode($wp_query->query_vars['eshopaction']) == 'cancel' && !isset($_POST['save'])) { $echo .= "<h3>" . __('The order was cancelled.', 'eshop') . "</h3>"; $echo .= '<p>' . __('We have not deleted the contents of your shopping cart in case you may want to edit its content.', 'eshop') . '</p>'; } if ($eshopoptions['shop_page'] != '') { $return = get_permalink($eshopoptions['shop_page']); } elseif (isset($_SESSION['lastproduct' . $blog_id])) { $return = get_permalink($_SESSION['lastproduct' . $blog_id]); } else { $return = get_permalink($eshopoptions['cart']); } $echo .= display_cart($_SESSION['eshopcart' . $blog_id], 'true', $eshopoptions['checkout']); $echo .= '<ul class="continue-proceed eshopcp0"><li class="rtnshopping"><a href="' . $return . '">' . __('« Continue Shopping', 'eshop') . '</a></li> <li class="gotocheckout"><a href="' . get_permalink($eshopoptions['checkout']) . '">' . __('Proceed to Checkout »', 'eshop') . '</a></li></ul>'; } else { //can be altered as desired. $echo .= '<p><strong class="eshoperror error">' . __('Your shopping cart is currently empty.', 'eshop') . '</strong></p>'; } return $echo; }
$order_id = $_POST['orderid']; ?> <html> <title> Status for order: <?php $order_id; ?> </title> <body> <?php $order_processing = SCA::getService("../OrderProcessingService/OrderProcessingService.php"); try { $order = $order_processing->getOrder($order_id); } catch (WarehouseOrderNotFoundException $e) { echo "<b>No order with order id {$order_id} was found</b><br/><br/>"; echo '<p><a href="welcome.php">Home</a></p>'; exit; } echo "<b>Order details: {$order_id}</b><br/><br/>"; display_cart($order); echo "<b>Status:</b><br/><br/>"; $event_log = SCA::getService('../EventLogService/EventLogService.php'); $events = $event_log->getEvents($order_id); display_events($events); ?> <p><a href="welcome.php">Home</a></p> </body> </html>
<meta http-equiv="Content-Type" content="text/html; charset= utf-8" /> <title>Shopping Cart</title> <link rel="icon" type="image" href="images/cart.png" /> </head> <body> <header id="heading"> <!--img id="logo" src="images/1.png" height="65" width="140" /> <h1>TheProgrammingNerd1</h1--> </header> <div id="main_div"> <h3>Shopping Cart</h3> <div id="division"> <section id="main_section"> <?php display_cart(); ?> </section> <aside id="side"> <span class="your_cart">Your Cart</span> <br> <?php product(); ?> </aside> </div> </div> </header>