Warning: max() error message
-
Hi
we have customers complaining about an error message coming up in the shopping cart and it makes reference to your plugin. We have the advanced paid version and custom code that you wrote for us on this site as well so not sure if the conflict is with that since the new updates to wordpress? Error message is:warning:max(): Array must contain at least one element in /home/watchwa/public_html/greenkids-drytimes.com.au/wp-content/plugis/woocommerce-advanced-shipping/includes/class-was-match-conditions.php on line 306
I don’t know what triggers the error as I have been unable to replicate it myself but the client says it is appearing quite frequently.
Any ideas on how to resolve this please?If it helps here is a copy of the custom code that you wrote for us:
/* Match Subtotal minus Discounts */
/**
* Must match the subtotal amount minus the discount.
*
* @param bool $match
* @param string $operator
* @param mixed $value
* @return bool
*/
add_action( ‘was_match_condition_subtotal_no_discount’, ‘was_match_condition_subtotal_no_discount’, 10, 3 );
function was_match_condition_subtotal_no_discount( $match, $operator, $value ) {if ( ! isset( WC()->cart ) ) return;
$subtotal_no_discount = WC()->cart->subtotal – ( WC()->cart->get_cart_discount_total() + WC()->cart->get_cart_discount_tax_total() );
if ( ‘==’ == $operator ) :
$match = ( $subtotal_no_discount == $value );
elseif ( ‘!=’ == $operator ) :
$match = ( $subtotal_no_discount != $value );
elseif ( ‘>=’ == $operator ) :
$match = ( $subtotal_no_discount >= $value );
elseif ( ‘<=’ == $operator ) :
$match = ( $subtotal_no_discount <= $value );
endif;return $match;
}
add_filter( ‘was_conditions’, ‘was_conditions_add_subtotal_no_discount’, 10, 1 );
function was_conditions_add_subtotal_no_discount( $conditions ) {$conditions[‘Cart’][‘subtotal_no_discount’] = ‘Subtotal minus discount’;
return $conditions;
}
add_filter( ‘was_values’, ‘was_values_add_subtotal_no_discount’, 10, 2 );
function was_values_add_subtotal_no_discount( $values, $condition ) {switch ( $condition ) {
case ‘subtotal_no_discount’:
$values[‘field’] = ‘text’;
break;}
return $values;
}
add_filter( ‘was_descriptions’, ‘was_descriptions_subtotal_no_discount’ );
function was_descriptions_subtotal_no_discount( $descriptions ) {$descriptions[‘subtotal_no_discount’] = __( ‘The subtotal cart amount, but minus the discounted amount.’, ‘woocommerce-advanced-shipping’ );
return $descriptions;
}
The page I need help with: [log in to see the link]
- The topic ‘Warning: max() error message’ is closed to new replies.