Table of Contents
- type:
- integration
- system:
- MODx
- name:
- PHx raw url encode
- description:
- Clean up your "add to cart" links with a custom PHx modifier
- tag:
- validation
PHx Raw URL Encode
Please note: The code on this page is submitted by members of the FoxyCart community, and may not verified by FoxyCart.com LLC in any way, shape, or form. Please double check the code before installing. If you need help with it please post in our forum, but if we cannot offer assistance (due to unfamiliarity with this particular system or language) we apologize in advance.
This is a simple PHx plugin to allow you to raw URL encode values that might be in your “add to cart links”
Why you'd want this
This is really handy in making sure your links are valid HTML/XHTML, and in making sure that undesirable characters (like ? or &) that your clients might enter into TVs or Document Objects aren't sent to FoxyCart (which could break things).
The Code
Create a new snippet called phx:rawurlencode
and paste the following into it.
<?php return rawurlencode($output); ?>
Usage
Pretty simple. First, make sure you have PHx installed and set up correctly. Then create the snippet as noted above.
Then, you simply call the customer PHx modifier where necessary. If you were planning on making a link (in a chunk or template or whatever) like this:
<a href="https://YOURDOMAIN.foxycart.com/cart?name=[*product_title*]&price=[*price*]">Add to Cart</a>
You'd do this instead:
<a href="https://YOURDOMAIN.foxycart.com/cart?name=[*product_title:rawurlencode*]&price=[*price*]">Add to Cart</a>