diff --git a/src/Actions/HarvestReviews.php b/src/Actions/HarvestReviews.php index 514d072..01d708d 100644 --- a/src/Actions/HarvestReviews.php +++ b/src/Actions/HarvestReviews.php @@ -9,6 +9,7 @@ use Statamic\Entries\Entry as StatamicEntry; use Statamic\Facades\Entry; use Statamic\Facades\GlobalSet; +use Statamic\Facades\Site; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; class HarvestReviews @@ -133,7 +134,7 @@ protected function saveReviews(?array $reviews) 'name' => $review['client']['name'], 'questions' => $questions, 'product' => $review['product'], - ], $review['id'], 'default'); + ], $review['id'], Site::default()->handle()); } } @@ -143,16 +144,18 @@ protected function updateTotals() return; } + $site = Site::default()->handle(); + $average_score = round($this->totalScore / $this->totalCount, 1); $recommendation_percentage = round($this->totalRecommends / $this->totalCount * 100); $set = GlobalSet::findByHandle('reviews'); - if (! $set || ! $set->localizations()['default']) { + if (! $set || ! $set->localizations()[$site]) { return; } - $set->localizations()['default']->average_score = $average_score; - $set->localizations()['default']->recommendation_percentage = $recommendation_percentage; + $set->localizations()[$site]->average_score = $average_score; + $set->localizations()[$site]->recommendation_percentage = $recommendation_percentage; $set->save(); Cache::forget('feedback-company-data');