Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
If you're experiencing an issue where creating lotteries from the Dokan frontend results in the product being created as a "Simple product" instead of a "Lottery" product type when WooCommerce Multilingual & Multicurrency is enabled, it might be due to a compatibility or conflict issue.

Solution:
First, check for any errors or warnings related to WPML in the WordPress Debug log or Server Error Log. To enable WP debug log, edit your

wp-config.php

file:

define('WP_DEBUG', true);<br />define('WP_DEBUG_LOG', true);<br />define('WP_DEBUG_DISPLAY', false);<br />@ini_set('display_errors',0);

Then, replicate the issue with WCML enabled and test creating products both with and without using Dokan to determine if the issue is with Lottery, Dokan, or both.

We have found a workaround involving the cache and product lookup tables. When inserting a new product, the default product type is 'simple' due to the cache. Purging the cache group 'products' changes the product type to 'lottery'. Here's a proof of concept fix to add to your theme's functions.php:

add_action( 'wp_insert_post', 'purge_product_cache', 9, 1 );<br /><br />function purge_product_cache( $product ) {<br />    if ( get_post_type( $product ) == "product" ) {<br />        wp_cache_flush_group( 'products' );<br />    }<br />}

Please try this solution and let us know if it resolves the issue.

If this solution doesn't look relevant, please open a new support ticket.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 14 replies, has 2 voices.

Last updated by Ilyes 1 year, 8 months ago.

Assisted by: Ilyes.

Author Posts
November 13, 2023 at 10:55 am #14787607

Никита Мороз

Great support! Thank you!