Skip to content

Conversation

@neralex
Copy link
Contributor

@neralex neralex commented Sep 11, 2025

Problem: $args[‘input_value’], min_value, max_value are not guaranteed to be assigned > PHP 8 throws notices.

Warning: Undefined array key "input_value" in \wp-content\themes\bootscore\woocommerce\inc\wc-qty-btn.php on line 31

The issue happens under php 8.3.2x while trying to reach the checkout.

The added safeguards ensure that meaningful, complete, type-consistent values are always available - regardless of what Woo/plugins deliver - eliminating PHP 8 notices and keeping button states correct.

It works for me. But please test the changes to see if the snippet still works for the cases you have added it for.

Problem: $args[‘input_value’], min_value, max_value are not guaranteed to be assigned > PHP 8 throws notices.

The added safeguards ensure that meaningful, complete, type-consistent values are always available - regardless of what Woo/plugins deliver - eliminating PHP 8 notices and keeping button states correct.
@crftwrk crftwrk added this to v6.4.0 Sep 12, 2025
@crftwrk crftwrk moved this to In Progress in v6.4.0 Sep 12, 2025
@crftwrk crftwrk requested a review from Axos11 September 12, 2025 08:06
Copy link
Member

@crftwrk crftwrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Axos11
Copy link
Contributor

Axos11 commented Sep 15, 2025

The question is "why" is woocommerce loading that file in the checkout in the first place. Because in our templating we don't have any qty buttons on the checkout page. So basically I think both should be cleaned up (prevent loading, find out what actually loads the file in the first place) and the sanitation added as well.
I have to double check the 0 stuff. But otherwise code looks fine to me. Will try to do that asap

@neralex
Copy link
Contributor Author

neralex commented Sep 15, 2025

@Axos11 I'm new at woocommerce and I was just trying to build some custom discount functions with ACF while running in those warnings after pressing the checkout-button and it leads me into this file. So I was only trying to reach the checkout along this way. But yeah, the reason why should be good to know.

@Axos11
Copy link
Contributor

Axos11 commented Sep 24, 2025

@neralex every contribution is welcome and thanks for bringing the focus back to that issue. I think that I would not change any of the values without need but just escape early if the data needed for the logic isn't present.

@crftwrk what do you think?

  add_filter('woocommerce_quantity_input_args', function (array $args) {

    add_filter('woocommerce_quantity_input_type', 'change_quantity_input_type');

    // Exit early if required args are not set
    if (!isset($args['max_value']) || !isset($args['min_value']) || !isset($args['input_value'])) {
      return $args;
    }
    // Rest of the code

@neralex
Copy link
Contributor Author

neralex commented Sep 24, 2025

@Axos11 I think it's great because 1. it fixes the bug and 2. it changes the actual behaviour less invasively than my patch does. #shortandsimple

@crftwrk
Copy link
Member

crftwrk commented Sep 25, 2025

I‘m in 👍 @neralex do you want to push a commit to this PR?

@neralex
Copy link
Contributor Author

neralex commented Sep 25, 2025

@crftwrk thanks for the offer but just merge it. @Axos11 found a great solution.

@crftwrk
Copy link
Member

crftwrk commented Sep 26, 2025

Got it!

@crftwrk crftwrk merged commit aa6b9e9 into bootscore:main Sep 26, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in v6.4.0 Sep 26, 2025
@neralex neralex deleted the woocommerce-quantity-php8-fix branch October 10, 2025 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants