Variable product with attribure value 0 is not working
-
Steps to reprocess the error.
1) Create Variable product with attribute value 0 to 5 (Eg: Size 0|1|2|3|4|5)
2) Go to product page and try to add in cart with attribute selection.
3) It will throw an error :Invalid value posted for {attribute_label}Solution:
I have research and found the issue in method find_matching_product_variation( $product, $match_attributes = array() )File name: woocommerce\includes\data-stores\class-wc-product-data-store-cpt.php
Line number: 1115
Current code:$match_any_value = empty( $attribute_value );
Should be: $match_any_value = (empty( $attribute_value ) && $attribute_value === 0) ? true : false;Please fix it in next release.
-
Hi there,
I created a variable product with the following attribute – https://cld.wthms.co/ZxZqzz – and then generated variations for each attribute. I wasn’t able to replicate your error.
Could you please share screenshots of the Attributes and Variations setup? Also, please share your system report. I would like more details to take a look to see if I can replicate this issue and post it as a bug report.
Cheers.
Hello
Thanks for reply.
I think this bug is affect when product has more than 50 variations.
Below are the variation screenshot and system report.
System Report:
`
### WordPress Environment ###WordPress address (URL): http://wp.securecerts.us
Site address (URL): http://wp.securecerts.us
WC Version: 3.7.0
REST API Version: ✔ 1.0.2
Log Directory Writable: ✔
WP Version: 5.2.3
WP Multisite: –
WP Memory Limit: 256 MB
WP Debug Mode: –
WP Cron: ✔
Language: en
External object cache: –### Server Environment ###
Server Info: Apache/2
PHP Version: 7.2.20
PHP Post Max Size: 64 MB
PHP Time Limit: 500
PHP Max Input Vars: 1000
cURL Version: 7.29.0
NSS/3.36SUHOSIN Installed: –
MySQL Version: 5.5.63-MariaDB
Max Upload Size: 64 MB
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ✔
DOMDocument: ✔
GZip: ✔
Multibyte String: ✔
Remote Post: ✔
Remote Get: ✔### Database ###
WC Database Version: 3.7.0
WC Database Prefix: wp_
MaxMind GeoIP Database: ✔
Total Database Size: 17.36MB
Database Data Size: 9.60MB
Database Index Size: 7.76MB
wp_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_comments: Data: 0.05MB + Index: 0.09MB + Engine InnoDB
wp_failed_jobs: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailchimp_carts: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_options: Data: 1.05MB + Index: 0.05MB + Engine InnoDB
wp_postmeta: Data: 4.52MB + Index: 5.03MB + Engine InnoDB
wp_posts: Data: 2.52MB + Index: 0.61MB + Engine InnoDB
wp_queue: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_sslstore_products: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_sslstore_refunds: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_terms: Data: 0.13MB + Index: 0.16MB + Engine InnoDB
wp_term_relationships: Data: 0.23MB + Index: 0.22MB + Engine InnoDB
wp_term_taxonomy: Data: 0.17MB + Index: 0.22MB + Engine InnoDB
wp_usermeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_wc_admin_notes: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_product_meta_lookup: Data: 0.25MB + Index: 0.56MB + Engine InnoDB
wp_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB### Security ###
Secure connection (HTTPS): ❌
Your store is not using HTTPS. Learn more about HTTPS and SSL Certificates.
Hide errors from visitors: ✔### Active Plugins (7) ###
Limit Login Attempts Reloaded: by WPChef – 2.9.0
Mailchimp for WooCommerce: by Mailchimp – 2.2.4
WooCommerce Admin: by WooCommerce – 0.19.0
WooCommerce Stripe Gateway: by WooCommerce – 4.2.5
WooCommerce Services: by Automattic – 1.21.1
WooCommerce: by Automattic – 3.7.0
WP SSLStore: by The SSL Store – 1.0.0### Inactive Plugins (2) ###
Akismet Anti-Spam: by Automattic – 4.1.2
Hello Dolly: by Matt Mullenweg – 1.7.2### Must Use Plugins (1) ###
installatron_hide_status_test.php: by –
### Settings ###
API Enabled: –
Force SSL: ✔
Currency: USD ($)
Currency Position: left
Thousand Separator: ,
Decimal Separator: .
Number of Decimals: 2
Taxonomies: Product Types: external (external)
grouped (grouped)
simple (simple)
variable (variable)Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
exclude-from-search (exclude-from-search)
featured (featured)
outofstock (outofstock)
rated-1 (rated-1)
rated-2 (rated-2)
rated-3 (rated-3)
rated-4 (rated-4)
rated-5 (rated-5)Connected to WooCommerce.com: –
### WC Pages ###
Shop base: #6 – /shop/
Cart: #7 – /cart/
Checkout: #8 – /checkout/
My account: #9 – /my-account/
Terms and conditions: ❌ Page visibility should be public### Theme ###
Name: Storefront
Version: 2.5.3
Author URL: https://woocommerce.com/
Child Theme: ❌ – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme
WooCommerce Support: ✔### Templates ###
Overrides: –
### Action Scheduler ###
Complete: 41
Oldest: 2019-10-03 10:43:16 +0000
Newest: 2019-10-09 04:55:48 +0000Pending: 2
Oldest: 2019-10-09 05:55:48 +0000
Newest: 2019-10-09 05:55:48 +0000Canceled: 0
Oldest: –
Newest: –In-progress: 0
Oldest: –
Newest: –Failed: 0
Oldest: –
Newest: –==================================================
Thank you for sharing your status report and the screenshot.
I did a bit more digging and found out that we do have a fix for the 0 attribute issue slated for release in WooCommerce 3.8.0 as explained here – https://github.com/woocommerce/woocommerce/pull/24750#discussion_r330602395
We don’t have a release date yet but please look out for that.
Also, if you have a large number of variations, you may also run into the AJAX Variation limit. To learn more about the issue and how to solve it, please see https://elvtn.com/woocommerce/overridng-woocommerce-ajax-variations-limit/.
I haven’t heard from you in a while so I’m going to go ahead and mark this issue as resolved. If you need additional help, please start a new thread.
Hello drwpcom,
We are waiting for woocommerce release with the bug fix.
https://github.com/woocommerce/woocommerce/pull/24750#discussion_r330602395
- The topic ‘Variable product with attribure value 0 is not working’ is closed to new replies.