Skip Navigation

[Resolved] Error by sync of woocommerce products with WC Multistore Plugin

This support ticket is created 5 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 11 replies, has 2 voices.

Last updated by Beda 5 years, 4 months ago.

Assisted by: Beda.

Author
Posts
#1279911

I am trying to: Syn Woocommerce Products between two of my sites which form part of a WP multisite network.

Link to a page where the issue can be seen: (it can be seen only in the backend as the sync option is available cnly for the admin)

I expected to see: The plugin should sync the products

Instead, I got: following error:

Fatal error: Uncaught InvalidArgumentException: incorrect post type in /homepages/9/d694407619/htdocs/costabravafun/wp-content/plugins/types/vendor/toolset/toolset-common/inc/autoloaded/field/group/post.php:69 Stack trace: #0 /homepages/9/d694407619/htdocs/costabravafun/wp-content/plugins/types/application/models/field/group/repeatable/service.php(605): Toolset_Field_Group_Post->__construct(Object(WP_Post)) #1 /homepages/9/d694407619/htdocs/costabravafun/wp-content/plugins/types/vendor/toolset/toolset-common/inc/autoloaded/field/group/post_factory.php(381): Types_Field_Group_Repeatable_Service->group_contains_rfg_or_prf(3043) #2 [internal function]: Toolset_Field_Group_Post_Factory->{closure}(Object(OTGS\Toolset\Common\Field\Group\GroupDisplayResult)) #3 /homepages/9/d694407619/htdocs/costabravafun/wp-content/plugins/types/vendor/toolset/toolset-common/inc/autoloaded/field/group/post_factory.php(258): array_filter(Array, Object(Closure)) #4 /homepages/9/d694407619/htdocs/costabravafun/wp-content/plugins/types/vendor/tools in /homepages/9/d694407619/htdocs/costabravafun/wp-content/plugins/types/vendor/toolset/toolset-common/inc/autoloaded/field/group/post.php on line 69

#1280019

I am not sure why a Synchronization of WooCommerce Products would scan or use Toolset Types contents, as that is unrelated, the Sync Plugin you use should likely not index other Types (repeatable field groups as it seems here).

However, I need to analyse this locally to understand what's happening and how we can solve it or if we need to contact the 3rd party who produces the Sync plugin.

Can you elaborate on what steps I need to take to have this issue happening?

The line with the error in Toolset is prepared for errors:
throw new InvalidArgumentException( 'incorrect post type' );

Hence, if reached, clearly something is done wrong or going wrong, it's not an unexpected error, it happens when there is a calculable mistake in the process.
It happens when the code is executed on items that are not the current Field (Repeating Field) item.
It should never get invoked on a sync process of a third party, which makes me suspect they try to sync other things than products only.

Do you have Repeatable Field Groups assigned to the Products and maybe the Sync plugin offers to also sync Metadata?
That may be a problem because Repeatable Field Groups technically are Posts, not Fields (Posts with Fields attached to Posts, truly).
So the Sync could literally try to sync something it cannot handle as it expects metadata but gets under the hood post data.
But these are just speculations, please can you provide me steps (and if required the 3rd party software download link) to replicate this?

Thank you!

#1280305

Hello Beda, Thank you very much for you answer.

To have this issue happeing you simply need to try to syncronize a product:

Multisite Dashboard > My Sites > Network Admin > Dashboard

Then:

> WooComerce > Products

There:

Search for a product that is not syncronized (the first column in the products list shows the sites on which the products are syncronized - choode a product with only one site in that column) and start editing the product.

> Edit product > Product data > Multistore (tab) > Publish to > // checkbox for the other site // > Update

This is where the error occurs

By editig the product you will notice that I add 2 WooCommerce Views filter fields to the Products (Image #2 and Localization /required field/).
Apart of that I allow to mark the relationship with another custom Post Type (in that case Providers)

The most important is that: This error does not completely stop the plugin form synchonizing the product. After the action the product is visible in the other shop - it is not fully synchronized though. A big part of the information is missing.

I know that the plugin which is responsable for the synchronization work because as soon as I use the Quick Edit (ajax edit) option to synchronize the product is does synchronize the the product perfectly and with all the details.

The synchronizing plugin is: hidden link

I believe that the plugin does synch the metadata as well.

#1281749

I think this is the issue:
"Apart of that I allow to mark the relationship with another custom Post Type (in that case Providers)"

I think if the WooCommerce Products are synced with that software it does (logically) not use the Toolset API to get those posts. But that is required, as Toolset Related posts can only be received by Toolset API.
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/

Somehow, it seems to feed our code with some data which makes it expect to be dealing with a relationship, however that's false and hence the error.

Toolset data can NOT be used multisite wide. Just like any other content on WordPress, it will be unique to the subsite of the network
Hence, Toolset does not have to support syncing to other subsites, but also, it should not be failing when another software tries to sync non-Toolset data. However, that software also has to exclude eventual calls to non-supported data.

To confirm this compatibility problem, I need to replicate this locally and then send it to our developers or contact the 3rd party to fix this.

Can you help me with the precise steps I need to take locally since duplicating a Multisite in this case is rather time-costly?

I understand I need to install this plugin hidden link, on a Multisite where Toolset Types also creates a relationship to the products, on all involved subsites.
Then I'd need to sync the products as you outlined before.

Please, can you confirm or correct my above steps and if possible, add a copy of the hidden link?

I enabled private answer fields for this.

#1285449
#1285453

Hello Beda,

Thank you for your reply and support.
In order to reproduce the error you should:
Install this plugin hidden link, on a Multisite where Toolset Types
Add some custom Woocommerce Views Fields and a Relationship to the parent product.
Then try to sync the products to a shop on another site which forms part of the WP Multisite.

I don't think that this error is stricktly related with the Relationships as I have deleted the relationship and the error continued to occure.

#1285455

Hmmm, you use another plugin than https://toolset.com/forums/topic/fatal-php-error-if-i-broadcast-articles-to-other-sites-multisite/ or https://toolset.com/forums/topic/as-editor-publish-post-fatal-error-invalid-post-type/.
However, the error is the same, interesting.

I'll need a copy of the plugin, as it's paid.
I have enabled a private reply so you can provide a fresh copy of it.

The error might happen even if there is no relationship, this is correct if it fires that part of the code for some reason.

#1285461
#1285479

Thank you.
Meanwhile, I had some findings on the other issue which is the same but another plugin and I found that it's due to Custom Fields being synced - not even relationships.
As soon there where Types fields, the 3rd party (which has integration for Toolset, of which we were not aware of) tries to grab the Toolset data as well and somewhere there, returns a "revision" post type instead of a "wpcf-post-group"

It might be the same in your case, which would explain why no relationship is needed at all.

I am off soon but will try to see if this is the same on your install.
I am then off until next Tuesday but will afterwards ensure it gets escalated to the Developers, on either side.

The plugin woocommerce-multistore may not be doing the same actions as the other software but seems to trigger the same exception and that is always due to passing the wrong post type as Post Field Group.
Remains to find out why this happens 🙂

Thank you for the copy of the plugin, I will feedback here the findings.

#1289483

I cannot test this plugin (WooCommerce Multistore plugin is inactive, please enter your Licence Key).

Hence I also have less chance to debug this, as online that's not possible.

I need a working version of the plugin, is it possible to register "wordpress.mamp" somehow as valid site for the plugin and share with me a key?
Otherwise, can you contact the author of that plugin, and ask them how this can be done?

I can also contact them separately, asking for instructions on how to test the plugin without buying it.
But I would need the contact of the author (email) which is not stored in the Plugins head file... can you maybe put me in contact?

#1290933

I would need to activate the plugin, as otherwise, I cannot determine the issue.

Can you help me with this?

#1296695

Hello Beda,

Sorry for the delay. I was out of office due to a work travel.
I have only one licence key for the plugin - it's in use on my testing enviorment.

I wiil check with the developer of the plugin if there is any possibility to get another key for testing purposes.. I will get back to you asap.

Best regards,

Lukasz

#1296705

Yes, please.

You can also add the developers contact details in the next reply so I can reach out as well if you would like me to.

We usually offer some perks back in turn (free Toolset, or so), to Developers who we cooperate with. This might encourage to share such keys needed for proper working plugins (and its debugging 🙂 )

I have enabled a private reply in case there is a chance for you to get such key and eventually contact details to the authors.