feat: limit checkout payment options from product rules
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -20,6 +20,7 @@ const {
|
||||
submitError,
|
||||
settlementType,
|
||||
checkTermMonths,
|
||||
paymentLimits,
|
||||
removeItem,
|
||||
proceedToCheckout,
|
||||
proceedAnyway,
|
||||
@@ -47,6 +48,7 @@ function goToOrdering() {
|
||||
:submitting="submitting"
|
||||
:settlement-type="settlementType"
|
||||
:check-term-months="checkTermMonths"
|
||||
:payment-limits="paymentLimits"
|
||||
@update:settlement-type="settlementType = $event"
|
||||
@update:check-term-months="checkTermMonths = $event"
|
||||
@back="router.push('/')"
|
||||
@@ -67,6 +69,7 @@ function goToOrdering() {
|
||||
:submitting="submitting"
|
||||
:settlement-type="settlementType"
|
||||
:check-term-months="checkTermMonths"
|
||||
:payment-limits="paymentLimits"
|
||||
@update:settlement-type="settlementType = $event"
|
||||
@update:check-term-months="checkTermMonths = $event"
|
||||
@remove="removeItem"
|
||||
|
||||
@@ -10,7 +10,7 @@ import IconLightbulb from '@/components/icons/IconLightbulb.vue'
|
||||
import IconLayoutGrid from '@/components/icons/IconLayoutGrid.vue'
|
||||
import IconDiamond from '@/components/icons/IconDiamond.vue'
|
||||
import { formatMeterage, formatNumber } from '@/utils/format'
|
||||
import type { CartItem, SettlementType } from '@/types'
|
||||
import type { CartItem, PaymentLimits, SettlementType } from '@/types'
|
||||
import PreorderPaymentFields from '@/components/orders/PreorderPaymentFields.vue'
|
||||
|
||||
defineProps<{
|
||||
@@ -30,6 +30,7 @@ defineProps<{
|
||||
submitting?: boolean
|
||||
settlementType: SettlementType | null
|
||||
checkTermMonths: number | null
|
||||
paymentLimits?: PaymentLimits
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -188,6 +189,8 @@ const quickLinks = [
|
||||
<PreorderPaymentFields
|
||||
:settlement-type="settlementType"
|
||||
:check-term-months="checkTermMonths"
|
||||
:allowed-methods="paymentLimits?.methods"
|
||||
:max-check-months="paymentLimits?.maxCheckMonths"
|
||||
@update:settlement-type="emit('update:settlementType', $event)"
|
||||
@update:check-term-months="emit('update:checkTermMonths', $event)"
|
||||
/>
|
||||
|
||||
@@ -4,7 +4,7 @@ import EmptyState from '@/components/ui/EmptyState.vue'
|
||||
import IconTrash from '@/components/icons/IconTrash.vue'
|
||||
import IconChevronBack from '@/components/icons/IconChevronBack.vue'
|
||||
import { formatMeterage, formatNumber } from '@/utils/format'
|
||||
import type { CartItem, SettlementType } from '@/types'
|
||||
import type { CartItem, PaymentLimits, SettlementType } from '@/types'
|
||||
import PreorderPaymentFields from '@/components/orders/PreorderPaymentFields.vue'
|
||||
|
||||
defineProps<{
|
||||
@@ -24,6 +24,7 @@ defineProps<{
|
||||
submitting?: boolean
|
||||
settlementType: SettlementType | null
|
||||
checkTermMonths: number | null
|
||||
paymentLimits?: PaymentLimits
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -106,6 +107,8 @@ const emit = defineEmits<{
|
||||
<PreorderPaymentFields
|
||||
:settlement-type="settlementType"
|
||||
:check-term-months="checkTermMonths"
|
||||
:allowed-methods="paymentLimits?.methods"
|
||||
:max-check-months="paymentLimits?.maxCheckMonths"
|
||||
@update:settlement-type="emit('update:settlementType', $event)"
|
||||
@update:check-term-months="emit('update:checkTermMonths', $event)"
|
||||
/>
|
||||
|
||||
@@ -174,8 +174,17 @@ async function savePaymentPlan() {
|
||||
formError.value = 'روش پرداخت را انتخاب کنید.'
|
||||
return
|
||||
}
|
||||
if ((planType.value === 'check' || planType.value === 'cash_check') && !planMonths.value) {
|
||||
formError.value = 'مدت چک را از ۱ تا ۴ ماه انتخاب کنید.'
|
||||
const maxMonths = current.paymentLimits?.maxCheckMonths ?? 4
|
||||
const allowed = current.paymentLimits?.methods
|
||||
if (allowed && !allowed.includes(planType.value)) {
|
||||
formError.value = 'این روش پرداخت برای محصولات سفارش مجاز نیست.'
|
||||
return
|
||||
}
|
||||
if (
|
||||
(planType.value === 'check' || planType.value === 'cash_check') &&
|
||||
(!planMonths.value || planMonths.value > maxMonths)
|
||||
) {
|
||||
formError.value = `مدت چک را تا ${maxMonths} ماه انتخاب کنید.`
|
||||
return
|
||||
}
|
||||
planSaving.value = true
|
||||
@@ -352,6 +361,8 @@ async function submitReceipt() {
|
||||
<PreorderPaymentFields
|
||||
:settlement-type="planType"
|
||||
:check-term-months="planMonths"
|
||||
:allowed-methods="order.paymentLimits?.methods"
|
||||
:max-check-months="order.paymentLimits?.maxCheckMonths"
|
||||
@update:settlement-type="planType = $event"
|
||||
@update:check-term-months="planMonths = $event"
|
||||
/>
|
||||
@@ -391,6 +402,8 @@ async function submitReceipt() {
|
||||
<PreorderPaymentFields
|
||||
:settlement-type="planType"
|
||||
:check-term-months="planMonths"
|
||||
:allowed-methods="order.paymentLimits?.methods"
|
||||
:max-check-months="order.paymentLimits?.maxCheckMonths"
|
||||
@update:settlement-type="planType = $event"
|
||||
@update:check-term-months="planMonths = $event"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user