September 22, 2020 at 1:34 pm
Hi,
I would like to add a free shipping amount notice after my side cart content by using a custom function. It seems that code block does not work for that purpose. Is there a way to add custom function to elements?
If not then what is the correct hook for afters side cart content area? I used this function here below.
As a feature request: it would be great to set this “Get free shipping if you order $$$ more” in the Customizer by just adding the amount 🙂
Thanks,
J.
add_action( 'kadence_after_side_cart_content', 'cart_notice' );
function cart_notice() {
$min_amount = 50; //change this to your free shipping threshold
$current = WC()->cart->subtotal;
if ( $current < $min_amount ) {
$added_text = 'Get free shipping if you order ' . wc_price( $min_amount - $current ) . ' more!';
$return_to = wc_get_page_permalink( 'shop' );
$notice = sprintf( '<a href="%s" class="button wc-forward">%s</a> %s', esc_url( $return_to ), 'Continue Shopping', $added_text );
wc_print_notice( $notice, 'notice' );
}