Woocommerce multilingual bug on multisite install
-
the hook bellow causes fatal error for products saved on a different blog then the blog that the ajax hook runs
Hooks::onAction( ‘shutdown’ )
->then( function() use ( $productId ) {
// For direct updates, we adjust terms filters just before triggering the update.
$hasTermsClausesFilter = $this->adjustTermsFilters();wc_get_container()->get( ProductAttributesLookupDataStore::class )->on_product_changed( $productId );
$this->restoreTermsFilters( $hasTermsClausesFilter );
} );We use an ajax hook on blog id (1) where we process products on different blogs (2) and call product->save
This will register the product hook from Woocommerce multilingual on the wrong blog and that causes a fatal error as the product doesn’t exist on blog (1)add_action(‘wp_ajax_blog_1’, function(){
// we are on blog 1 hereswitch_to_blog(2); // switched to blog 2
//create a product here
//add attributes, and other data
$product->save()
restore_current_blog();echo “success”; //return a response to ajax
wp_die(); //your hook from above runs here on blog(1) searching for product 190 from blog(2) saved above. This causes a fatal error and javascript breakes because the product doesnt exist on blog(1)
});
- The topic ‘Woocommerce multilingual bug on multisite install’ is closed to new replies.