WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce Advanced Product Quantities
[resolved] Plugin gives error when we update product which is already added to cart. (8 posts)

  1. ashu2982
    Member
    Posted 6 months ago #

    Hi,
    I just installed your plugin as it does what i exactly need.
    I was checking how it works so i added incremental quantity to product and proceed to checkout then i went back to same product page decrease the quantity and clicked add to cart button and BOOM it gave error message and then site goes blank with just 'error' showing on screen.

    Warning: Division by zero in /home/*********/wp-content/plugins/woocommerce-incremental-product-quantities/product-quantity-validations.php on line 137
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/*********/wp-content/plugins/woocommerce-incremental-product-quantities/product-quantity-validations.php:137) in /home/********/wp-includes/pluggable.php on line 876

    Please take a look at error message and if possible please fix this error asap because this plugin was the only reason that i didn't switch to another shopping cart.

    Thanks in advance.

    http://wordpress.org/plugins/woocommerce-incremental-product-quantities/

  2. ashu2982
    Member
    Posted 6 months ago #

    An update to my problem.
    Just figured out that the site goes blank with 'error' message was because of Better WP Security Plugun. It says 'Site is locked down due to too many attempts to open a file that does not exist.' though every time this lock down came after the error in plugin.

  3. ashu2982
    Member
    Posted 6 months ago #

    Ok i deleted these lines in product-quantity-validations.php and so far plugin is working great.
    I am sorry but i don't have much knowledge about php and wp programming so i am completely unaware of what it does. Please let me know if there is any other alternative.

    if ( $step != null && $cart_qty_rem % step != 0 ) {
    $woocommerce->add_error( sprintf( __("You may only purchase %s in multiples of %s.", 'woocommerce' ), $title, $step ) );
    return false;
    }

    I am not marking this question as resolved because i know deleting code written by author is definitely not a solution :)

  4. J. Tyler Wiest
    Member
    Plugin Author

    Posted 6 months ago #

    Hm, personally I'm unable to replicate the error but based on your error try replacing what you removed with this:

    // Total Cart Quantity Step Validation
    if ( $step != null && $step != 0 && $cart_qty_rem != 0 && $cart_qty_rem % $step != 0 ) {
    $woocommerce->add_error( sprintf( __("You may only purchase %s in multiples of %s.", 'woocommerce' ), $title, $step ) );
    return false;
    }

    This shouldn't run the validation if $step or $cart_qty_rem = 0 meaning you shouldn't get a division by 0 error.

    Please let me know so I can push the changes to the repo, thanks!

  5. ashu2982
    Member
    Posted 6 months ago #

    Yes this worked. Now i am not getting any error after updating your code.

    Thanks for your help. This plugin definitely deserve 5 Star from me :)

  6. J. Tyler Wiest
    Member
    Plugin Author

    Posted 6 months ago #

    Great!

    Glad you enjoy it.

  7. atejena
    Member
    Posted 6 months ago #

    Hi i installed the plugin onto my site but when i activate the plugin all i get when trying to edit a product is the description and a bar that says Quantity rules the problem is that i'm not able to expand that bar so i'm left with no way to update pricing, short description or pretty much anything under the Description box. Help me please.

  8. J. Tyler Wiest
    Member
    Plugin Author

    Posted 4 months ago #

    Are you still having that issue atejena?

Reply

You must log in to post.

About this Plugin

About this Topic