【发布时间】:2019-09-01 08:10:18
【问题描述】:
在购物车页面中,我已经创建了两个文本字段,但我无法将用户在该字段中输入的值获取到管理订单详细信息页面。
如何获取订单详细信息页面中的值,并且我还想将这些详细信息保存在数据库中。
以下是我的购物车页面的代码
<?php
do_action( 'woocommerce_before_cart' ); ?>
<section class="checkout_display">
<div class="container">
<div class="row">
<form action="<?php echo esc_url( wc_get_checkout_url() );?>" method="post">
<?php do_action( 'woocommerce_before_cart_table' ); ?>
<div class="col-lg-6 col-md-8 col-sm-12 inset">
<div class="checkout_title">get started</div>
<div class="first_form">
<!--Code which display text field one -->
<div class="form-group" >
<label>Instagram username</label>
<input type="text" name="igusername" required>
</div>
<!--Code which display text field second -->
<div class="form-group">
<label>Email</label>
<input type="email" name="useremail" required>
</div>
<?php do_action( 'woocommerce_before_cart_contents' ); ?>
<?php
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
?>
<div class="form-group">
<label>Your package</label>
<select disabled>
<option> <?php echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $_product->get_name() ), $cart_item, $cart_item_key ) );?> For
<span><?php echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); // PHPCS: XSS ok.
?>
</span>
</option>
</select>
</div>
<div class="checkbox"><input type="checkbox" /> Yes! send me special promotion and discounts</div>
<div class="btn">
<input type="submit" value="next">
</a>
</div>
<?php
}
}
?>
<?php do_action( 'woocommerce_cart_contents' ); ?>
<?php do_action( 'woocommerce_after_cart_contents' ); ?>
</div>
</div>
<?php do_action( 'woocommerce_after_cart_table' ); ?>
</form>
</div>
</div>
</section>
<?php do_action( 'woocommerce_after_cart' ); ?>
显示文本字段一和二的代码是文本框,我想从中获取用户输入的值,并希望在付款完成后将它们显示并存储在管理订单详细信息页面中
【问题讨论】:
-
在购物车页面显示/保存字段的相关代码在哪里?即使它不起作用,您也应该始终在答案中提供相关代码。没有它,没有人可以帮助你。请记住,人们可以通过魔术猜测事物,而且您应该提供一些上下文......
-
@LoicTheAztec 现在可以请您检查一下吗?
标签: php wordpress session woocommerce hook-woocommerce