Hi!
I have used the code for the free shipping notice and after updating to PHP 8.2 i have the following errors:
So i need help with updating this code to be compatible with PHP 8.2.
What is important:
I already used another code from https://www.businessbloomer.com/woocommerce-add-need-spend-x-get-free-shipping-cart-page/. And the problem was, that my site is in several languages, and there were some problems with translating.
I do not really need those parts of my current code, which includes delivery and time information. I need only a "free shipping notice option". So here is a code and i have really appreciated it if someone can help with optimizing/changing it.
So here is a code and i have really appreciated it if someone can help with optimizing/changing it.
add_action( 'woocommerce_before_checkout_form', 'next_day_delivery' );
add_action( 'woocommerce_before_cart', 'next_day_delivery' );
add_action( 'flatsome_cart_sidebar', 'next_day_delivery' );
function next_day_delivery() {
if( WC()->cart->is_empty() )
return; // Exit
$cart_subtotal = WC()->cart->subtotal;
$limit_free = 150; // Starting freee shipping amount
$free_shipping = ''; // Initialising
if ( $cart_subtotal < $limit_free ) {
$free_shipping = sprintf(
__('%s Add %s worth of goods to your order to get %s', 'woocommerce' ),
'', // ' <img src="' . get_stylesheet_directory_uri() . '/images/shipping-icon.png"> ',
strip_tags( wc_price( round( $limit_free - $cart_subtotal, 2 ) ) ),
'<strong>' . __( 'FREE SHIPPING!', 'woocommerce' ) . '</strong>'
);
} elseif ( $cart_subtotal >= $limit_free ) {
$free_shipping = '<strong>' . __( ' You get FREE SHIPPING!', 'woocommerce' ) . '</strong>';
}
if ( $end_time > $now_time && $is_week_days ) {
// print the information notice
$message = sprintf( __( '', 'woocommerce' ), $remain_time, $free_shipping );
}
elseif ( $end_time <= $now_time && $is_week_days ) {
$message = sprintf( __( '', 'woocommerce' ), $after_tomorow, $free_shipping );
} else {
$message = __( '', 'woocommerce' ) . $free_shipping;
}
wc_print_notice( $message, 'success' );
}