Skip to content

Instantly share code, notes, and snippets.

@alewolf
Last active July 15, 2020 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alewolf/5d933417e35a3d7585b96e2ada9f2e05 to your computer and use it in GitHub Desktop.
Save alewolf/5d933417e35a3d7585b96e2ada9f2e05 to your computer and use it in GitHub Desktop.
resync variable product in WooCommerce
<?php
/***********************************************************************************************
* This function will automatically resync variable product prices in case the prices don't show
* on the catalogue pages anymore.
*
* Simply place it in functions.php
***********************************************************************************************/
add_filter( 'woocommerce_get_price_html', 'resync_variable_product', 100, 2 );
function resync_variable_product( $price, $product ){
if (empty($price)){
error_log('resyncing variable product ' .$product->get_id());
WC_Product_Variable::sync($product->get_id());
}
return $price;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment