Skip to content

Commit

Permalink
Rapidez v3 support (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordythevulder authored Dec 12, 2024
1 parent c2f690d commit 84f5d52
Show file tree
Hide file tree
Showing 42 changed files with 554 additions and 329 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"prefer-stable": true,
"require": {
"php": "^8.1|^8.2",
"rapidez/checkout-theme": "^2.11"
"rapidez/checkout-theme": "^3.0"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 3 additions & 0 deletions resources/shipping-icons/default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/views/cart/coupon.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<x-rapidez-ct::coupon-field />
<template v-if="cart.applied_coupons?.length" v-for="coupon in cart.applied_coupons" v-cloak>
<graphql-mutation
:query="'mutation ($cart_id: String!) { removeCouponFromCart(input: { cart_id: $cart_id }) { cart { ' + config.queries.cart + ' } } }'"
:query="'mutation ($cart_id: String!) { removeCouponFromCart(input: { cart_id: $cart_id }) { ...cart } } ' + config.fragments.cart"
:variables="{ cart_id: mask }"
:callback="updateCart"
:error-callback="checkResponseForExpiredCart"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<graphql-mutation
:query="'mutation ($cart_id: String!, $cart_item_id: Int) { removeItemFromCart(input: { cart_id: $cart_id, cart_item_id: $cart_item_id }) { cart { ' + config.queries.cart + ' } } }'"
:query="'mutation ($cart_id: String!, $cart_item_id: Int) { removeItemFromCart(input: { cart_id: $cart_id, cart_item_id: $cart_item_id }) { ...cart } } ' + config.fragments.cart"
:variables="{ cart_id: mask, cart_item_id: item.id }"
:notify="{ message: item.product.name+' '+config.translations.cart.remove }"
:callback="updateCart"
Expand Down
45 changes: 45 additions & 0 deletions resources/views/checkout/pages/credentials.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@extends('rapidez::layouts.app')

@section('title', __('Checkout'))

@section('robots', 'NOINDEX,NOFOLLOW')

@section('content')
<div class="overflow-clip">
<div class="container">
<x-rapidez-ct::layout.checkout>
<x-slot:header>
@include('rapidez-ct::checkout.partials.header', ['href' => route('cart')])
</x-slot:header>
<x-rapidez-ct::title-progress-bar :$checkoutSteps :$currentStep :$currentStepKey>
@lang('Credentials')
</x-rapidez-ct::title-progress-bar>

<form
class="contents"
v-on:submit.prevent="(e) => {
submitPartials(e.target?.form ?? e.target)
.then((result) =>
window.app.$emit('checkout-credentials-saved')
&& window.Turbo.visit(window.url('{{ route('checkout', ['step' => 'payment']) }}'))
).catch();
}"
>
@include('rapidez-ct::checkout.steps.credentials')
<x-rapidez-ct::toolbar>
<x-rapidez-ct::button.outline :href="route('cart')">
@lang('Back to cart')
</x-rapidez-ct::button.outline>

<x-rapidez-ct::button.enhanced loader>
@lang('Next')
</x-rapidez-ct::button.enhanced>
</x-rapidez-ct::toolbar>
</form>
<x-slot:sidebar>
@include('rapidez-ct::checkout.partials.sidebar.sidebar')
</x-slot:sidebar>
</x-rapidez-ct::layout.checkout>
</div>
</div>
@endsection
44 changes: 44 additions & 0 deletions resources/views/checkout/pages/login.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@extends('rapidez::layouts.app')

@section('title', __('Checkout'))

@section('robots', 'NOINDEX,NOFOLLOW')

@section('content')
<div class="overflow-clip">
<div class="container">
<x-rapidez-ct::layout.checkout>
<x-slot:header>
@include('rapidez-ct::checkout.partials.header', ['href' => route('cart')])
</x-slot:header>

<x-rapidez-ct::title-progress-bar :$checkoutSteps :$currentStep :$currentStepKey>
@lang('Credentials')
</x-rapidez-ct::title-progress-bar>

<form
v-if="hasCart"
v-on:submit.prevent="(e) => {
submitPartials(e.target?.form ?? e.target)
.then((result) =>
window.Turbo.visit(window.url('{{ route('checkout', ['step' => 'credentials']) }}'))
).catch();
}"
class="max-w-md mx-auto"
v-cloak
>
@include('rapidez-ct::checkout.steps.login')
<x-rapidez-ct::toolbar>
<x-rapidez-ct::button.outline :href="route('cart')">
@lang('Back to cart')
</x-rapidez-ct::button.outline>

<x-rapidez-ct::button.enhanced loader type="submit" dusk="continue" >
@lang('Next')
</x-rapidez-ct::button.enhanced>
</x-rapidez-ct::toolbar>
</form>
</x-rapidez-ct::layout.checkout>
</div>
</div>
@endsection
57 changes: 57 additions & 0 deletions resources/views/checkout/pages/payment.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@extends('rapidez::layouts.app')

@section('title', __('Checkout'))

@section('robots', 'NOINDEX,NOFOLLOW')

@section('content')
<div class="overflow-clip">
<div class="container">
<x-rapidez-ct::layout.checkout>
<x-slot:header>
@include('rapidez-ct::checkout.partials.header', ['href' => route('cart')])
</x-slot:header>

<x-rapidez-ct::title-progress-bar :$checkoutSteps :$currentStep :$currentStepKey>
@lang('Payment')
</x-rapidez-ct::title-progress-bar>

<form
class="contents"
v-on:submit.prevent="(e) => {
submitPartials(e.target?.form ?? e.target)
.then((result) =>
window.app.$emit('checkout-payment-saved')
&& window.app.$emit('placeOrder')
).catch();
}"
>
@include('rapidez::checkout.steps.payment_method')
<x-rapidez-ct::toolbar>
<x-rapidez-ct::button.outline :href="route('checkout', ['step' => 'credentials'])">
@lang('Back to credentials')
</x-rapidez-ct::button.outline>
<graphql-mutation
:query="config.queries.placeOrder"
:variables="{ cart_id: mask }"
:before-request="handleBeforePlaceOrderHandlers"
:callback="handlePlaceOrder"
mutate-event="placeOrder"
redirect="{{ route('checkout.success') }}"
v-slot="{ mutate, variables }"
>
<fieldset>
<x-rapidez-ct::button.enhanced class="relative" type="submit" dusk="continue" loader>
@lang('Place order')
</x-rapidez-ct::button.enhanced>
</fieldset>
</graphql-mutation>
</x-rapidez-ct::toolbar>
</form>
<x-slot:sidebar>
@include('rapidez-ct::checkout.partials.sidebar.sidebar')
</x-slot:sidebar>
</x-rapidez-ct::layout.checkout>
</div>
</div>
@endsection
25 changes: 13 additions & 12 deletions resources/views/checkout/partials/header.blade.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
@include('rapidez-ct::components.slide-in.receipt')
<div class="lg:hidden">
@include('rapidez-ct::components.slide-in.receipt')
</div>
<div class="flex flex-wrap gap-y-3 max-xl:-mt-5 xl:mr-20">
<x-rapidez-ct::button.outline v-if="checkout.step == 2" class="flex items-center justify-center !p-0 w-12 h-12 lg:hidden" :href="route('cart')">
<x-heroicon-o-arrow-long-left class="w-6 h-6"/>
</x-rapidez-ct::button.outline>
<x-rapidez-ct::button.outline v-else class="flex items-center justify-center !p-0 w-12 h-12 lg:hidden" v-on:click.prevent="goToStep(1)">
<x-heroicon-o-arrow-long-left class="w-6 h-6"/>
</x-rapidez-ct::button.outline>
@isset($href)
<x-rapidez-ct::button.outline class="flex items-center justify-center !p-0 size-12 lg:hidden" :$href>
<x-heroicon-o-arrow-long-left class="size-6"/>
</x-rapidez-ct::button.outline>
@endif

<div class="flex lg:w-24 [&>*]:w-auto [&>*]:h-auto max-lg:flex-1 max-lg:h-12">
<a href="{{ url('/') }}" class="sticky top-0 max-lg:mx-5 flex items-center lg:self-start max-lg:flex-1 lg:pt-4">
<div class="w-inherit flex-1">
<div class="flex lg:w-24 *:w-auto *:h-auto max-lg:flex-1 max-lg:h-12">
<a href="{{ url('/') }}" class="sticky top-0 max-lg:mx-5 flex items-center lg:self-start max-lg:flex-1 lg:pt-4 max-w-full">
<div class="w-inherit flex-1 *:w-auto *:h-auto *:max-w-full max-w-full h-full *:max-h-full">
<x-rapidez-ct::logo />
</div>
</a>
</div>
<x-rapidez-ct::button.inactive for="slide-in" class="lg:hidden">
<span class="relative">
<span class="absolute flex items-center justify-center w-4 h-4 -right-2 -top-1.5 rounded-full bg-ct-primary text-white text-xs">
<span class="absolute flex items-center font-semibold justify-center size-4 -right-2 -top-1.5 rounded-full bg-ct-primary text-white text-xs">
@{{ Math.round(cart.total_quantity) }}
</span>
<x-heroicon-o-shopping-cart class="w-6 h-6"/>
<x-heroicon-o-shopping-cart class="size-6"/>
</span>
@lang('My order')
</x-rapidez-ct::button.inactive>
Expand Down
23 changes: 0 additions & 23 deletions resources/views/checkout/partials/layout.blade.php

This file was deleted.

60 changes: 49 additions & 11 deletions resources/views/checkout/partials/sections/address.blade.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,52 @@
<checkout-address v-slot="{ useCards, editing, toggleEdit, isType, select }">
<x-rapidez-ct::card.inactive v-if="useCards && !editing">
@include('rapidez-ct::checkout.partials.address-cards')
@include('rapidez-ct::checkout.partials.buttons.address')
</x-rapidez-ct::card.inactive>
<checkout-address v-slot="{ useCards, editing, toggleEdit }">
<div class="contents">
<template v-if="useCards && !editing">
@include('rapidez-ct::checkout.partials.address-cards')
@include('rapidez-ct::checkout.partials.buttons.address')
</template>

<x-rapidez-ct::card.inactive v-else>
@include('rapidez-ct::checkout.partials.shipping-billing-fields', ['type' => 'shipping'])
<template v-else>
<graphql-mutation
:query="config.queries.setNewShippingAddressesOnCart"
:variables="{
cart_id: mask,
...window.address_defaults,
...cart.shipping_addresses[0],
country_code: cart.shipping_addresses[0]?.country.code || window.address_defaults.country_code
}"
group="shipping"
:callback="updateCart"
:error-callback="checkResponseForExpiredCart"
:watch="false"
mutate-event="setShippingAddressesOnCart"
v-slot="{ mutate, variables }"
v-if="!cart.is_virtual"
>
<fieldset partial-submit="mutate" v-on:change="function (e) {e.target.closest('fieldset').querySelector(':invalid') === null && mutate().then(() => (cart?.billing_address?.same_as_shipping ?? true) && window.app.$emit('setBillingAddressOnCart'))}">
@include('rapidez-ct::checkout.partials.shipping-billing-fields', ['type' => 'shipping'])
</fieldset>
</graphql-mutation>

<div class="mt-9 pt-7 border-t border-dashed" v-if="!checkout.hide_billing">
@include('rapidez-ct::checkout.partials.shipping-billing-fields', ['type' => 'billing'])
</div>
</x-rapidez-ct::card.inactive>
<graphql-mutation
:query="config.queries.setNewBillingAddressOnCart"
:variables="JSON.parse(JSON.stringify({
cart_id: mask,
...window.address_defaults,
...cart.billing_address,
same_as_shipping: !cart.is_virtual && (cart?.billing_address?.same_as_shipping ?? true),
country_code: cart.billing_address?.country.code || window.address_defaults.country_code
}))"
:callback="updateCart"
:error-callback="checkResponseForExpiredCart"
:watch="false"
group="billing"
mutate-event="setBillingAddressOnCart"
v-slot="{ mutate, variables }"
>
<fieldset partial-submit="mutate" v-on:change="function (e) {e.target.closest('fieldset').querySelector(':invalid') === null && mutate().then(() => (cart?.billing_address?.same_as_shipping ?? true) && window.app.$emit('setBillingAddressOnCart'))}">
@include('rapidez-ct::checkout.partials.shipping-billing-fields', ['type' => 'billing'])
</fieldset>
</graphql-mutation>
</template>
</div>
</checkout-address>
Loading

0 comments on commit 84f5d52

Please sign in to comment.