2021-06-05 09:26:32 +00:00
|
|
|
@extends('layouts.main')
|
|
|
|
|
|
|
|
@section('content')
|
|
|
|
<!-- CONTENT HEADER -->
|
|
|
|
<section class="content-header">
|
|
|
|
<div class="container-fluid">
|
|
|
|
<div class="row mb-2">
|
|
|
|
<div class="col-sm-6">
|
2021-12-20 08:20:43 +00:00
|
|
|
<h1>{{ __('Store') }}</h1>
|
2021-06-05 09:26:32 +00:00
|
|
|
</div>
|
|
|
|
<div class="col-sm-6">
|
|
|
|
<ol class="breadcrumb float-sm-right">
|
2023-01-14 22:34:10 +00:00
|
|
|
<li class="breadcrumb-item"><a class="" href="{{ route('home') }}">{{ __('Dashboard') }}</a></li>
|
2021-12-15 14:02:31 +00:00
|
|
|
<li class="breadcrumb-item"><a class="text-muted"
|
2021-12-20 08:20:43 +00:00
|
|
|
href="{{ route('store.index') }}">{{ __('Store') }}</a>
|
2021-12-13 01:48:02 +00:00
|
|
|
</li>
|
2021-06-05 09:26:32 +00:00
|
|
|
</ol>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<!-- END CONTENT HEADER -->
|
|
|
|
|
|
|
|
<!-- MAIN CONTENT -->
|
2023-01-14 22:34:10 +00:00
|
|
|
<section class="content">
|
2021-06-05 09:26:32 +00:00
|
|
|
<div class="container-fluid">
|
2023-05-17 16:17:51 +00:00
|
|
|
<form
|
|
|
|
id="payment_form"
|
|
|
|
action="{{ route('payment.pay') }}"
|
|
|
|
method="POST"
|
|
|
|
x-data="{
|
|
|
|
payment_method: '',
|
|
|
|
coupon_code: '',
|
|
|
|
clicked: false,
|
|
|
|
setCouponCode(event) {
|
|
|
|
this.coupon_code = event.target.value
|
|
|
|
}
|
|
|
|
}"
|
|
|
|
>
|
2023-03-28 13:28:26 +00:00
|
|
|
@csrf
|
|
|
|
@method('post')
|
|
|
|
<div class="row d-flex justify-content-center flex-wrap">
|
|
|
|
@if (!$productIsFree)
|
|
|
|
<div class="col-xl-4">
|
|
|
|
<div class="card">
|
|
|
|
<div class="card-header">
|
|
|
|
<h4 class="mb-0">
|
|
|
|
<i class="fas fa-money-check-alt"></i>
|
|
|
|
Payment Methods
|
2023-01-14 22:34:10 +00:00
|
|
|
</h4>
|
|
|
|
</div>
|
2023-03-28 13:28:26 +00:00
|
|
|
<div class="card-body">
|
2023-03-28 00:00:43 +00:00
|
|
|
<input type="hidden" name="product_id" value="{{ $product->id }}">
|
2023-03-28 13:28:26 +00:00
|
|
|
<input type="hidden" name="payment_method" :value="payment_method"
|
|
|
|
x-model="payment_method">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-lg-12">
|
2023-03-28 00:00:43 +00:00
|
|
|
@foreach ($paymentGateways as $gateway)
|
2023-03-28 13:28:26 +00:00
|
|
|
<div class="row checkout-gateways">
|
|
|
|
<div class="col-12 d-flex justify-content-between">
|
|
|
|
<label class="form-check-label h4 checkout-gateway-label"
|
|
|
|
for="{{ $gateway->name }}">
|
|
|
|
<span class="mr-3">{{ $gateway->name }}</span>
|
|
|
|
</label>
|
|
|
|
<button class="btn btn-primary rounded" type="button"
|
|
|
|
name="payment-method" id="{{ $gateway->name }}"
|
|
|
|
value="{{ $gateway->name }}"
|
|
|
|
:class="payment_method === '{{ $gateway->name }}' ?
|
|
|
|
'active' : ''"
|
|
|
|
@click="payment_method = '{{ $gateway->name }}'; clicked = true;"
|
|
|
|
x-text="payment_method == '{{ $gateway->name }}' ? 'Selected' : 'Select'">Select</button>
|
|
|
|
</button>
|
|
|
|
|
2023-03-28 00:00:43 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
@endforeach
|
|
|
|
</div>
|
2023-03-28 13:28:26 +00:00
|
|
|
</div>
|
2023-03-28 00:00:43 +00:00
|
|
|
</div>
|
2023-03-28 13:28:26 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-05-19 15:00:30 +00:00
|
|
|
@if ($isCouponsEnabled)
|
|
|
|
<div class="col-xl-4">
|
|
|
|
<div class="card">
|
|
|
|
<div class="card-header">
|
|
|
|
<h4 class="mb-0">
|
|
|
|
Coupon Code
|
|
|
|
</h4>
|
2023-05-17 16:17:51 +00:00
|
|
|
</div>
|
2023-05-19 15:00:30 +00:00
|
|
|
<div class="card-body">
|
|
|
|
<div class="d-flex">
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="coupon_code"
|
|
|
|
name="coupon_code"
|
|
|
|
value="{{ old('coupon_code') }}"
|
|
|
|
:value="coupon_code"
|
|
|
|
class="form-control @error('coupon_code') is_invalid @enderror"
|
|
|
|
placeholder="SUMMER"
|
|
|
|
x-on:change.debounce="setCouponCode($event)"
|
|
|
|
x-model="coupon_code"
|
|
|
|
/>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
id="send_coupon_code"
|
|
|
|
class="btn btn-success ml-3"
|
|
|
|
:disabled="!coupon_code.length"
|
|
|
|
:class="!coupon_code.length ? 'disabled' : ''"
|
|
|
|
:value="coupon_code"
|
|
|
|
>
|
|
|
|
{{ __('Submit') }}
|
|
|
|
</button>
|
2023-05-17 16:17:51 +00:00
|
|
|
</div>
|
2023-05-19 15:00:30 +00:00
|
|
|
@error('coupon_code')
|
|
|
|
<div class="text-danger">
|
|
|
|
{{ $message }}
|
|
|
|
</div>
|
|
|
|
@enderror
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
@endif
|
2023-03-28 13:28:26 +00:00
|
|
|
@endif
|
|
|
|
<div class="col-xl-3">
|
|
|
|
<div class="card">
|
|
|
|
<div class="card-header">
|
|
|
|
<h4 class="mb-0 text-center">
|
|
|
|
<i class="fas fa-shopping-cart"></i>
|
|
|
|
Checkout details
|
|
|
|
</h4>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="card-body">
|
|
|
|
<ul class="list-group mb-3">
|
|
|
|
<li class="list-group-item">
|
|
|
|
<div>
|
|
|
|
<h5 class="my-0">{{ __('Product details') }}</h5>
|
|
|
|
</div>
|
|
|
|
<ul class="pl-0">
|
|
|
|
<li class="d-flex justify-content-between">
|
|
|
|
<span class="text-muted d-inline-block">{{ __('Type') }}</span>
|
|
|
|
<span
|
|
|
|
class="text-muted d-inline-block">{{ strtolower($product->type) == 'credits' ? $credits_display_name : $product->type }}</span>
|
|
|
|
</li>
|
|
|
|
<li class="d-flex justify-content-between">
|
|
|
|
<span class="text-muted d-inline-block">{{ __('Amount') }}</span>
|
|
|
|
<span class="text-muted d-inline-block">{{ $product->quantity }}</span>
|
|
|
|
</li>
|
|
|
|
<li class="d-flex justify-content-between">
|
|
|
|
<span class="text-muted d-inline-block">{{ __('Total Amount') }}</span>
|
|
|
|
<span class="text-muted d-inline-block">{{ $product->quantity }}</span>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="list-group-item d-flex justify-content-between lh-condensed">
|
|
|
|
<div>
|
|
|
|
<h6 class="my-0">{{ __('Description') }}</h6>
|
|
|
|
<span class="text-muted">
|
|
|
|
{{ $product->description }}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li class="list-group-item">
|
|
|
|
<div>
|
|
|
|
<h5 class="my-0">{{ __('Pricing') }}</h5>
|
|
|
|
</div>
|
2023-01-14 22:34:10 +00:00
|
|
|
|
2023-03-28 13:28:26 +00:00
|
|
|
<ul class="pl-0">
|
|
|
|
<li class="d-flex justify-content-between">
|
|
|
|
<span class="text-muted d-inline-block">{{ __('Subtotal') }}</span>
|
|
|
|
<span class="text-muted d-inline-block">
|
|
|
|
{{ $product->formatToCurrency($discountedprice) }}</span>
|
|
|
|
</li>
|
|
|
|
<div class="d-flex justify-content-between">
|
|
|
|
<span class="text-muted d-inline-block">{{ __('Tax') }}
|
|
|
|
@if ($taxpercent > 0)
|
|
|
|
({{ $taxpercent }}%):
|
|
|
|
@endif
|
|
|
|
</span>
|
|
|
|
<span class="text-muted d-inline-block">
|
|
|
|
+ {{ $product->formatToCurrency($taxvalue) }}</span>
|
|
|
|
</div>
|
2023-05-17 16:17:51 +00:00
|
|
|
<div id="coupon_discount_details" class="d-flex justify-content-between" style="display: none !important;">
|
|
|
|
<span class="text-muted d-inline-block">
|
|
|
|
{{ __('Coupon Discount') }}
|
2023-05-18 01:13:10 +00:00
|
|
|
</span>
|
|
|
|
<span id="coupon_discount_value" class="text-muted d-inline-block">
|
2023-05-17 16:17:51 +00:00
|
|
|
|
|
|
|
</span>
|
|
|
|
</div>
|
2023-01-14 22:34:10 +00:00
|
|
|
@if ($discountpercent && $discountvalue)
|
2023-03-28 13:28:26 +00:00
|
|
|
<div class="d-flex justify-content-between">
|
|
|
|
<span class="text-muted d-inline-block">{{ __('Discount') }}
|
|
|
|
({{ $discountpercent }}%):</span>
|
|
|
|
<span
|
|
|
|
class="text-muted d-inline-block">-{{ $product->formatToCurrency($discountvalue) }}</span>
|
|
|
|
</div>
|
2023-01-14 22:34:10 +00:00
|
|
|
@endif
|
2023-03-28 13:28:26 +00:00
|
|
|
<hr class="text-white border-secondary">
|
|
|
|
<div class="d-flex justify-content-between">
|
|
|
|
<span class="text-muted d-inline-block">{{ __('Total') }}</span>
|
2023-05-18 01:13:10 +00:00
|
|
|
<input id="total_price_input" type="hidden" value="{{ $product->getTotalPrice() }}">
|
2023-03-28 13:28:26 +00:00
|
|
|
<span
|
2023-05-18 01:13:10 +00:00
|
|
|
id="total_price"
|
|
|
|
class="text-muted d-inline-block"
|
|
|
|
>
|
|
|
|
{{ $product->formatToCurrency($total) }}
|
|
|
|
</span>
|
2023-03-28 13:28:26 +00:00
|
|
|
</div>
|
|
|
|
<template x-if="payment_method">
|
|
|
|
<div class="d-flex justify-content-between">
|
|
|
|
<span class="text-muted d-inline-block">{{ __('Pay with') }}</span>
|
|
|
|
<span class="text-muted d-inline-block" x-text="payment_method"></span>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
</ul>
|
2021-06-05 09:26:32 +00:00
|
|
|
|
2023-05-17 16:17:51 +00:00
|
|
|
<button :disabled="(!payment_method || !clicked || coupon_code ? true : false) && {{ !$productIsFree }}"
|
|
|
|
id="submit_form_button"
|
|
|
|
:class="(!payment_method || !clicked || coupon_code ? true : false) && {{ !$productIsFree }} ? 'disabled' : ''"
|
|
|
|
:x-text="coupon_code"
|
2023-03-28 13:28:26 +00:00
|
|
|
class="btn btn-success float-right w-100">
|
2023-05-17 16:17:51 +00:00
|
|
|
|
2023-03-28 13:28:26 +00:00
|
|
|
<i class="far fa-credit-card mr-2" @click="clicked == true"></i>
|
|
|
|
@if ($productIsFree)
|
|
|
|
{{ __('Get for free') }}
|
|
|
|
@else
|
|
|
|
{{ __('Submit Payment') }}
|
|
|
|
@endif
|
|
|
|
|
|
|
|
</button>
|
2023-05-17 16:17:51 +00:00
|
|
|
<script>
|
|
|
|
</script>
|
2021-06-05 09:26:32 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-03-28 13:28:26 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
2021-06-05 09:26:32 +00:00
|
|
|
</div>
|
2023-03-28 13:28:26 +00:00
|
|
|
|
2021-06-05 09:26:32 +00:00
|
|
|
</section>
|
|
|
|
<!-- END CONTENT -->
|
2023-05-17 16:17:51 +00:00
|
|
|
|
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
2023-05-18 01:13:10 +00:00
|
|
|
const productId = $("[name='product_id']").val()
|
2023-05-17 16:17:51 +00:00
|
|
|
let hasCouponCodeValue = $('#coupon_code').val().trim() !== ''
|
|
|
|
|
|
|
|
$('#coupon_code').on('change', function(e) {
|
|
|
|
hasCouponCodeValue = e.target.value !== ''
|
|
|
|
})
|
|
|
|
|
2023-05-18 01:13:10 +00:00
|
|
|
function calcPriceWithCouponDiscount(couponValue, couponType) {
|
|
|
|
let totalPrice = $('#total_price_input').val()
|
|
|
|
|
|
|
|
if (typeof totalPrice == 'string') {
|
|
|
|
totalPrice = parseFloat(totalPrice)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (couponType === 'percentage') {
|
|
|
|
totalPrice = totalPrice - (totalPrice * couponValue / 100)
|
|
|
|
$('#coupon_discount_value').text("- " + couponValue + "%")
|
|
|
|
} else if (couponType === 'amount') {
|
|
|
|
totalPrice = totalPrice - couponValue
|
|
|
|
$('#coupon_discount_value').text(totalPrice)
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#total_price').text(totalPrice)
|
|
|
|
$('#total_price_input').val(totalPrice)
|
|
|
|
}
|
|
|
|
|
2023-05-17 16:17:51 +00:00
|
|
|
function checkCoupon() {
|
|
|
|
const couponCode = $('#coupon_code').val()
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url: "{{ route('admin.coupon.redeem') }}",
|
|
|
|
method: 'POST',
|
2023-05-18 01:13:10 +00:00
|
|
|
data: { couponCode: couponCode, productId: productId },
|
2023-05-17 16:17:51 +00:00
|
|
|
success: function(response) {
|
|
|
|
if (response.isValid && response.couponCode) {
|
|
|
|
Swal.fire({
|
|
|
|
icon: 'success',
|
2023-05-18 01:13:10 +00:00
|
|
|
text: 'The coupon was successfully added to your purchase.',
|
2023-05-17 16:17:51 +00:00
|
|
|
}).then(function(isConfirmed) {
|
2023-05-18 01:13:10 +00:00
|
|
|
calcPriceWithCouponDiscount(response.couponValue, response.couponType)
|
2023-05-17 16:17:51 +00:00
|
|
|
$('#submit_form_button').prop('disabled', false).removeClass('disabled')
|
|
|
|
$('#send_coupon_code').prop('disabled', true)
|
|
|
|
$('#coupon_discount_details').prop('disabled', false).show()
|
|
|
|
})
|
|
|
|
|
|
|
|
} else {
|
|
|
|
console.log('Invalid Coupon')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error: function(response) {
|
|
|
|
const responseJson = response.responseJSON
|
|
|
|
|
|
|
|
if (!responseJson.isValid) {
|
|
|
|
Swal.fire({
|
|
|
|
icon: 'error',
|
|
|
|
title: 'Oops...',
|
|
|
|
text: responseJson.error,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#payment_form').on('submit', function(e) {
|
|
|
|
if (hasCouponCodeValue) {
|
|
|
|
checkCoupon()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
$('#send_coupon_code').click(function(e) {
|
|
|
|
if (hasCouponCodeValue) {
|
|
|
|
checkCoupon()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
</script>
|
2023-01-14 22:34:10 +00:00
|
|
|
@endsection
|