Jetpack: Interaction between WooCommerce create new copy of Product, and Publicize

Created on 11 Feb 2017  路  15Comments  路  Source: Automattic/jetpack

Steps to reproduce the issue

Install/Enable WooCommerce.
Create a product, publish.
Edit Product, select "Create new copy".
See the Publicize settings, and publish to see what actually happens (e.g. on Twitter).

What I expected

The publicize settings should be editable, and default to ticked.

What happened instead

The publicize settings are greyed out, and default to off.
However, when the copied product is published the publicize DOES happen (e.g. posts to Twitter etc). This the settings are greyed out, this cannot be adjusted at will. So it becomes a problem.

Good For Community Publicize [Pri] Normal [Type] Enhancement [Type] Good First Bug [Type] Happiness Request

All 15 comments

Thanks for the report.

When you duplicate a post (or a product), you also duplicate post meta data that was created by Publicize on the original post to indicate that the post was pushed to your social networks. To solve that issue, we would need to customize the duplicate post feature to remove all post meta data star the string _wpas_ when duplicating a post.

There used to be a woocommerce_duplicate_product_exclude_meta filter in WooCommerce that would allow to exclude specific post meta when duplicating a product, but it looks like that filter was removed in 10d3e2d580cc7ad815eddf32ca486f5c5fb2d26c. I've opened a GitHub issue with WooCommerce to see if we could bring that filter back, and thus make sure it's possible to duplicate WooCommerce products without affecting Publicize:
https://github.com/woocommerce/woocommerce/issues/13180

Thanks @jeherve - the problem wouldn't exist though if the publicize settings weren't greyed out. Is this because the original post was already published and thus has a flag for that set, which is then copied?

@arjenlentz Exactly! Since the meta is set already to indicate an existing, published post, the Publicize settings are inactive since that post wouldn't be Publicized again via wp-admin.

@kraftbj that's not actually what happens though, as in fact the copy DOES get publicized when Published (as the original bugreport notes).

@jeherve
And even more "interesting", if you try this with a Product that is not publicized (the social targets unticked, then published), a copy will STILL get publicized!

So aside from the items being greyed out, a) the copied item gets publicized and b) this publicized logic appears to go ahead irrespective of the (greyed out) settings that are present.

@arjenlentz That's indeed the expected behaviour right now: the status of the chexkboxes is managed via post meta data. You consequently can't trust the checkboxes at all when you work with a duplicated product right now.

Once https://github.com/woocommerce/woocommerce/issues/13180 is fixed, we should be able to add a compatibilty function to Jetpack, to avoid duplicating Publicize post meta when duplicating a WooCommerce product. Then you'll be able to trust and use the checkboxes again.

woocommerce_duplicate_product_exclude_meta was added back to WooCommerce in https://github.com/woocommerce/woocommerce/pull/13202, so we could now go ahead and create a new compatibility function in this file to exclude all post meta including the _wpas_ string.

Has there been any movement on this? I'm still seeing the grayed out area and am unable to change anything in the product Publicize area.

@JapeNZ We haven't made any progress on this, but will update this issue when we do so.

@jeherve Any news about this one? We had a question about it in 2694924-zen

@bindlegirl No news yet, but as I mentioned above we'll update this issue once we make progress on this.

Took a look at this just for fun, and I'm not sure of the best approach.

woocommerce_duplicate_product_exclude_meta requires that we define the meta keys to exclude ahead of time, and then it loops through what's given to it and removes those from the duplicate post metadata:

https://github.com/woocommerce/woocommerce/blob/master/includes/admin/class-wc-admin-duplicate-product.php#L153-L155

It doesn't pass the existing metadata through the filter, so it seems like we can't dynamically removing metadata starting with _wpas_?

It might be possible to piggyback on the woocommerce_product_duplicate_before_save action just below though.

It doesn't pass the existing metadata through the filter

That's a good point. It may make sense to open an issue/PR at Woo to add this as a second parameter for the existing filter?

This is possible now that https://github.com/woocommerce/woocommerce/pull/27038 has been merged. We should probably wait until WC 4.4.0 is released first.

@jeherve Do you think this could be now implemented after the above Woo change has been merged? Thank you!
Have another user report here: #25508234-hc

Do you think this could be now implemented after the above Woo change has been merged?

It may be worth a try, yes!

Was this page helpful?
0 / 5 - 0 ratings