Last active
July 15, 2020 05:48
-
-
Save alewolf/5d933417e35a3d7585b96e2ada9f2e05 to your computer and use it in GitHub Desktop.
resync variable product in WooCommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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