Commit f8f6fd8d by Pham Huy

update form đăng ký

parent be640cd4
......@@ -328,11 +328,6 @@ p.title-item-sidebar {
right: 2%;
}
.bg-light-green{
background: #56BC86;
border-color: #56BC86;
}
.woocommerce form[name="checkout"] .loading{
position: absolute;
left: calc(50% - 100px);
......
......@@ -746,4 +746,9 @@ figure {
right: 125%;
visibility: visible;
}
}
.bg-light-green{
background: #56BC86 !important;
border-color: #56BC86 !important;
}
\ No newline at end of file
......@@ -1016,7 +1016,7 @@ function mst_checkout_field($checkout) {
add_action('woocommerce_checkout_update_order_meta', 'custom_checkout_field_update_order_meta');
function custom_checkout_field_update_order_meta($order_id) {
if (!empty($_POST['mst_checkout_field'])) {
add_post_meta( $order_id, __('Mã số thuế'), sanitize_text_field( $_POST ['mst_checkout_field'] ) );
add_post_meta( $order_id, 'taxcode', sanitize_text_field( $_POST ['mst_checkout_field'] ) );
// update_post_meta($order_id, __('Mã số thuế'),sanitize_text_field($_POST['mst_checkout_field']));
}
}
......@@ -1033,16 +1033,6 @@ function custom_override_checkout_fields( $fields ) {
return $fields;
}
/**
* Add the fields to order email
*/
add_filter( 'woocommerce_email_order_meta_keys', 'custom_checkout_field_order_meta_keys' );
function custom_checkout_field_order_meta_keys( $keys ) {
echo '<h4>Mã số thuế:</h4>';
$keys['Taxcode'] = 'mst_checkout_field';
return $keys;
}
// add_filter( 'woocommerce_add_to_cart_validation', 'wc_limit_one_per_order', 10, 2 );
// function wc_limit_one_per_order( $passed_validation) {
// if ( WC()->cart->get_cart_contents_count() >= 1 ) {
......@@ -1163,4 +1153,45 @@ function customize_override_checkout_field($field) {
$field['billing']['billing_first_name']['label'] = 'Người liên hệ';
$field['billing']['billing_first_name']['class'] = array('form-row-wide');
return $field;
}
}
add_action('woocommerce_after_order_notes', 'customercode_checkout_field');
function customercode_checkout_field($checkout) {
echo '<div id="customercode_checkout_field">';
woocommerce_form_field('customercode_checkout_field', array(
'type' => 'text',
'required' => true,
'class' => array(
'mst-field form-row-wide'
) ,
'label' => __('Mã khách hàng') ,
'placeholder' => __('Nhập mã khách hàng') ,
) ,
$checkout->get_value('customercode_checkout_field'));
echo '</div>';
}
add_action('woocommerce_checkout_update_order_meta', 'customercode_field_update_order_meta');
function customercode_field_update_order_meta($order_id) {
if (!empty($_POST['customercode_checkout_field'])) {
add_post_meta( $order_id, 'customer_code', sanitize_text_field( $_POST ['mst_checkout_field'] ) );
// update_post_meta($order_id, __('Mã số thuế'),sanitize_text_field($_POST['mst_checkout_field']));
}
}
/**
* Add the fields to order email
*/
add_filter( 'woocommerce_email_order_meta_fields', 'custom_woocommerce_email_order_meta_fields');
function custom_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order ) {
$fields['customer_code'] = array(
'label' => __( 'Mã khách hàng' ),
'value' => get_post_meta( $order->id, 'customer_code', true ),
);
$fields['taxcode'] = array(
'label' => __( 'Mã số thuế' ),
'value' => get_post_meta( $order->id, 'taxcode', true ),
);
return $fields;
}
......@@ -17,15 +17,16 @@ get_header();
<h2 class="prices-title">BẢNG GIÁ GÓI HÓA ĐƠN ĐIỆN TỬ- A HÓA ĐƠN</h2>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="table-responsive">
<table class="table table-striped" id="package-invoice">
<thead>
<tr>
<th scope="col" width="7%" class="text-center">STT</th>
<th scope="col" width="30%" class="text-center">Gói hóa đơn</th>
<th scope="col" width="13%" class="text-center">Trị giá</th>
<th scope="col" width="10%" class="text-center">Phí khởi tạo</th>
<th scope="col" width="13%" class="text-center">Thành tiền (VNĐ)</th>
<th scope="col" width="12%" class="text-center"></th>
<th scope="col" width="60px" class="text-center">STT</th>
<th scope="col" width="200px"class="text-center">Gói hóa đơn</th>
<th scope="col" width="100px" class="text-center">Trị giá</th>
<th scope="col" width="120px" class="text-center">Phí khởi tạo</th>
<th scope="col" width="120px" class="text-center">Thành tiền (VNĐ)</th>
<th scope="col" width="150px" class="text-center"></th>
</tr>
</thead>
......@@ -108,6 +109,7 @@ get_header();
</tbody>
<?php endif; ?>
</table>
</div>
</div>
<?php //echo do_shortcode('[products limit="12" columns="3" ]') ?>
</div>
......@@ -123,17 +125,18 @@ get_header();
<h2 class="prices-title">BẢNG GIÁ GÓI CHỮ KÝ SỐ</h2>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="table-responsive">
<table class="table table-striped" id="digitalKey">
<thead>
<tr>
<!-- <th scope="col" width="7%" class="text-center">STT</th> -->
<th scope="col" width="30%" class="text-center">Gói Chữ ký số</th>
<th scope="col" width="13%" class="text-center">Giá dịch vụ</th>
<th scope="col" width="10%" class="text-center">Token</th>
<th scope="col" width="13%" class="text-center">Giá trước thuế</th>
<th scope="col" width="13%" class="text-center">VAT (10%)</th>
<th scope="col" width="13%" class="text-center">Thành tiền (VNĐ)</th>
<th scope="col" width="12%" class="text-center"></th>
<th scope="col" width="200px" class="text-center">Gói Chữ ký số</th>
<th scope="col" width="130px" class="text-center">Giá dịch vụ</th>
<th scope="col" width="100px" class="text-center">Token</th>
<th scope="col" width="150px" class="text-center">Giá trước thuế</th>
<th scope="col" width="100px" class="text-center">VAT (10%)</th>
<th scope="col" width="150px" class="text-center">Thành tiền (VNĐ)</th>
<th scope="col" width="150px" class="text-center"></th>
</tr>
</thead>
......@@ -232,6 +235,7 @@ get_header();
</tbody>
<?php endif; ?>
</table>
</div>
</div>
<?php //echo do_shortcode('[products limit="12" columns="3" ]') ?>
</div>
......
<?php
/**
* Template Name: Đăng ký sử dụng
*
* @package WordPress
* @subpackage Twenty_Sixteen
* @since Twenty Sixteen 2.1
*/
//response generation function
$cities = array( "Tiền Giang", "Hưng Yên", "Hà Nội", "TP Hồ Chí Minh","Cà Mau", "Đắc Lắc", "Nam Định", "Quảng Ninh", "Đắk Nông", "Đà Nẵng", "Hải Dương", "Long An", "Bến Tre", "Đồng Tháp", "Vĩnh Long", "Kiên Giang", "Trà Vinh", "Sóc Trăng", "Bắc Ninh", "Thanh Hoá", "Vũng Tàu", "Đồng Nai", "Bình Dương", "Thái Nguyên", "Thái Bình", "Cần Thơ", "Nghệ An", "Huế", "Bình Phước", "Quảng Nam", "Quảng Ngãi", "Ninh Thuận", "Lào Cai", "Hải Phòng", "An Giang", "Phú Thọ", "Tây Ninh", "Khánh Hòa", "Phú Yên", "Hòa Bình", "Tuyên Quang", "Lai Châu", "Hậu Giang", "Lâm Đồng", "Lạng Sơn", "Hà Nam", "Bắc Cạn", "Bình Định", "Cao Bằng", "Sơn La", "Quảng Bình", "Quảng Trị", "Gia Lai", "Bắc Giang", "Hà Tĩnh", "Ninh Bình", "Bình Thuận", "Kon Tum", "Vĩnh Phúc", "Bạc Liêu", "Yên Bái", "Điện Biên", "Hà Giang");
function Sortify($string){
return preg_replace('~&([a-z]{1,2})(acute|cedil|circ|grave|lig|orn|ring|slash|tilde|uml);~i', '$1' . chr(255) . '$2', htmlentities($string, ENT_QUOTES, 'UTF-8'));
}
array_multisort(array_map('Sortify', $cities), $cities);
// asort($cities);
$response = "";
//function to generate response
function form_response($type, $message){
global $response;
if($type == "success") $response = "<div class='success'>{$message}</div>";
else $response = "<div class='error'>{$message}</div>";
}
//response messages
$not_human = "Human verification incorrect.";
$missing_content = "Please supply all information.";
$email_invalid = "Email Address Invalid.";
$message_unsent = "Message was not sent. Try Again.";
$message_sent = "Thanks! Your message has been sent.";
//user posted variables
$taxcode = $_POST['customer_taxcode'];
$company = $_POST['customer_company'];
$address = $_POST['customer_address'];
$city = $_POST['customer_city'];
$email = $_POST['message_email'];
$name = $_POST['customer_name'];
$phone = $_POST['customer_phone'];
$message = $_POST['message_text'];
$human = $_POST['message_human'];
//php mailer variables
$to = get_option('admin_email');
$subject = "Someone sent a message from ".get_bloginfo('name');
$headers = 'From: '. $email . "\r\n" . 'Reply-To: ' . $email . "\r\n";
if(!$human == 0){
if($human != 2) form_response("error", $not_human); //not human!
else {
//validate email
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
form_response("error", $email_invalid);
else //email is valid
{
//validate presence of name and message
if(empty($name) || empty($message)){
form_response("error", $missing_content);
}
else //ready to go!
{
$sent = wp_mail($to, $subject, strip_tags($message), $headers);
if($sent) form_response("success", $message_sent); //message sent!
else form_response("error", $message_unsent); //message wasn't sent
}
}
}
}
else if ($_POST['submitted']) form_response("error", $missing_content);
get_header();
?>
<style type="text/css">
#register-customer .error{
padding: 5px 9px;
border: 1px solid red;
color: red;
border-radius: 3px;
}
#register-customer .success{
padding: 5px 9px;
border: 1px solid green;
color: green;
border-radius: 3px;
}
#register-customer .select-city {
width:100%;
position:absolute;
left:0;
top:0;
z-index:5;
}
#register-customer .select-holder {
display:inline-block;
position:relative;
width:100%;
height:1.5em;
background:#f9f9f9;
}
</style>
<section class="container" id="register-customer">
<h2 class="register-title">Đăng ký sử dụng</h2>
<div id="form-register-customer">
<?php echo $response; ?>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<form action="<?php the_permalink(); ?>" method="post" >
<div class="row">
<!-- mã số thuế -->
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 form-group">
<label for="customer_taxcode">Mã số thuế: <span class="txt-red">*</span></label>
<input type="text" class="form-control" name="customer_taxcode" id="customer_taxcode" value="<?php echo esc_attr($_POST['customer_taxcode']); ?>">
</div>
<!-- Tên công ty -->
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 form-group">
<label for="customer_company">Tên công ty: <span class="txt-red">*</span></label>
<input type="text" class="form-control" name="customer_company" id="customer_company" value="<?php echo esc_attr($_POST['customer_company']); ?>">
</div>
<!-- Địa chỉ -->
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 form-group">
<label for="customer_address">Địa chỉ: </label>
<input type="text" class="form-control" name="customer_address" id="customer_address" value="<?php echo esc_attr($_POST['customer_address']); ?>">
</div>
<!-- Tỉnh/Thành phố -->
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 form-group">
<label for="customer_city">Tỉnh/Thành phố: </label>
<span class="select-holder">
<select name="customer_city" id="customer_city" class="form-control select-city" onmousedown="if(this.options.length>9){this.size=9;}" onchange='this.size=0;' onblur="this.size=0;">
<?php foreach ($cities as $v_city): ?>
<option value="<?= ($_POST['customer_city']) ? $_POST['customer_city'] : $v_city?>"><?=$v_city?></option>
<?php endforeach; ?>
</select>
</span>
</div>
<!-- Người liên hệ -->
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 form-group">
<label for="customer_name">Người liên hệ: <span class="txt-red">*</span> </label>
<input type="text" class="form-control" name="customer_name" id="customer_name" value="<?php echo esc_attr($_POST['customer_name']); ?>">
</div>
<!-- Số điện thoại -->
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 form-group">
<label for="customer_phone">Số điện thoại: <span class="txt-red">*</span> </label>
<input type="text" class="form-control" name="customer_phone" id="customer_phone" placeholder="Số điện thoại" value="<?php echo esc_attr($_POST['customer_phone']); ?>">
</div>
<!-- Email -->
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 form-group">
<label for="customer_email">Email: </label>
<input type="text" class="form-control" name="customer_email" id="customer_email" placeholder="Email" value="<?php echo esc_attr($_POST['customer_email']); ?>">
</div>
<!-- Nội dung -->
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 form-group">
<label for="customer_message">Nội dung: </label>
<input type="text" class="form-control" name="customer_message" id="customer_message" placeholder="Lĩnh vực kinh doanh" value="<?php echo esc_attr($_POST['customer_message']); ?>">
</div>
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 form-group">
<input type="submit" value="Đăng ký" class="bg-light-green">
<input type="hidden" name="submitted" value="1">
</div>
</div>
</form>
</div>
</div>
</div>
</section>
<?php get_footer(); ?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment