Woocommerce 预订参数网址
Posted
技术标签:
【中文标题】Woocommerce 预订参数网址【英文标题】:Woocommerce Bookings parameter url 【发布时间】:2021-08-04 09:06:04 【问题描述】:我想在可预订产品的表单中填写参数 url 一个字段。在 html 代码中,我找到了某个字段的 name 和 id。
<p class="form-field form-field-wide wc_booking_field_lot wc_bookings_field_resource">
<label for="wc_bookings_field_resource">Lot:</label>
<select name="wc_bookings_field_resource" id="wc_bookings_field_resource">
<option value="303">P30</option>
<option value="304">P31</option>
<option value="305">P32</option>
<option value="306">P33</option>
<option value="307">P34</option>
<option value="308">P35</option>
<option value="309">P36</option>
<option value="310">P37</option>
</select>
</p>
例如,我想在打开链接时用“P35”填充字段。我试图让它与“http://example.com/booking/camperpitch/?wc_bookings_field_resource=308”一起工作,但它什么也没做。
你知道怎么做吗?
谢谢
【问题讨论】:
【参考方案1】:试试下面的代码。
<p class="form-field form-field-wide wc_booking_field_lot wc_bookings_field_resource">
<label for="wc_bookings_field_resource">Lot:</label>
<select name="wc_bookings_field_resource" id="wc_bookings_field_resource">
<option value="303" <?php echo ( isset( $_GET['wc_bookings_field_resource'] ) && $_GET['wc_bookings_field_resource'] != '' && $_GET['wc_bookings_field_resource'] == '303' ) ? 'selected': ''; ?>>P30</option>
<option value="304" <?php echo ( isset( $_GET['wc_bookings_field_resource'] ) && $_GET['wc_bookings_field_resource'] != '' && $_GET['wc_bookings_field_resource'] == '304' ) ? 'selected': ''; ?>>P31</option>
<option value="305" <?php echo ( isset( $_GET['wc_bookings_field_resource'] ) && $_GET['wc_bookings_field_resource'] != '' && $_GET['wc_bookings_field_resource'] == '305' ) ? 'selected': ''; ?>>P32</option>
<option value="306" <?php echo ( isset( $_GET['wc_bookings_field_resource'] ) && $_GET['wc_bookings_field_resource'] != '' && $_GET['wc_bookings_field_resource'] == '306' ) ? 'selected': ''; ?>>P33</option>
<option value="307" <?php echo ( isset( $_GET['wc_bookings_field_resource'] ) && $_GET['wc_bookings_field_resource'] != '' && $_GET['wc_bookings_field_resource'] == '307' ) ? 'selected': ''; ?>>P34</option>
<option value="308" <?php echo ( isset( $_GET['wc_bookings_field_resource'] ) && $_GET['wc_bookings_field_resource'] != '' && $_GET['wc_bookings_field_resource'] == '308' ) ? 'selected': ''; ?>>P35</option>
<option value="310" <?php echo ( isset( $_GET['wc_bookings_field_resource'] ) && $_GET['wc_bookings_field_resource'] != '' && $_GET['wc_bookings_field_resource'] == '310' ) ? 'selected': ''; ?>>P37</option>
<option value="309" <?php echo ( isset( $_GET['wc_bookings_field_resource'] ) && $_GET['wc_bookings_field_resource'] != '' && $_GET['wc_bookings_field_resource'] == '309' ) ? 'selected': ''; ?>>P36</option>
</select>
</p>
【讨论】:
以上是关于Woocommerce 预订参数网址的主要内容,如果未能解决你的问题,请参考以下文章
FacetWp 预订不适用于 woocommerce 预订?
text [WooCommerce预订]修改预订摘要中的日期
php [WooCommerce预订]自动确认通过COD购买的预订