Thread Starter
Jason
(@galapogos01)
Worse still; the plugin sets 13 postmeta records for each product, even when the mapping is empty!
- fb_age_group
- fb_brand
- fb_color
- fb_gender
- fb_material
- fb_mpn
- fb_pattern
- fb_product_condition
- fb_product_description
- fb_product_video
- fb_rich_text_description
- fb_size
- fb_visibility
This is madness — can you advise how this can be stopped?
Thread Starter
Jason
(@galapogos01)
For anyone following — this patch bypasses saving the superfluous meta:
--- a/facebook-commerce.php
+++ b/facebook-commerce.php
@@ -1004,6 +1004,8 @@
* @param WC_Facebook_Product $woo_product The Facebook product object
*/
private function save_facebook_product_attributes( $woo_product ) {
+ // Disabled: rely on defaults.
+ return;
// phpcs:disable WordPress.Security.NonceVerification.Missing
if ( isset( $_POST[ WC_Facebook_Product::FB_BRAND ] ) ) {
$woo_product->set_fb_brand( sanitize_text_field( wp_unslash( $_POST[ WC_Facebook_Product::FB_BRAND ] ) ) );
Would love to see a proper fix to this in core; only save them if populated, for example! Think of your poor customers’ performance…
Plugin Support
Marija
(@marijastuntcoders)
Hi @galapogos01 – thank you for reaching out!
We have prioritized this issue, and the team is looking into it. We will let you know as soon as we have an update.
Kind regards,
Marija
Thread Starter
Jason
(@galapogos01)
Thanks @marijastuntcoders
I found I also had to patch these methods to avoid further superfluous meta records being created:
--- a/facebook-commerce.php
+++ b/facebook-commerce.php
@@ -1071,6 +1071,8 @@
* @since 1.10.0
*/
private function save_product_settings( WC_Product $product ) {
+ // Disabled: rely on defaults.
+ return;
$woo_product = new WC_Facebook_Product( $product->get_id() );
// phpcs:disable WordPress.Security.NonceVerification.Missing
And
--- a/includes/Products.php
+++ b/includes/Products.php
@@ -299,6 +299,9 @@
* @return bool success
*/
public static function set_product_visibility( \WC_Product $product, $visibility ) {
+ // Disabled: rely on default (visible).
+ return true;
+
unset( self::$products_visibility[ $product->get_id() ] );
if ( ! is_bool( $visibility ) ) {
return false;
These patches are just butchering methods to avoid creating meta records. It would be excellent to see the plugin properly updated to avoid creating these records where the product is just using default values. ie. where the value is not set, the plugin should skip saving a meta.