Skip to content

Commit

Permalink
Control Discount Text
Browse files Browse the repository at this point in the history
  • Loading branch information
bdsumon4u committed Apr 24, 2024
1 parent 3d5e14a commit cdac985
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/Http/Requests/SettingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public function rules()
'related_products' => 'required|array',
'scroll_text' => 'nullable',
'show_option' => 'required|array',
'discount_text' => 'required',
'services' => 'required|array',
];
}
Expand Down
9 changes: 8 additions & 1 deletion resources/views/admin/settings/others.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,20 @@
</div>
</div>
<div class="border col-md-12 my-3"></div>
<div class="col-md-12">
<div class="col-md-8">
<div class="form-group">
<label for="">Scroll Text</label>
<x-textarea name="scroll_text" id="scroll_text">{{$scroll_text ?? null}}</x-textarea>
<x-error field="scroll_text" />
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="discount-text">Discount Text</label>
<x-input name="discount_text" id="discount-text" :value="$discount_text ?? '<small>Discount:</small> [percent]%'" />
<small>Short Code: <strong>[percent]</strong></small>
</div>
</div>
<div class="col-6">
<div class="form-group">
<label for="" class="mb-0">Products Page</label>
Expand Down
5 changes: 4 additions & 1 deletion resources/views/livewire/product-card.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
<div class="product-card__badge product-card__badge--sale">Sold</div>
@endif
@if($product->price != $product->selling_price)
<div class="product-card__badge product-card__badge--sale"><small>Discount:</small> {{ round(($product->price - $product->selling_price) * 100 / $product->price, 0, PHP_ROUND_HALF_UP) }}%</div>
<div class="product-card__badge product-card__badge--sale">
@exp($percent = round(($product->price - $product->selling_price) * 100 / $product->price, 0, PHP_ROUND_HALF_UP))
{!! str_replace('[percent]', $percent, setting('discount_text') ?? '<small>Discount:</small> [percent]%') !!}
</div>
@endif
</div>
<div class="product-card__image">
Expand Down

0 comments on commit cdac985

Please sign in to comment.