|
1
|
import { ConditionalShippingOptionPriceAccessor } from "../types" |
|
2
|
|
|
3
|
export const getCustomShippingOptionPriceFieldName = ( |
|
4
|
field: string, |
|
5
|
type: "region" | "currency" |
|
6
|
): ConditionalShippingOptionPriceAccessor => { |
|
7
|
const prefix = type === "region" ? "region_prices" : "currency_prices" |
|
8
|
const customPrefix = |
|
9
|
type === "region" |
|
10
|
? "conditional_region_prices" |
|
11
|
: "conditional_currency_prices" |
|
12
|
|
|
13
|
const name = field.replace( |
|
14
|
prefix, |
|
15
|
customPrefix |
|
16
|
) as ConditionalShippingOptionPriceAccessor |
|
17
|
|
|
18
|
return name |
|
19
|
} |