Skip to main content
12 events
when toggle format what by license comment
Apr 12, 2020 at 0:53 comment added Chaz Pierce Yes. The value is entered on the General Settings section of the Edit Product page (Variable) and saved properly. I simply want this event to fire only if the checkbox is checked. Nothing more - but its giving me a hell of a time.
Apr 12, 2020 at 0:43 comment added 西門 正 Code Guy - JingCodeGuy Is this value same for all users?
Apr 11, 2020 at 23:25 comment added Chaz Pierce Sorry, don't really understand your explanation. The value is set in General Settings on the Product Edit page. How can I use this value when dealing with item quantity?
Apr 11, 2020 at 22:33 comment added 西門 正 Code Guy - JingCodeGuy If the option is in the cart, the only way to pass to checkout process is from the form. Because it is an user option. If you get from database, the value is always the default one, not from the user. This is what form designed for passing instant options or data for processing.
Apr 11, 2020 at 19:07 comment added Chaz Pierce I'm not using $_REQUEST, but I assume that it should be able to get the custom field without it, no? Because the custom field $term_name is being passed the same way?
Apr 11, 2020 at 4:19 comment added 西門 正 Code Guy - JingCodeGuy I have updated notes on tracing about the $_REQUEST.
Apr 11, 2020 at 4:18 history edited 西門 正 Code Guy - JingCodeGuy CC BY-SA 4.0
add notes on tracing
Apr 11, 2020 at 3:49 comment added 西門 正 Code Guy - JingCodeGuy What is the var_dump($stock_weight_checkbox) result? is $stock_weight_checkbox a product attribute? when it is submitted to cart, does it include in $_REQUEST when you var_dump? If not, then the $stock_weight_checkbox did not pass the value. And it is only for display. If so, it is not inside the form tag.
Apr 11, 2020 at 3:32 comment added 西門 正 Code Guy - JingCodeGuy I can see that you use === which means value + type is completely same. It could be type problem if value looks right, try == and see if the result is same.
Apr 11, 2020 at 3:21 comment added Chaz Pierce It seems that somewhere in the checkout process that product meta ($stock_weight_checkbox) is not being passed or considered.
Apr 11, 2020 at 3:20 comment added Chaz Pierce Thank you for this. Due to your help I was able to get the the if ( 'yes' === $stock_weight_checkbox) part tested and the see it was returning a boolean false in that part of the script. wc_get_product( $product_id ); fixed that and now the condition is accurately showing the error when necessary. The issue I am still having is in the first part of the script. When $stock_weight_checkbox is enabled it no longer correctly reduces the stock quantity according to the specified rules. If I eliminate the 'yes === condition, it works. A var_dump shows 'yes' on product page.
Apr 11, 2020 at 2:33 history answered 西門 正 Code Guy - JingCodeGuy CC BY-SA 4.0