• Resolved Creativewarrior

    (@creativewarrior)


    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]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Creativewarrior

    (@creativewarrior)

    Hi Just an update – the error message appears on other pages apart from the cart page but not consistently. I have cleared and purged the cache as well with no luck and all plugins are up to date with no new plugins being added, have disabled plugins as well and still get the error message.

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    This is related to my Advanced Shipping plugin, which is not the same as this plugin. Please get in touch through the support channel for that plugin to get assistance with it.

    Cheers,
    Jeroen

    Thread Starter Creativewarrior

    (@creativewarrior)

    Thanks Jeroen – have sent that through the proper support channel to you now ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Warning: max() error message’ is closed to new replies.