Widget:Tp total calculate
From Guild Wars 2 Wiki
Jump to navigationJump to search
This widget fetches trading post prices, and provides basic options for displaying subtotals and a grand total.
Usage
This widget should be placed at the bottom of a page, beneath any tables or placeholder elements which contain item ids and quantities.
{{tp total calculate}}
Required element structure
To enable the widget to calculate an individual price, subtotals and a grandtotal, certain CSS classes and a data attributes are required. This documentation has been written assuming use of a table, but any nested HTML structure can be used.
Refer to the example below for an illustration.
Parent element (table)
Classes
- tpwrapper
- The parent element requires the "tpwrapper" class. Every item within this element will contribute to the grand total.
Attributes
- data-info
- Optional. By default, the trading post sell prices will be used ("data-info=sells"). The other options are trading post buy price ("data-info=buys") and trading post sell price including the -15% tax ("data-info=sellst")
- data-useval
- Optional. By default, set to "false". If set to true, respects vendor values.
Individual element (row)
Classes
- tptotal
- The individual item requires the "tptotal" class. Everything within this element will contribute to the row subtotal.
- tpprice
- Elements with this class will be replaced with the trading post price for a single qty of the given item id.
- tpsubtotal
- Elements with this class will be replaced with the trading post price for multiple qty of the given item id, using the input quantity, referred to as the subtotal.
Attributes
- data-id
- Required. The item ID.
- data-qty
- Required. The quantity.
- data-value
- Optional. A fall back option if trading post prices cannot be found for the buy/sell option. This can be used to inject vendor prices (as used on Template:Base ingredients table row).
Final element (last row)
Classes
- tpgrandtotal
- Elements with this class will be replaced, effectively with the total of all subtotals within the table (technically does not require any subtotal classes to be used).
Attributes
- None.
Example
{| {{STDT|sortable right tpwrapper}} data-info="buys" ! Qty ! Material ! style="width:135px;" | TP buy price ! style="width:135px;" | Subtotal |- class="tptotal" data-id="19976" data-qty="30" | 30 | style="text-align:left;" | {{item icon|Mystic Coin}} | class="tpprice" | ... | class="tpsubtotal" | ... |- class="tptotal" data-id="24315" data-qty="50" | 50 | style="text-align:left;" | {{item icon|Molten Lodestone}} | class="tpprice" | ... | class="tpsubtotal" | ... |- class="tptotal" data-id="19701" data-qty="1500" | 1500 | style="text-align:left;" | {{item icon|Orichalcum Ore}} | class="tpprice" | ... | class="tpsubtotal" | ... |- ! colspan="3" style="text-align:left;" | Grand total ! class="tpgrandtotal" style="text-align:right;" | ... |} {{tp total calculate}}
Qty | Material | TP buy price | Subtotal |
---|---|---|---|
30 | Mystic Coin | ... | ... |
50 | Molten Lodestone | ... | ... |
1500 | Orichalcum Ore | ... | ... |
Grand total | ... |
Used on
See also
- Template:Tp total placeholder — the input materials template
- Template:Tp total calculate — wrapper template for this widget