State pricing (Australia)
In Australia, stamp duty, registration and CTP insurance differ by state, so the same car has a different drive-away price in each one. Vyro stores a price per pricing code.
| Code | State or territory | Currency |
|---|---|---|
AU_NSW |
New South Wales | AUD |
AU_VIC |
Victoria | AUD |
AU_QLD |
Queensland | AUD |
AU_SA |
South Australia | AUD |
AU_WA |
Western Australia | AUD |
AU_TAS |
Tasmania | AUD |
AU_ACT |
Australian Capital Territory | AUD |
AU_NT |
Northern Territory | AUD |
NZ |
New Zealand (one price nationwide) | NZD |
The format is <country>_<state> where the country has states, and the country alone where it doesn’t.
The two fields
Section titled “The two fields”pricing_codesis the list of codes a vehicle is priced in. Filter on this.pricing_configholds the price for each code. Read from this withpath.
query VictorianStock($showroomId: uuid!) { stocked_vehicles( where: { showroom_stocked_vehicles: { showroom_id: { _eq: $showroomId } } pricing_codes: { _contains: ["AU_VIC"] } } limit: 20 ) { id pricing_codes vic: pricing_config(path: "AU_VIC") }}A vehicle that isn’t in a state’s pricing_codes isn’t sold there. Leave it out of that state’s results rather than showing another state’s price.
Several states at once
Section titled “Several states at once”Use aliases to fetch more than one state in a single request:
query AllStates($id: uuid!) { stocked_vehicles_by_pk(id: $id) { nsw: pricing_config(path: "AU_NSW") vic: pricing_config(path: "AU_VIC") qld: pricing_config(path: "AU_QLD") wa: pricing_config(path: "AU_WA") }}Or fetch pricing_config without path to get every state in one JSON object, keyed by code.
Which states a dealer sells in
Section titled “Which states a dealer sells in”query DealerStates($showroomId: uuid!) { showroom_pricing_codes(where: { showroom_id: { _eq: $showroomId } }) { pricing_code { code short_name country region currency } } showrooms_by_pk(id: $showroomId) { default_pricing_code }}default_pricing_code is the state the dealer’s own website shows when it doesn’t know where the shopper is.
Picking the shopper’s state
Section titled “Picking the shopper’s state”Pick a state before you show a price, and say which state it’s for (“$45,990 drive away, NSW”). In order of preference:
- The shopper chose it, in a state picker or by entering a postcode.
- Their location, from IP geolocation. Most CDNs give you a region header.
- The dealer’s
default_pricing_code.
To turn a postcode into a state, use your own postcode data, or ask which of the dealer’s locations serve that postcode:
query ServingLocation($showroomId: uuid!, $postcode: String!) { locations( where: { showroom_id: { _eq: $showroomId } primary_market_area_postcodes: { _contains: [$postcode] } } limit: 1 ) { id name address }}Then turn the location’s address.state into a pricing code. It can be the full name or the abbreviation, so map both:
const AU_STATES = { NSW: 'NSW', 'NEW SOUTH WALES': 'NSW', VIC: 'VIC', VICTORIA: 'VIC', QLD: 'QLD', QUEENSLAND: 'QLD', SA: 'SA', 'SOUTH AUSTRALIA': 'SA', WA: 'WA', 'WESTERN AUSTRALIA': 'WA', TAS: 'TAS', TASMANIA: 'TAS', ACT: 'ACT', 'AUSTRALIAN CAPITAL TERRITORY': 'ACT', NT: 'NT', 'NORTHERN TERRITORY': 'NT',};
function pricingCodeFor(address) { if (address?.country_code === 'NZ') return 'NZ'; const state = AU_STATES[String(address?.state ?? '').trim().toUpperCase()]; return state ? `AU_${state}` : null;}