簡體   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