Merge pull request #3569 from thenbrent/non_static_variable_product_sync
Backward compatible variable_product_sync()
This commit is contained in:
commit
a5760fc19b
|
@ -829,7 +829,7 @@ function process_product_meta_variable( $post_id ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update parent if variable so price sorting works and stays in sync with the cheapest child
|
// Update parent if variable so price sorting works and stays in sync with the cheapest child
|
||||||
WC_Product_Variable::variable_product_sync( $post_id );
|
WC_Product_Variable::sync( $post_id );
|
||||||
|
|
||||||
// Update default attribute options setting
|
// Update default attribute options setting
|
||||||
$default_attributes = array();
|
$default_attributes = array();
|
||||||
|
|
|
@ -463,7 +463,19 @@ class WC_Product_Variable extends WC_Product {
|
||||||
/**
|
/**
|
||||||
* Sync variable product prices with the children lowest/highest prices.
|
* Sync variable product prices with the children lowest/highest prices.
|
||||||
*/
|
*/
|
||||||
public static function variable_product_sync( $product_id ) {
|
public function variable_product_sync( $product_id = '' ) {
|
||||||
|
|
||||||
|
if ( empty( $product_id ) )
|
||||||
|
$product_id = $this->id;
|
||||||
|
|
||||||
|
self::sync( $product_id );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sync variable product prices with the children lowest/highest prices.
|
||||||
|
*/
|
||||||
|
public static function sync( $product_id ) {
|
||||||
$children = get_posts( array(
|
$children = get_posts( array(
|
||||||
'post_parent' => $product_id,
|
'post_parent' => $product_id,
|
||||||
'posts_per_page'=> -1,
|
'posts_per_page'=> -1,
|
||||||
|
|
Loading…
Reference in New Issue