bobbingwide / vgc

VGC - Garden Vista Group theme
GNU General Public License v2.0
0 stars 0 forks source link

Warning Undefined array key "_square_meter" when Updating any product #65

Closed bobbingwide closed 9 months ago

bobbingwide commented 10 months ago

When updating A test product 10 x 10ft (ID 9566) the following message was produced.

PHP Warning: Undefined array key "_square_meter" in C:\apache\htdocs\wordpress\wp-content\themes\vgc\inc\custom-woo-functions.php on line 425

It seems that this message is produced when updating any product.

Originally posted by @bobbingwide in https://github.com/bobbingwide/vgc/issues/62#issuecomment-1780780040

bobbingwide commented 10 months ago

Analysis of the code shows that the logic to display the Product Size - function addSquareMeterToProductPageAdmin() is not called from anywhere. But the code to save the _square_meter post meta data is still active. Solution: Comment out the following line.

add_action('woocommerce_process_product_meta', 'woocommerceProcessCustomFields');

This problem existed in VGC v1.0.0

bobbingwide commented 10 months ago

Note that there are only 8 products which have this post meta value. Showing rows 0 - 7 (8 total, Query took 0.0123 seconds.) SELECT * FROM vgcwp_postmeta where meta_key = '_square_meter';

meta_id post_id meta_key meta_value
48614 3344 _square_meter 80
414901 4552 _square_meter 80
520662 4689 _square_meter 80
994312 6212 _square_meter 80
1006099 6235 _square_meter 80
1009150 6274 _square_meter 80
1011435 6275 _square_meter 80
1220852 6611 _square_meter 80

and they're all draft products: REGENCY TEMPLATE something

bobbingwide commented 9 months ago

Delivered in v1.7.0