【发布时间】:2019-03-20 20:58:53
【问题描述】:
我正在使用下面的代码,当客户选择一个国家/地区时,它可以很好地向 woocommerce 结帐添加一条消息。但我也想使用这个短代码添加一个弹出窗口
echo do_shortcode('[sg_popup id=3839] ');
但是当我将它添加到文本消息下方时,弹出窗口总是会显示,即如果我添加以下内容
`echo '<div class="shipping-notice woocommerce-info" style="display:none">Please allow 5-10 business days for delivery after order processing.'; echo do_shortcode('[sg_popup id=3839] '); echo '</div>'
我想是因为它只是隐藏代码所以它实际上是在运行简码?但我还有什么其他选择?
感谢任何帮助。
add_action( 'woocommerce_before_checkout_billing_form', 'display_shipping_notice' );
function display_shipping_notice() {
echo '<div class="shipping-notice woocommerce-info" style="display:none">Please allow 5-10 business days for delivery after order processing.</div>';
}
add_action( 'woocommerce_after_checkout_form', 'show_hide_shipping_notice' );
function show_hide_shipping_notice(){
?>
<script>
jQuery(document).ready(function($){
// Set the country code (That will display the message)
var countryCode = 'FR';
$('select#billing_country').change(function(){
selectedCountry = $('select#billing_country').val();
if( selectedCountry == countryCode ){
$('.shipping-notice').hide();
}
else {
$('.shipping-notice').show();
}
});
});
</script>
<?php
}
【问题讨论】:
-
在前端转换后的 HTML 看起来如何。它可能是一个 css 问题,也可能是一个取决于将按什么顺序呈现的问题
标签: php jquery wordpress woocommerce checkout