Jump to content

MikeETWE

New Members
  • Posts

    3
  • Joined

  • Last visited

MikeETWE's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, like this? 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>'; } else { $message = __( '', 'woocommerce' ) . $free_shipping; } wc_print_notice( $message, 'success' ); } In that case i have error: And the caption "Add ... worth of goods to your order to get ...." is not displayed.
  2. 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' ); }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.