xah

Catalogue Price Estimator

xah
Jul 12th, 2021 (edited)
1,670
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.74 KB | None | 0 0
  1. <div class="pr-5 w-full grid grid-cols-1 max-w-5xl md:grid-cols-2 xl:grid-cols-4 2xl:grid-cols-6 gap-4">
  2.         @foreach($variables['all_items'] as $variable)
  3.             <x-product-card class="cursor-pointer" src="{{ asset($variable->image_url) }}" id="{{ $variable->id }}" x-on:click="{productBoxOpen=true, alt='{{ $variable->name }}', img='{{ asset($variable->image_url) }}'}">  
  4.                 <x-slot name="brand">{{ explode(" ", $variable->brand_name()->first()->Name)[0] }}</x-slot>
  5.                 <x-slot name="category">{{ explode(" ", $variable->category_name()->first()->Name)[0] }}</x-slot>
  6.                 <x-slot name="title">
  7.                     <h2 class="text-xl font-medium leading-6 tracking-wide text-gray-800 hover:text-black cursor-pointer" x-on:click="{document.getElementById('{{ $variable->id }}').click()}">
  8.                         {{ $variable->name }}
  9.                     </h2>
  10.                 </x-slot>
  11.                 <x-slot name="search">
  12.                     <x-svg.search class="w-5 h-5 cursor-pointer" x-on:click="{document.getElementById('{{ $variable->id }}').click()}"></x-svg.search>
  13.                 </x-slot>
  14.                     {{ $variable->description }}
  15.                 <x-slot name="price">
  16.                     ${{ $variable->unit_price }} + GST
  17.                 </x-slot>
  18.                 <x-slot name="basket">
  19.                     <div class="flex items-center space-x-1 cursor-pointer" :class="'{{ $variable->name }}' in shopping_cart ? 'text-gray-800' : 'text-gray-400 hover:text-gray-800'" x-on:click="{alt='{{ $variable->name }}', alt in shopping_cart ? delete shopping_cart[alt] : shopping_cart[alt] = {'quantity': 1, 'price': {{ $variable->unit_price }}, 'id': {{ $variable->id }}, 'total_price': {{ $variable->unit_price }} }}">
  20.                         <x-svg.basket class="h-5 w-5"></x-svg.basket>
  21.                     </div>
  22.                 </x-slot>
  23.             </x-product-card>
  24.         @endforeach
  25.     </div>
  26.  
  27.     <div @click.away="showPriceEstimator = false" class="fixed bottom-0 right-0 w-96 px-5 bg-white border-t-2 border-l-2 border-orange-500 max-h-screen overflow-y-auto">
  28.         <div class="grid grid-cols-1 divide-y-2 divide-orange-300">
  29.             <div>
  30.                 <x-svg.basket class="w-5 h-5 my-5 float-left"></x-svg.basket>
  31.                 <div class="float-left px-2 py-5">
  32.                     <button class="float-left hover:text-red-500" x-on:click="showPriceEstimator = !showPriceEstimator">Price Estimator ~ <span x-text="Object.values(shopping_cart).reduce( function(cnt,o){ return cnt + o['quantity']; }, 0)"></span> Item(s)&nbsp;&nbsp;</button>
  33.                 </div>
  34.  
  35.                 <div class="hidden float-right w-5 h-5 my-5" :class="{'hidden' : showPriceEstimator , 'visible float-right' : ! showPriceEstimator }">
  36.                     <x-svg.expand class="h-5 w-5 float-left hover:text-red-500 cursor-pointer" x-on:click="{showPriceEstimator = !showPriceEstimator}"></x-svg.expand>
  37.                 </div>
  38.                 <div class="hidden float-right w-5 h-5 my-5" :class="{'hidden' : ! showPriceEstimator , 'visible float-right' : showPriceEstimator }">
  39.                     <x-svg.shrink class="h-5 w-5 float-left hover:text-red-500 cursor-pointer" x-on:click="{showPriceEstimator = !showPriceEstimator}"></x-svg.shrink>
  40.                 </div>
  41.                 <div class="float-right w-5 h-5 my-5">
  42.                     <x-svg.info class="h-5 w-5 float-left hover:text-red-500 cursor-pointer" x-on:click="{displayPriceInfoOpen = true}"></x-svg.info>
  43.                 </div>
  44.             </div>
  45.             <template x-for="[product_name, product_values] in Object.entries(shopping_cart)">
  46.                 <div class="w-full py-3 inline-block hidden" :class="{ 'w-full py-3 inline-block': showPriceEstimator, 'hidden' : ! showPriceEstimator , 'visible' : showPriceEstimator }">
  47.                     <div class="w-3/5 float-left">
  48.                         <p class="truncate"><button class="font-semibold text-red-900 hover:text-red-500" x-text="product_name" x-on:click="{document.getElementById(product_values['id']).click()}"></button></p>
  49.                         <p class="text-gray-800 text-sm" x-text="'Subtotal: '+(product_values['total_price']).toLocaleString('en-NZ', {style: 'currency', currency: 'NZD'})"></p>
  50.                     </div>
  51.                     <div class="w-2/5 h-full float-left flex justify-center content-center">
  52.                         <p class="m-auto">
  53.                             <button class="font-semibold rounded-full text-yellow-800 bg-yellow-100 hover:bg-yellow-200 font-semibold px-2 text-center" x-on:click="product_values['quantity'] > 1 ? (product_values['quantity'] -= 1, product_values['total_price'] = product_values['quantity']*product_values['price']) : delete shopping_cart[product_name]">-</button>
  54.                             <input :value="product_values['quantity']" x-on:change="$event.target.value > 0 ? (product_values['quantity'] = parseInt($event.target.value), product_values['total_price'] = product_values['quantity']*product_values['price']) : delete shopping_cart[product_name]" class="form-input ring-2 ring-gray-200 rounded-md w-12 text-center shadow-sm">
  55.                             <button class="font-semibold rounded-full text-yellow-800 bg-yellow-100 hover:bg-yellow-200 font-semibold px-2 text-center" x-on:click="(product_values['quantity'] += 1, product_values['total_price'] = product_values['quantity']*product_values['price'])">+</button>
  56.                         </p>
  57.                     </div>
  58.                 </div>
  59.             </template>
  60.             <div class="py-3 hidden" :class="{ 'py-3': showPriceEstimator, 'hidden' : ! showPriceEstimator , 'visible' : showPriceEstimator }">
  61.                 <div class="float-right whitespace-pre-line px-5"><span class="float-right text-sm" x-text="(Object.values(shopping_cart).reduce( function(cnt,o){ return cnt + o['total_price']; }, 0)).toLocaleString('en-NZ', {style: 'currency', currency: 'NZD'})"></span>
  62.                     <span class="float-right text-sm" x-text="(Object.values(shopping_cart).reduce( function(cnt,o){ return cnt + o['total_price']; }, 0)*0.15).toLocaleString('en-NZ', {style: 'currency', currency: 'NZD'})"></span>    
  63.                     <span class="float-right font-semibold" x-text="(Object.values(shopping_cart).reduce( function(cnt,o){ return cnt + o['total_price']; }, 0)*1.15).toLocaleString('en-NZ', {style: 'currency', currency: 'NZD'})"></span>
  64.                 </div>
  65.                 <div class="float-right text-right whitespace-pre-line"><span class="text-sm">Subtotal
  66.                     GST</span>
  67.                     <span class="font-semibold">TOTAL</span>
  68.                 </div>
  69.             </div>
  70.         </div>
  71.     </div>
  72.  
  73.     <!-- Product popup -->
  74.     <x-modal xshow="productBoxOpen">
  75.         <x-slot name="heading"><div x-text="alt"></div></x-slot>
  76.         <div class="px-6 py-2 w-full"><img :src="img"></div>
  77.     </x-modal>
  78.  
  79.     <x-modal xshow="displayPriceInfoOpen">
  80.         <x-slot name="heading">About this price estimator</x-slot>
  81.         <div class="px-6 py-2 w-full whitespace-pre-line">
  82.             The displayed prices are reflective of but not a confirmed final price. It is likely that discounts on bulk orders and special offers are available.
  83.            
  84.             After you have confirmed your items, please click the "request a quote" button for a detailed form where you can add any additional requirements and/or queries.
  85.  
  86.             Once sent, we will get back to you shortly with a custom-solution for your needs.
  87.  
  88.         </div>
  89.         <x-slot name="footer">
  90.             <x-jet-secondary-button x-on:click="displayPriceInfoOpen = false">
  91.                 {{ __('Alright, got it!') }}
  92.             </x-jet-secondary-button>
  93.         </x-slot>
  94.     </x-modal>
Add Comment
Please, Sign In to add comment