CabGrid Pro supports shortcode attributes that can adjust the appearance and functionality of each individual instance of CabGrid on your website. This article discusses the available shortcode attributes and how to implement them.
In addition to the standard price calculator, CabGrid Pro also provides a table layout shortcode:
This can be configured with its own attributes. These are detailed in a separate article.
Shortcode Attribute Syntax
The syntax for attributes is (use double quotes around values):
[cabGridPro attr1="val1" attr2="val2"]
When using the WordPress Classic Editor (aka TinyMCE) to edit posts or pages, the Cab Grid icon () will insert the Cab Grid Pro shortcode with all available attributes and some default values. Otherwise, attributes can be added as required.
Current Cab Grid Pro Shortcode Attributes
Click on an attribute title to get details and example values…
The ID attribute of the main Cab Grid Pro element will be prefixed with ‘cabGridPro‘ so, for example, it could be addressed in CSS like this:
In Cab Grid Pro v4 or earlier, the ID attribute also provided GROUP functionality (see GROUPS tab for more info).
In Cab Grid Pro v4 and earlier this functionality was provided via the ID attribute.
If it is not set, the default layout will be used – as set in the OPTIONS tab of the Cab Grid Pro WordPress admin.
The layout attribute can currently be set to ‘passengers‘ or ‘vehicle‘ or ‘tickets‘ or ‘time‘
When set to ‘passengers‘ the Cab Grid interface will show input boxes for the number of passengers and number of luggage items, and use this information to calculate which vehicle is most appropriate and select a price.
When set to ‘vehicle‘ the Cab Grid interface will display details of all vehicles configured. The user will need to choose a vehicle as well as setting origin and destination to obtain a journey price.
When set to ‘tickets‘ the Cab Grid interface will show a single number input. This is for the number of tickets required. This is good for municipal transport such as bus, coach or train services. The number of tickets specified will multiply the price for the journey. So 2 tickets for a £10 journey will result in a price of £20.00 being displayed. (The number of tickets will govern which vehicle is selected – and hence price table.)
When set to ‘time‘ the Cab Grid interface will show a number input. This is for the number of time units required. The unit of time can be set in the OPTIONS tab when ‘Length of time‘ is selected for the ‘Price Based On’ option. This is good for tour or hire style businesses. The time period specified will multiply the price for the journey. So 2 units (hours, days, or whatever set) for a £10 journey will result in a price of £20.00 being displayed.
In ‘time‘ mode, the number of passengers field will also be displayed (though it is possible to hide this field through CSS). This is used to govern which vehicle is selected – and hence price table. The return button is also hidden in time mode as it is not relevant (though it may be re-enabled through CSS). The time option was introduced in Cab Grid Pro version 4.5.
[cabGridPro layout="passengers"] or
The ‘icons‘ attribute is used to set the general icon set and text colours the instance uses.
Currently, values can be set to ‘light’ or ‘dark’. Light icons (& text) are for instances with dark backgrounds and vice versa.
The ‘luggage‘ attribute is used to set if the luggage input field is hidden.
It expects values of either ‘Off’ (with capital ‘O’) to hide the input field, or ‘On’ (with upper-case ‘O’) to explicitly show the input field*.
ORIGIN & DEST
These attributes allows you to pre-define (set the drop-down) for either pick up or destination.
Setting the ‘ORIGIN’ attribute to a value that exactly matches one of your place names will pre-define the pickup location drop down for this instance of the Cab Grid Pro plugin.
Setting the ‘DEST’ attribute to a value that exactly matches one of your place names will pre-define the drop-off location drop down for this instance of the Cab Grid Pro plugin.
The values set for ORIGIN and DEST must exactly match (case-sensitive) a place name set in the AREAS tab. The corresponding checkbox under the ‘Origin’ or ‘Destination’ columns in the AREAS tab must also be checked/ticked and the origin/dest entered must also be part of the GROUP.
For PASSENGER and TICKET layout modes, if both ORIGIN and DEST attributes are set and matched, the Cab Grid Pro interface will perform the calculation and return a price. In VEHICLE mode, the visitor must select a vehicle for the calculation to be performed.
Setting only one of either ORIGIN or DEST attributes will simply pre-populate the corresponding drop down and no calculation will be performed. The customer can then go on to select or change options to get a price and book as normal.
[cabGridPro origin="place1" dest="place2"]
The ‘vehicles‘ attribute is used to restrict the vehicles the instance uses for price calculations.
If set, in ‘vehicles’ layout mode, only the identified vehicles will be displayed. In other modes, the price lookup will be restricted to the vehicles identified. This will also restrict the maximum capacity for passengers, luggage, etc. to that of the highest capacity vehicle identified.
The vehicles attribute expects vehicle ID numbers separated by a comma. The ID of a vehicle can be found by hovering the mouse over the vehicle name field under the VEHICLES tab on the Cab Grid Pro admin page:
From Cab Grid Pro version 5.0, when in VEHICLE layout, the vehicles will be displayed in the order specified in this shortcode attribute. So, in the example above, the calculator will be laid out, left to right, starting with the vehicle with ID ‘6’, then ‘1’, then ‘4’.
The ‘class‘ attribute is used to assign additional CSS classes to a Cab Grid Pro calculator instance. Class names are separated with a space. This is useful when targeting specific Cab Grid instances to style.
[cabGridPro class="myCustomClassName anotherClass"]
Custom class names can also be assigned in the widget properties box when displaying Cab Grid taxi fare price calculator in a sidebar area.
The ‘single‘ attribute is used to limit either the origin or destination drop down lists to a single place. (Note; this is similar to selecting only one place as an origin or destination in the AREAS tab, but using the single attribute, the setting can be applied to a specific instance of the Cab Grid taxi price calculator only, rather than all instances.)
The ‘single‘ attribute can be set to either ‘origin‘ (to limit the pick-up location list) or ‘dest‘ (to limit the destination location list). When the ‘single‘ attribute is defined the corresponding ‘origin‘ or ‘dest‘ attribute must also be defined.
[cabGridPro single="origin" origin="Place Name"]
[cabGridPro single="dest" dest="Other Place"]
This shortcode attribute was added in Cab Grid Pro version 5.1.11
The ‘onewayrtn‘ attribute is used to preset the one-way/return icon. It accepts the following values for:
PASS, LUGG, TICK & TIME
Note; setting these attributes within the Cab Grid Pro shortcode will override any values defined via the Defaults Add-on or _settings.php file. However, if values are set in a link via query string parameters, the shortcode attributes will ignored.
The ‘pass’ attribute is used to set the number of passengers shown when the Cab Grid Pro calculator loads in ‘passengers’ layout.
The ‘lugg’ attribute is used to set the quantity of luggage items shown when the Cab Grid Pro calculator loads in ‘passengers’ layout.
The ‘tick’ attribute is used to set the number of tickets shown when the Cab Grid Pro calculator loads in ‘tickets’ layout.
[cabGridPro layout="tickets" tick="4"]
The ‘time’ attribute is used to set the quantity of time units shown when the Cab Grid Pro calculator loads in ‘time’ layout.
[cabGridPro time="8" layout="time"]
Change the Cab Grid Pro calculator input type displayed between regular text (number) inputs and drop-down menus (HTML <select> boxes).
This shortcode attribute was added in Cab Grid Pro version 5.6.6
Effected inputs: Number of passengers, Quantity of Luggage, Number of Tickets, Number of Time Units.
The ‘dropdown‘ attribute is used to set the appearance of number inputs in the Cab Grid Pro calculator. It accepts the following values for:
Default value: ‘n’
The regular number input field allows mobile devices to show a native number input interface and is preferred.