| @@ 1312-1332 (lines=21) @@ | ||
| 1309 | $clear_parent_ids[] = $product_id; |
|
| 1310 | } |
|
| 1311 | ||
| 1312 | if ( ! empty( $clear_parent_ids ) ) { |
|
| 1313 | foreach ( $clear_parent_ids as $clear_id ) { |
|
| 1314 | ||
| 1315 | $children_by_price = get_posts( array( |
|
| 1316 | 'post_parent' => $clear_id, |
|
| 1317 | 'orderby' => 'meta_value_num', |
|
| 1318 | 'order' => 'asc', |
|
| 1319 | 'meta_key' => '_price', |
|
| 1320 | 'posts_per_page' => 1, |
|
| 1321 | 'post_type' => 'product', |
|
| 1322 | 'fields' => 'ids' |
|
| 1323 | ) ); |
|
| 1324 | ||
| 1325 | if ( $children_by_price ) { |
|
| 1326 | foreach ( $children_by_price as $child ) { |
|
| 1327 | $child_price = get_post_meta( $child, '_price', true ); |
|
| 1328 | update_post_meta( $clear_id, '_price', $child_price ); |
|
| 1329 | } |
|
| 1330 | } |
|
| 1331 | } |
|
| 1332 | } |
|
| 1333 | } |
|
| 1334 | ||
| 1335 | // Sold Individually |
|
| @@ 1111-1131 (lines=21) @@ | ||
| 1108 | $clear_parent_ids[] = $product->id; |
|
| 1109 | } |
|
| 1110 | ||
| 1111 | if ( ! empty( $clear_parent_ids ) ) { |
|
| 1112 | foreach ( $clear_parent_ids as $clear_id ) { |
|
| 1113 | ||
| 1114 | $children_by_price = get_posts( array( |
|
| 1115 | 'post_parent' => $clear_id, |
|
| 1116 | 'orderby' => 'meta_value_num', |
|
| 1117 | 'order' => 'asc', |
|
| 1118 | 'meta_key' => '_price', |
|
| 1119 | 'posts_per_page' => 1, |
|
| 1120 | 'post_type' => 'product', |
|
| 1121 | 'fields' => 'ids' |
|
| 1122 | ) ); |
|
| 1123 | ||
| 1124 | if ( $children_by_price ) { |
|
| 1125 | foreach ( $children_by_price as $child ) { |
|
| 1126 | $child_price = get_post_meta( $child, '_price', true ); |
|
| 1127 | update_post_meta( $clear_id, '_price', $child_price ); |
|
| 1128 | } |
|
| 1129 | } |
|
| 1130 | } |
|
| 1131 | } |
|
| 1132 | } |
|
| 1133 | ||
| 1134 | // Sold individually. |
|
| @@ 1038-1059 (lines=22) @@ | ||
| 1035 | $clear_parent_ids[] = absint( $_POST['previous_parent_id'] ); |
|
| 1036 | } |
|
| 1037 | ||
| 1038 | if ( ! empty( $clear_parent_ids ) ) { |
|
| 1039 | foreach ( $clear_parent_ids as $clear_id ) { |
|
| 1040 | $children_by_price = get_posts( array( |
|
| 1041 | 'post_parent' => $clear_id, |
|
| 1042 | 'orderby' => 'meta_value_num', |
|
| 1043 | 'order' => 'asc', |
|
| 1044 | 'meta_key' => '_price', |
|
| 1045 | 'posts_per_page' => 1, |
|
| 1046 | 'post_type' => 'product', |
|
| 1047 | 'fields' => 'ids' |
|
| 1048 | ) ); |
|
| 1049 | ||
| 1050 | if ( $children_by_price ) { |
|
| 1051 | foreach ( $children_by_price as $child ) { |
|
| 1052 | $child_price = get_post_meta( $child, '_price', true ); |
|
| 1053 | update_post_meta( $clear_id, '_price', $child_price ); |
|
| 1054 | } |
|
| 1055 | } |
|
| 1056 | ||
| 1057 | wc_delete_product_transients( $clear_id ); |
|
| 1058 | } |
|
| 1059 | } |
|
| 1060 | } |
|
| 1061 | ||
| 1062 | // Sold Individually |
|