| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\App\Events; |
| 4 |
|
| 5 |
use FluentCart\App\Listeners\UpdateDefaultVariation; |
| 6 |
|
| 7 |
/** |
| 8 |
* Fired when a product's variation set changes in a way that can invalidate its |
| 9 |
* default_variation_id — combinations regenerated/removed, or a variant set |
| 10 |
* active/inactive. Distinct from StockChanged (which is broad and currently |
| 11 |
* carries no default listener) so this stays scoped to variant-set mutations. |
| 12 |
* UpdateDefaultVariation re-resolves the default to the first purchasable |
| 13 |
* combination; works for every variation type. |
| 14 |
*/ |
| 15 |
class ProductVariationsChanged extends EventDispatcher |
| 16 |
{ |
| 17 |
public string $hook = 'fluent_cart/product_variations_changed'; |
| 18 |
|
| 19 |
protected array $listeners = [ |
| 20 |
UpdateDefaultVariation::class, |
| 21 |
]; |
| 22 |
|
| 23 |
/** |
| 24 |
* @var array $postIds |
| 25 |
*/ |
| 26 |
public $postIds; |
| 27 |
|
| 28 |
public function __construct($postIds) |
| 29 |
{ |
| 30 |
$this->postIds = $postIds; |
| 31 |
} |
| 32 |
|
| 33 |
public function toArray(): array |
| 34 |
{ |
| 35 |
return [ |
| 36 |
'post_ids' => $this->postIds, |
| 37 |
]; |
| 38 |
} |
| 39 |
|
| 40 |
public function getActivityEventModel() |
| 41 |
{ |
| 42 |
return null; |
| 43 |
} |
| 44 |
|
| 45 |
public function shouldCreateActivity(): bool |
| 46 |
{ |
| 47 |
return false; |
| 48 |
} |
| 49 |
} |
| 50 |
|