Skip to content

Commit

Permalink
Fixing Issue woocommerce#10523 - Variations ID lookup by SKU
Browse files Browse the repository at this point in the history
I copied the code from the bulk() function to look up the Variation ID by the Variation SKU if the Variation ID is missing.
  • Loading branch information
torrelasley committed Mar 10, 2016
1 parent 29d3515 commit e9c3a36
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions includes/api/class-wc-api-products.php
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,11 @@ protected function save_variations( $id, $data ) {
foreach ( $variations as $menu_order => $variation ) {
$variation_id = isset( $variation['id'] ) ? absint( $variation['id'] ) : 0;

if ( ! $variation_id && isset( $variation['sku'] ) ) {
$variation_sku = wc_clean( $variation['sku'] );
$variation_id = wc_get_product_id_by_sku( $variation_sku );
}

// Generate a useful post title
$variation_post_title = sprintf( __( 'Variation #%s of %s', 'woocommerce' ), $variation_id, esc_html( get_the_title( $id ) ) );

Expand Down

0 comments on commit e9c3a36

Please sign in to comment.