add product script to pages

master
Gustavo Luigi 2022-09-02 11:49:28 +02:00
parent 6610ea0c05
commit 9385bb2f37
4 changed files with 24 additions and 49 deletions

20
assets/js/product.js Normal file
View File

@ -0,0 +1,20 @@
$(window).on('load', function(){
$('#btn-check-out').click(function(){
let productId = $(this).attr("data-id");
addToBag(productId);
window.location.replace($('meta[name="checkout"]').attr('content'));
});
$('#btn-add-to-bag').click(function(){
let productId = $(this).attr("data-id");
let parentElement = $('#count-products-in-bag').parent();
let copyElemetn = $('#count-products-in-bag').clone();
copyElemetn.attr('id', '');
copyElemetn.appendTo(parentElement);
$('#count-products-in-bag').addClass('animate__animated animate__backInUp');
$('#count-products-in-bag').on('animationend', function(){
$('#count-products-in-bag').removeClass('animate__animated animate__backInUp');
copyElemetn.remove();
});
addToBag(productId);
});
});

View File

@ -79,26 +79,5 @@
</div>
@stop
@section('scripts')
<script>
$(window).on('load', function(){
$('#btn-check-out').click(function(){
let productId = $(this).attr("data-id");
addToBag(productId);
window.location.replace("{{url('/checkout')}}");
});
$('#btn-add-to-bag').click(function(){
let productId = $(this).attr("data-id");
let parentElement = $('#count-products-in-bag').parent();
let copyElemetn = $('#count-products-in-bag').clone();
copyElemetn.attr('id', '');
copyElemetn.appendTo(parentElement);
$('#count-products-in-bag').addClass('animate__animated animate__backInUp');
$('#count-products-in-bag').on('animationend', function(){
$('#count-products-in-bag').removeClass('animate__animated animate__backInUp');
copyElemetn.remove();
});
addToBag(productId);
});
});
</script>
@stop
<script src="{{storage('assets/js/product.js')}}"></script>
@stop

View File

@ -84,17 +84,5 @@
</div>
@stop
@section('scripts')
<script>
$(window).on('load', function(){
$('#btn-check-out').click(function(){
let productId = $(this).attr("data-id");
addToBag(productId);
window.location.replace("{{url('/checkout')}}");
});
$('#btn-add-to-bag').click(function(){
let productId = $(this).attr("data-id");
addToBag(productId);
});
});
</script>
<script src="{{storage('assets/js/product.js')}}"></script>
@stop

View File

@ -84,17 +84,5 @@
</div>
@stop
@section('scripts')
<script>
$(window).on('load', function(){
$('#btn-check-out').click(function(){
let productId = $(this).attr("data-id");
addToBag(productId);
window.location.replace("{{url('/checkout')}}");
});
$('#btn-add-to-bag').click(function(){
let productId = $(this).attr("data-id");
addToBag(productId);
});
});
</script>
<script src="{{storage('assets/js/product.js')}}"></script>
@stop