Parameters
TreasureChest Parameters
&service
TreasureChest has 4 services:
- items (default)
- cart
- pdt
- global
items (default)
The default service (items) queries the database for information on the specified item and sets many useful placeholders for use in your item's page. An example would look like this
[[TreasureChest? &item=`1`]]
As this is the default service, you do not need to specify &service=`items`.
cart
The `cart` service handles all of the functionality of your customer's shopping experience, including adding items to the cart, removing items in the cart, adjusting and remembering item quantities and item options, and checking out. It also handles interaction with PayPal's IPN system and helps you track your orders and inventory. The cart service is also responsible for triggering the TreasureChest system events if you need a MODx plugin to handle any extra lifting with your orders. An example cart call would look like this
[!TreasureChest? &service=`cart`!]
Notice that it is called uncached as it's content is very dynamic.
pdt
The `pdt` service generates a custom "Thank You" or "Receipt" page for your customers. Once you have configured the TreasureChest Module with your PDT document id and PDT token, the TreasureChest snippet will automatically instruct PayPal to send your customers back to that specified page after they complete their payment. This service sets placeholders for each of the parameters that paypal sends back to your site when the customer is redirected there. The `pdt` service also invokes the events OnPDTSuccess or OnPDTFail depending on the status of the payment. If the payment fails or the customer cancels, the customer is redirected to your unauthorized page to protect the security and integrity of your checkout process (for instance if you sell instant downloads).
An example cart call would look like this
[!TreasureChest? &service=`pdt`!]
Notice that it is called uncached so that customer order info is not saved in your site cache.
global
The `global` service registers the shopping cart javascript ONLY if it is not already registered. This is very useful in the head of your template so that when your customers are shopping at your site, the View Cart links are still present on pages that do not have a TreasureChest snippet call in their content. This service will only load the javascript if there is not another TreasureChest snippet call on the page so the javascript will only be placed in the head ONCE. An example cart call would look like this
[[TreasureChest? &service=`pdt`]]
&item and &selector
item
For each product you have you will create a separate MODx document. On this document, the first line in the Document content area should be
[[TreasureChest? &item=`1`]]
Where `1` is the unique id for the product from the TreasureChest Module. This will set placeholders for each of the items attributes in the database.
selector
The default selector is `id`, but if you wish to query for your items by a different table column you can specify the selector. For instance if you have a product with an item name of "Red Pens" you could set up your product page like this.
[[TreasureChest? &item=`Red Pens` &selector=`item_name`]]
If you have an an product with an item number of "green_shirt_005" you coud set up the product page like this.
[[TreasureChest? &item=`green_shirt_005` &selector=`item_number`]]
&thumb_w
Thumbnail width
A thumbnail image is automatically generated with phpThumb() for the image you uploaded for your product in the TreasureChest Module. You can specify the width of this thumbnail using the thumb_w parameter (your image is kept to scale). The default thumbnail width is 100 pixels. If you wanted the thumbnail to be 125 pixels wide you would set it in your product page as below
[[TreasureChest? &item=`1` &thumb_w=`125`]]
&cart_template
Cart Item Template
The chunk that holds the HTML that tells TreasureChest how to display your items in the cart. If you had a chunk called {{tcCartItem}} with the the following contents:
<tr id="cart_item_[+cart.id+]" class="cart_item[+cart.alt+]">
You would set up your "Cart" document like this.
<td class="cart_item_name[+cart.alt+]">
[+cart.item_name+]
</td>
<td class="cart_item_quantity[+cart.alt+]">
<input type="text" name="[+cart.id+]"
value="[+cart.quantity+]" size="3" maxlength="3" />
</td>
<td class="cart_item_amount[+cart.alt+]">
$[+cart.amount+] ea.
</td>
<td class="cart_item_remove[+cart.alt+]">
<a href="[~[*id*]~]&action=remove&item=[+cart.id+]" title="Remove [+cart.item_name+] from the cart.">Remove</a>
</td>
</tr>
<tr>
<td colspan="2">
[+cart.option_name_0+] [+cart.option_value_0+]
</td>
<td colspan="2">
[+cart.option_name_1+] [+cart.option_value_1+]
</td>
</tr>
[!TreasureChest? &service=`cart` &cart_template=`tcCartItem`!]
Additionally, you can specify the &cart_wrap_template to customize the look of the rest of the cart. There is some very important javascript in the default cart wrap, so only attempt this if you are sure you know what you are doing. To change the look of the cart, It might be better if you edit the file in
assets/snippets/treasure_chest/style/treasurechest.cart.css