Table of Contents
Advanced Code Snippets for v2.0
Looking for snippets for version 1.1 or older? You can find all the old snippets available on this page. If you're using version 2.0 and a snippet you require isn't yet available below, get in touch with us.
Please note that advanced manipulation of the cart or checkout via javascript is not supported by FoxyCart, and you can break things causing lost orders, errors, and global catastrophe. The links here are provided for reference, and they very likely will not work without tinkering requiring at least intermediate javascript knowledge.
Shipping Snippets
- Custom Shipping Code - supports custom shipping code in the admin
- Custom Shipping Endpoint - for fetching shipping rates from your own shipping endpoint
- Breaking large shipments into multiple smaller packages - if you ship large weight products, use this snippet to break overweight shipments into smaller packages to return rates
- Dynamically setting the shipping origin point for live rates - for changing the origin point for shipping calculations for the whole order
- Locations Modification - for performing dynamic filtering of the countries and states available in the checkout
- Dynamically setting the shipping box dimensions for live rates - for customising the package dimensions sent to the selected live rate providers for your store
Add To Cart Snippets
- Dynamic product add to cart totals with multicurrency support - to dynamically update your product listings total price as the customer changes options before adding to cart, along with automatically switching template sets and converting product prices to different currencies.
- Update product page total price to include option modifiers - to dynamically update your product listings total price as the customer changes options before adding to cart
Cart Snippets
- Removing PayPal Button From Cart - css code to hide the “Checkout With PayPal” button from the cart
- Add an Empty Cart Button to the Cart - Twig/jQuery code to add “Empty Cart” button to the cart/checkout (modify for cart only)
- Add a Message to Coupon Area for Unapplied Coupons - Customize the coupon area by adding a message that shows when a coupon was added but hasn't met the criteria for a discount yet. You can also style the coupon text with this snippet
- Hide the Zip/Post Code Entry Input on the Cart - Customize the cart area by hiding the input for postal code. This may be useful when you are only using one live shipping rate or don't want taxes or shipping to be calculated until the customer reaches the checkout.
- Hide the add to cart forms and links before the page loads - Customize the cart by hiding the add to cart form and link elements before the page loads. This prevents a user from adding anything to the cart before a webpage fully loads.
Checkout Snippets
- Dynamic Terms of Service Link - for changing your terms of service link depending on the selected state or country
- Dynamically Require Phone Number - if you require the customer provide a phone number depending on their shipping country
- Dynamically Require Tax ID - if you require the customer provide a tax id depending on their country
- Address Validation and Auto-Completion through CraftyClicks.
- Upsell modal on the checkout - to allow customers to quickly add additional products at checkout
- Gift Wrapping checkbox on the checkout, or other upsell / add-on items from the checkout
- Adding donations on the checkout, allowing customers to add configurable price donations to cart
- Guest Checkout - to allow guest checkout without requiring the customer to enter an email address
- Prevent Shipping to PO Boxes - for preventing customers from shipping to PO Box addresses
- Setting a Max Length on Checkout Fields - if you need to limit how much text a user can enter in an address field.
- Dynamically blocking checkouts based on custom conditions - such as requiring a total order or quantity.
- Add or remove coupon code based on item in cart - Will add/remove coupon if required item is added to/removed from cart.
- Display a dropdown list with "Other" text box - Will display a dropdown list in the checkout, and will display an extra text box for “Other” input if “Other” is selected.
- Toggle tax exemption status on checkout with a checkbox - if you don't need to have a customer provide a tax ID, but want to allow them to specify that they're tax exempt
- Auto Fill and Hide Purchase Order Field - If you'd like to allow customers to submit orders without supplying payment details (use case: Quote System)
- Add a Message Above the Email Address - If you'd like to show a message to customers at the top of the checkout page
- Add an Empty Cart Button to the Cart and Checkout - Twig/jQuery code to add “Empty Cart” button to the cart/checkout (modify for checkout only)
- Dynamically populate custom checkout field options - Pull options for select, radio or checkbox form fields from an endpoint on your website
- Dynamically validate VAT ID - Uses the Pre-Payment Webhook and Vatlayer to validate VAT ID's
- Add a Message Above Shipping Rates - Add a message above shipping rates on the Checkout
Receipt Snippets
- Conversion Tracking Pixels/Scripts - general information for tracking transaction completions with third party services
- Change the "Continue To" Button Based on Products in Cart - Will allow you to customize the URL and label of the “Continue To” button based on the category (or other conditions).
- Add a link to the web receipt based on item category - Add a link to the web receipt based on the category of items in the order
- Redirect the customer to a webpage upon order completion - Redirect the customer to a webpage instead of the Foxy receipt
Email Receipt Snippets
- Email Notification for Subscriptions - if you require an email notification whenever there is a subscription event
- Category-specific receipt emails only including matching category products - Send category-specific emails that only include items from specific categories.
General Snippets
- Enable Multiple Languages - to allow your store to display multiple languages