diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/layouts/scripts.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/layouts/scripts.blade.php index e9d89ff52..8e73e3173 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/layouts/scripts.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/layouts/scripts.blade.php @@ -22,6 +22,34 @@ /* add translations */ window._translations = @json($velocityHelper->jsonTranslations()); })(); + + /** + * Wishist form will dynamically create and execute. + * + * @param {!string} action + * @param {!string} method + * @param {!string} csrfToken + */ + function submitWishlistForm(action, method, csrfToken) { + let form = document.createElement('form'); + form.method = 'POST'; + form.action = action; + + let _methodElement = document.createElement('input'); + _methodElement.type = 'hidden'; + _methodElement.name = '_method'; + _methodElement.value = method; + form.appendChild(_methodElement); + + let _tokenElement = document.createElement('input'); + _tokenElement.type = 'hidden'; + _tokenElement.name ='_token'; + _tokenElement.value = csrfToken; + form.appendChild(_tokenElement); + + document.body.appendChild(form); + form.submit(); + } @stack('scripts') diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/products/wishlist.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/products/wishlist.blade.php index 17f0cddf9..82967034c 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/products/wishlist.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/products/wishlist.blade.php @@ -14,37 +14,23 @@ $title = $wishlist ? __('velocity::app.shop.wishlist.remove-wishlist-text') : __('velocity::app.shop.wishlist.add-wishlist-text'); @endphp - @if($wishlist) -
- @method('DELETE') - - @csrf -
- @else -
- @csrf -
- @endif - + onclick="submitWishlistForm( + '{{ $href }}', + '{{ $wishlist ? 'DELETE' : 'POST' }}', + '{{ csrf_token() }}' + )" + > @if (isset($text)) {!! $text !!} @endif + @endauth