discount cart rules

This commit is contained in:
merdan 2022-11-17 16:08:28 +05:00
parent d3a47e0949
commit 30eea44d48
1 changed files with 6 additions and 4 deletions

View File

@ -13,14 +13,16 @@ class CartRuleResource extends JsonResource
public function toArray($request): array
{
$is_fixed = str_contains($this->action_type,'fixed');
return [
'id' => $this->id,
'name' => $this->name,
'description' => $this->description,
'action_type' => $this->action_type,
'amount' => str_contains($this->action_type,'fixed')?
core()->formatPrice($this->discount_amount, $this->currency):
$this->discount_amount.'%'
'is_fixed' => $is_fixed,
'is_discount' => $this->discount_amoun >0,
'amount' => (double) ($is_fixed ?
core()->convertPrice($this->discount_amount, $this->currency):
$this->discount_amount)
];
}