diff --git a/cart.php b/cart.php index 0d2a284..0960ab6 100644 --- a/cart.php +++ b/cart.php @@ -71,4 +71,8 @@ +
+ +
+ diff --git a/shipping.php b/shipping.php new file mode 100644 index 0000000..36272c0 --- /dev/null +++ b/shipping.php @@ -0,0 +1,94 @@ + null !== $_POST['name'] ? htmlspecialchars($_POST['name']) : '', + 'zip' => null !== $_POST['zip'] ? htmlspecialchars($_POST['zip']) : '', + 'prefecture' => null !== $_POST['prefecture'] ? htmlspecialchars($_POST['prefecture']) : '', + 'city' => null !== $_POST['city'] ? htmlspecialchars($_POST['city']) : '', + 'address1' => null !== $_POST['address1'] ? htmlspecialchars($_POST['address1']) : '', + 'address2' => null !== $_POST['address2'] ? htmlspecialchars($_POST['address2']) : '', + 'country' => null !== $_POST['country'] ? htmlspecialchars($_POST['country']) : '', + 'email' => null !== $_POST['email'] ? htmlspecialchars($_POST['email']) : '', + ]; + + if (isset($_POST['topayment'])) { + if (!isset($_POST['name']) || $_POST['name'] == '') $errcheck['name'] = $eigo ? 'Name' : 'お名前'; + if (!isset($_POST['zip']) || $_POST['zip'] == '') $errcheck['zip'] = $eigo ? 'ZIP Code' : '郵便番号'; + if (!isset($_POST['prefecture']) || $_POST['prefecture'] == '') $errcheck['prefecture'] = $eigo ? 'State/Province/Prefecture' : '都道府県'; + if (!isset($_POST['city']) || $_POST['city'] == '') $errcheck['city'] = $eigo ? 'City/Town' : '市区町村'; + if (!isset($_POST['address1']) || $_POST['address1'] == '') $errcheck['address1'] = $eigo ? 'Address 1' : '町名+番地'; + if (!isset($_POST['country']) || $_POST['country'] == '') $errcheck['country'] = $eigo ? 'Country' : '国'; + if (!isset($_POST['email']) || $_POST['email'] == '' || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) $errcheck['email'] = $eigo ? 'Email' : 'メール'; + unset($_POST['topayment']); + + if (count($errcheck) > 0) { + $err = $eigo ? 'Please check the following fields:' : '下記のフィールドをご確認下さい:'; + echo $err .= '
'; + foreach ($errcheck as $e) { + $err .= $e.'
'; + } + } + else { + $step = 2; + } + } + else if (isset($_POST['complete'])) { + dd($_POST); + // TODO + // ・QRコード及びアドレスの表示 + // ・支払いの確認 + // ・支払いIDと配送情報をDBに入って、メールの送信 + // ・管理者は毎日午後5時(日本時間)まで手動で確認すると、翌日午前12時(日本時間)配送予定ってメッセージの表示 + // ・郵便局で配送すると、午後3時(日本時間)までメールで郵便追跡番号を送る + // ・3日間後、配送情報は自動でDBから削除される(crontab) + } + + $total = 0; + $cart = array_filter(explode(',', getcookie('cart'))); + + $sql = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); + if (mysqli_connect_errno()) { + printf("Connect failed: %s\n", mysqli_connect_error()); + exit(); + } + + foreach ($cart as $c) { + if ($stmt = mysqli_prepare($sql, 'SELECT price FROM item WHERE slug = ?')) { + mysqli_stmt_bind_param($stmt, 's', $c); + mysqli_stmt_execute($stmt); + mysqli_stmt_bind_result($stmt, $price); + mysqli_stmt_fetch($stmt); + mysqli_stmt_close($stmt); + + if (!isset($items[$c])) $items[$c] = [ + 'price' => $price, + 'count' => 1 + ]; + else $items[$c]['count']++; + } + } + + mysqli_close($sql); + + if ($err != '') { +?> +
+ diff --git a/shipping/0.php b/shipping/0.php new file mode 100644 index 0000000..9c558e3 --- /dev/null +++ b/shipping/0.php @@ -0,0 +1 @@ +. diff --git a/shipping/1.php b/shipping/1.php new file mode 100644 index 0000000..38804d4 --- /dev/null +++ b/shipping/1.php @@ -0,0 +1,38 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
diff --git a/shipping/2.php b/shipping/2.php new file mode 100644 index 0000000..28a8f96 --- /dev/null +++ b/shipping/2.php @@ -0,0 +1,4 @@ + + <?php echo $address; ?> diff --git a/static/style.css b/static/style.css index af9bfba..a3ac01c 100644 --- a/static/style.css +++ b/static/style.css @@ -169,3 +169,15 @@ a { display: inline-block; } } + +.address-form > tbody > tr > td > input { + width: 220px; +} + +.error { + background-color: #da4453; + margin-top: 40px; + padding: 10px; + z-index: 5000; + border: 4px #ff1212 ridge; +}