繁体   English   中英

Woocommerce 结帐条款和条件 - 删除控制命令和标签

[英]Woocommerce checkout terms and conditions - remove control commands and tags

woocommerce 结帐页面框中显示的嵌入式 T&C(条款和条件)确实显示了 T&C 页面https://lonesome-dragon.com/terms_conditions/的控制命令或标签。

这在结帐期间在文本框中看起来很乱,我想在那里隐藏这些控制命令。

这是我的主题(Qode Bridge with WP Bakery Builder)的问题,还是我可以在结帐页面上用 PHP 片段过滤掉它(也许这是可能的,因为所有这些控制命令都是括号之间的字符串)?

此类控制命令或标签的示例(另请参阅随附的屏幕截图)

[/vc_column_text][vc_separator type=”transparent” up=”15″]

示例这看起来如何

发生这种情况的站点(半 SFW)是: https://lonesome-dragon.com/ (只需将商店里的东西放入购物车,继续结帐并单击 T&C 复选框附近的“条款和条件”字样看到这些丑陋的标签。

非常感谢您的提示

最后我找到了如何摆脱这些标签的解决方案(也删除了方括号和方括号之间的所有内容)。

对于可能有同样问题的所有其他人,这里是代码:

/*** Strip Shortcode from Terms & Conditions Box *****/
remove_action( 'woocommerce_checkout_terms_and_conditions', 'wc_terms_and_conditions_page_content', 30 );
add_action( 'woocommerce_checkout_terms_and_conditions', 'wc_terms_and_conditions_page_content_custom', 30 );
function wc_terms_and_conditions_page_content_custom() {
    $terms_page_id = wc_terms_and_conditions_page_id();
    if ( ! $terms_page_id ) {
        return;
    }
    $page = get_post( $terms_page_id );
    if ( $page && 'publish' === $page->post_status && $page->post_content && ! has_shortcode( $page->post_content, 'woocommerce_checkout' )) {
/* hier bleiben tags mit "/" erhalten wie beispielsweise [vc_column width=”1/2″], weshalb das Pattern in preg_replace ersetzt wurde */
/* echo '<div class="woocommerce-terms-and-conditions" style="display: none; max-height: 200px; overflow: auto;">' . wp_kses_post( wc_format_content(preg_replace( "~(?:\[/?)[^/\]]+/?\]~s", '', $page->post_content ) ) ) . '</div>';} */
echo '<div class="woocommerce-terms-and-conditions" style="display: none; max-height: 200px; overflow: auto;">' . wp_kses_post( wc_format_content(preg_replace( "/\[([^\[\]]++|(?R))*+\]/", '', $page->post_content ) ) ) . '</div>';}  
}

来源: https://xtemos.com/forums/topic/help-shortcodes-visible-in-terms-and-conditions/并根据此处的见解进行调整: 如何使用正则表达式删除方括号和它们之间的任何内容?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM