PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.8
Booking for Appointments and Events Calendar – Amelia v2.4.8
2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / v3 / src / views / public / Parts / Payment / Methods / PaymentWc.vue
ameliabooking / v3 / src / views / public / Parts / Payment / Methods Last commit date
PaymentCommon.vue 4 days ago PaymentOnSite.vue 1 month ago PaymentPayPal.vue 4 days ago PaymentSquare.vue 4 days ago PaymentStripe.vue 4 days ago PaymentWc.vue 1 month ago
PaymentWc.vue
128 lines
1 <template>
2 <div class="am-fs__payment_default"></div>
3 </template>
4
5 <script setup>
6 // * Import from Vue
7 import {
8 // ref,
9 inject,
10 watchEffect,
11 } from 'vue'
12
13 // * Import form Vuex
14 import { useStore } from 'vuex'
15
16 // * Composables
17 import {
18 getErrorMessage,
19 useBookingData,
20 useCreateBookingError,
21 } from '../../../../../assets/js/public/booking.js'
22
23 import httpClient from '../../../../../plugins/axios'
24
25 // * Component props
26 let props = defineProps({
27 instantBooking: {
28 type: Boolean,
29 default: false,
30 },
31 })
32
33 const store = useStore()
34
35 const shortcodeData = inject('shortcodeData')
36
37 let stepsArray = inject('stepsArray')
38
39 // ! treba da se prilagodi za services i packages
40 // let sidebarSteps = inject('sidebarSteps', ref([]))
41
42 /**************
43 * Navigation *
44 *************/
45
46 const { footerButtonReset, footerButtonClicked } = inject('changingStepsFunctions', {
47 footerButtonReset: () => {},
48 footerButtonClicked: {
49 value: false,
50 },
51 })
52
53 defineExpose({
54 continueWithBooking,
55 })
56
57 // * Labels
58 const amLabels = inject('labels')
59
60 watchEffect(() => {
61 if (footerButtonClicked.value && !props.instantBooking) {
62 if (!store.getters['coupon/getCouponValidated']) {
63 footerButtonReset()
64 emits('payment-error', amLabels.value.coupon_mandatory)
65 } else {
66 continueWithBooking()
67 }
68 }
69 })
70
71 /***********
72 * Payment *
73 **********/
74
75 function continueWithBooking() {
76 footerButtonReset()
77
78 let bookingData = useBookingData(
79 store,
80 {
81 shortcode: shortcodeData.value,
82 steps: stepsArray.value.map((i) => i.name),
83 // ! it must be refactored
84 // sidebar: sidebarSteps.value.map(i => Object.assign({key: i.key, data: i.stepSelectedData})),
85 },
86 false,
87 {},
88 null,
89 )
90
91 store.commit('setLoading', true)
92
93 payment('/payment/wc', bookingData, function (response) {
94 window.location = response.data.data.cartUrl
95 })
96 }
97
98 const emits = defineEmits(['payment-error'])
99
100 function payment(endpoint, bookingData, success) {
101 httpClient
102 .post(endpoint, bookingData.data, bookingData.options)
103 .then(success)
104 .catch((error) => {
105 useCreateBookingError(store, error.response.data, () => {
106 emits('payment-error', getErrorMessage())
107 })
108 })
109 }
110 </script>
111
112 <script>
113 export default {
114 name: 'PaymentWc',
115 }
116 </script>
117
118 <style lang="scss">
119 .amelia-v2-booking {
120 #amelia-container {
121 .am-fs__payment_default {
122 &-btn {
123 }
124 }
125 }
126 }
127 </style>
128