Ok, FYI, I just nailed my issue but I have no idea how to fix it.
Re-reading this thread I openend the Chrome Dev Tools and looked at the XHR requests to see the AJAX calls and saw the same kind of respons as honestaeb AND a much smalled bit of HTML code and text I recognized right away as it’s a notice I added myself via hook.
In this case, the client sells coffee in 1 lb increments in either 1 or 2 lb bags and I needed to check if any product in cart has 2 units of qty and if so, show the notice.
My function hooks on the woocommerce_check_cart_items hook. In there I have a conditional check for is_cart() || is_checkout(), inside that another check for quantity and if products are in specific categories then I use the wc_print_notice function to print a message.
I just tested commenting out that code in my child theme’s functions.php and order went through without error. Here’s my entire code for this below. Any way I could modify that to avoid that error?
Thanks!
add_action( 'woocommerce_check_cart_items', 'wfd_two_pounds_bags_warning_check' );
function wfd_two_pounds_bags_warning_check () {
global $woocommerce;
// Only run in the Cart or Checkout pages
if( is_cart() || is_checkout() ) {
$coffee_cats = array( 15, 16, 17, 18, 19 );
// Loop through the products in the Cart
foreach( $woocommerce->cart->cart_contents as $product_in_cart ) {
if( $product_in_cart['quantity'] >= 2 && has_term( $coffee_cats, 'product_cat', $product_in_cart['product_id'] ) ) {
$cart_message = 'Si votre commande contient 2 livres et plus du même café, il sera livré en sacs de 2 livres. Si vous préférez le recevoir en sacs de 1 livre, veuillez le mentionner dans les <strong>notes de la commande</strong> sur la page de commande.';
if ( '2' == get_current_blog_id() ) {
$cart_message = 'If your order contains 2lbs or more of the same coffee, it will be shipped in 2lbs bags. If you prefer to get certain or all of your coffees in 1lbs bags, please mention so in the <strong>Order Notes</strong> on the Checkout page.';
}
wc_print_notice( $cart_message, 'notice');
break;
}
}
}
}