代码:
<?php// adds the button to the cart pageadd_action( 'woocommerce_cart_actions', 'woocommerce_empty_cart_button' );function woocommerce_empty_cart_button() {echo '<a href="' . esc_url( add_query_arg( 'empty_cart', 'yes' ) ) . '" style="background-color: rgba(224, 32, 32,1);"; class="btn btn-scheme-light btn-scheme-hover-light btn-style-default btn-style-round btn-size-default" title="' . esc_attr( 'Svuota il carrello', 'woocommerce' ) . '">' . esc_html( 'Svuota il carrello', 'woocommerce' ) . '</a>';}// empty the cart and refresh the page (redirects to the cart page)add_action( 'wp_loaded', 'woocommerce_empty_cart_action', 20 );function woocommerce_empty_cart_action() {if ( isset( $_GET['empty_cart'] ) && 'yes' === esc_html( $_GET['empty_cart'] ) ) {WC()->cart->empty_cart();$referer = wc_get_cart_url();wp_safe_redirect( $referer );}}add_action( 'woocommerce_before_mini_cart', 'minicart_count_after_content' );function minicart_count_after_content() {if ( WC()->cart->get_cart_contents_count() > 0 )echo '<a href="' . esc_url( add_query_arg( 'empty_cart', 'yes' ) ) . '" style="background-color: rgba(224, 32, 32,1);"; class="btn btn-scheme-light btn-scheme-hover-light btn-style-default btn-style-rectangle btn-size-default" title="' . esc_attr( 'Svuota il carrello', 'woocommerce' ) . '">' . esc_html( 'Svuota il carrello', 'woocommerce' ) . '</a>';}<?php // adds the button to the cart page add_action( 'woocommerce_cart_actions', 'woocommerce_empty_cart_button' ); function woocommerce_empty_cart_button() { echo '<a href="' . esc_url( add_query_arg( 'empty_cart', 'yes' ) ) . '" style="background-color: rgba(224, 32, 32,1);"; class="btn btn-scheme-light btn-scheme-hover-light btn-style-default btn-style-round btn-size-default" title="' . esc_attr( 'Svuota il carrello', 'woocommerce' ) . '">' . esc_html( 'Svuota il carrello', 'woocommerce' ) . '</a>'; } // empty the cart and refresh the page (redirects to the cart page) add_action( 'wp_loaded', 'woocommerce_empty_cart_action', 20 ); function woocommerce_empty_cart_action() { if ( isset( $_GET['empty_cart'] ) && 'yes' === esc_html( $_GET['empty_cart'] ) ) { WC()->cart->empty_cart(); $referer = wc_get_cart_url(); wp_safe_redirect( $referer ); } } add_action( 'woocommerce_before_mini_cart', 'minicart_count_after_content' ); function minicart_count_after_content() { if ( WC()->cart->get_cart_contents_count() > 0 ) echo '<a href="' . esc_url( add_query_arg( 'empty_cart', 'yes' ) ) . '" style="background-color: rgba(224, 32, 32,1);"; class="btn btn-scheme-light btn-scheme-hover-light btn-style-default btn-style-rectangle btn-size-default" title="' . esc_attr( 'Svuota il carrello', 'woocommerce' ) . '">' . esc_html( 'Svuota il carrello', 'woocommerce' ) . '</a>'; }<?php // adds the button to the cart page add_action( 'woocommerce_cart_actions', 'woocommerce_empty_cart_button' ); function woocommerce_empty_cart_button() { echo '<a href="' . esc_url( add_query_arg( 'empty_cart', 'yes' ) ) . '" style="background-color: rgba(224, 32, 32,1);"; class="btn btn-scheme-light btn-scheme-hover-light btn-style-default btn-style-round btn-size-default" title="' . esc_attr( 'Svuota il carrello', 'woocommerce' ) . '">' . esc_html( 'Svuota il carrello', 'woocommerce' ) . '</a>'; } // empty the cart and refresh the page (redirects to the cart page) add_action( 'wp_loaded', 'woocommerce_empty_cart_action', 20 ); function woocommerce_empty_cart_action() { if ( isset( $_GET['empty_cart'] ) && 'yes' === esc_html( $_GET['empty_cart'] ) ) { WC()->cart->empty_cart(); $referer = wc_get_cart_url(); wp_safe_redirect( $referer ); } } add_action( 'woocommerce_before_mini_cart', 'minicart_count_after_content' ); function minicart_count_after_content() { if ( WC()->cart->get_cart_contents_count() > 0 ) echo '<a href="' . esc_url( add_query_arg( 'empty_cart', 'yes' ) ) . '" style="background-color: rgba(224, 32, 32,1);"; class="btn btn-scheme-light btn-scheme-hover-light btn-style-default btn-style-rectangle btn-size-default" title="' . esc_attr( 'Svuota il carrello', 'woocommerce' ) . '">' . esc_html( 'Svuota il carrello', 'woocommerce' ) . '</a>'; }
© 版权声明
THE END