Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Commit

Permalink
fixes #430 by handling private (disabled) variations
Browse files Browse the repository at this point in the history
 - detects translations correctly by adding 'post_status’ => 'any' to
query
 - on update checks for change of variation post status so that the
variation ‘enabled’ property can be synchronised
  • Loading branch information
Jon007 committed Jun 11, 2019
1 parent 08c9913 commit 7c475b8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Hyyan/WPI/Product/Variation.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public function duplicate()
'meta_key' => self::DUPLICATE_KEY,
'meta_value' => $variation['variation_id'],
'post_type' => 'product_variation',
'post_status' => 'any',
'post_parent' => $this->to->get_id(),
));
switch (count($posts)) {
Expand Down Expand Up @@ -182,6 +183,11 @@ protected function update(\WC_Product_Variation $variation, \WP_Post $post, arra
{
$this->copyVariationMetas($variation->get_id(), $post->ID);
pll_set_post_language( $post->ID, pll_get_post_language( $post->post_parent ) );
if ( $post->post_status != $variation->get_status() ) {
$destVariation = wc_get_product( $post->ID );
$destVariation->set_status( $variation->get_status() );
$destVariation->save();
}
Utilities::flushCacheUpdateLookupTable( $post->ID );
}
/**
Expand Down

0 comments on commit 7c475b8

Please sign in to comment.