Add To Cart
Use our Forums to find examples and answers to your questions. If you have advanced requirements for your project, contact us and our staff can help you find a solution.
Add To Cart Tag
Name: addtocart
The addtocart tag provides an easy way to add shopping cart forms into your templates. The addtocart tag sends your product information securely to FoxyCart using JSON. This information is then used for the cart tag and the checkout page. It also includes several parameters to easily configure how you want your form to operate, including the ability to bypass the Foxybox cart and go straight to the checkout form..
{exp:foxee:addtocart id="{entry_id}" block_foxybox="yes"}
Parameters
id="2"
Description: The entry Id of the product you want to use in the addtocart form. If used inside the weblog:entries tag, you can pull it dynamically by using {entry_id}
Required: Yes
Default: none
disable="related_products"
Description: You can disable certain features of the addtocart tag. Separate each by using the pipe ( | ) character.
Required: no
Default: none
Possible values: related_products, custom_fields, pricing_options, discounts, product_limit_quantity, pricing_options_inventory_check
method="form"
Description: This will output either a form with a submit button or a form with a link
Required: no
Default: form
Possible values: form, link
label="your text here"
Description: This will set the inner HTML of the submit button or link to text
Required: no
Default: Add To Cart
Possible values:
image="/img/your_image.jpg"
Description: Sets the inner HTML of the link or submit button to an image. The value should be a URL to an image
Required: no
Default:
Possible values:
class="your_class_name"
Description: Sets the form elements to a specified class
Required: no
Default:
Possible values:
Here is a typical form output using the class parameter set to test
<form id="foxycart_5" method="post" action="https://your.foxycart.com/cart" class="foxycart">
<input type="hidden" name="block_fb" value="false" />
<input type="hidden" name="x:sku" value="5" />
<input type="hidden" name="code" value="00005" />
<input type="hidden" name="weight" value="10.00" />
<input type="hidden" name="name" value="Shippable" />
<input type="hidden" name="price" value="10.00" />
<input type="hidden" name="category" value="SHIPPING" />
<div class="foxee_pricing_options">
Color: <select name="color" class="test">
<option value="Red{p+0.00|w+0.00}">Red</option>
<option value="White{p+0.00|w+0.00}">White</option>
<option value="Blue{p+0.00|w+0.00}">Blue</option>
</select>
</div>
<div class="foxee_pricing_options">
Size: <select name="size" class="test">
<option value="Small{p+1.00|w+1.00}">Small</option>
<option value="Medium{p+2.00|w+2.00}">Medium</option>
<option value="Large{p+3.00|w+3.00}">Large</option>
<option value="X-large{p+4.00|w+4.00}">X-large</option>
<option value="XX-Large{p+5.00|w+5.00}">XX-Large</option>
</select>
</div>
<input name="quantity" type="text" size="3" value="1" />
<input type="submit" name="submit" value="Add to Cart" class="foxycart_link test" />
</form>
number_format="0"
Description: Determines the number of decimal places for your price. A setting of 2 will produce standard currency formatting of two decimal places ($4.00).
Required: no
Default: 2
Possible values:
empty="yes"
Description: This will empty the FoxyCart before placing the product into it.
Required: no
Default:
Possible values: yes, no
cart="checkout"
Description: Changes the form action to view the cart - go straight to the checkout form or go to the updateinfo form
Required: no
Default: view
Possible values: view, checkout, updateinfo - You can also go straight to paypal checkout using "checkout_paypal_express", you must have the paypal option selected in your foxycart settings.
category="shipping"
Description: Sets the category to use for the product.
Required: no
Default: Whatever the products settings are
Possible values:
hide_fields="shipping"
Description: Set to fields that you would like to be session variables in the form.
Required: no
Default:
Possible values:
exclude_fields="donation_min"
Description: Set to the field names you don't want to go into FoxyCart. These Fields will still show up on the Orders Page in FoxEE. Separate each by '|'.
Required: no
Default: donation_min|donation_max|sku|fe_memberid|fe_siteid
Possible values:
form_begin="yes"
Description: Only display the start of the form plus any hidden fields. Useful for custom addtocart forms.
Required: no
Default: no
Possible values: yes, no
block_foxybox="no"
Description: This will essentially block the display of FoxyBox when product is added. This is very useful when using the cart tag to show your cart contents dynamically.
Required: no
Default: no
Possible values:
discount_id="1"
Description: This will apply a discount that is setup in the FoxEE CP Discounts section. The value is the id of the discount.
Required: no
Default:
Possible values:
Adding Custom Information To Your Form
You can add any amount of custom information to your addtocart form by creating a parameter. This information will be passed to the checkout form as well as your FoxEE Orders Tab. You can use any word except the above parameters and the reserved words outlined below. This is very useful to pass information dynamically.
The following words are reserved:
- name
- price
- entry_id
- category
- cart
- empty
- quantity
- quantity_min
- quantity_max
- code
- weight
- sub_frequency
- sub_startdate
- discount_quantity_amount
- discount_quantity_percentage
- discount_price_amount
- discount_price_percentage
- output
- id
- class
- label
- method
- number_format
- image
- block_foxybox
