---- dataentry integration ----
type : integration # do not change this line
supports-foxycart-version-from : 0.7.0 # Minimum required FoxyCart version for this to work
supports-foxycart-version-to : # Last FoxyCart version that supports this (leave empty if unknown)
systems : MODx Revolution, MODx Evolution # the system(s) that the integration is for, separated with commas if more than one
name : HMAC Price Validation # the name of the integration
description : A plugin to automatically verify all links and forms output using MODX Revo and Evo #
tags : hmac # tags, separated by commas. don't include the "system" here.
date_dt : 2011-06-28 # the date in YYYY-MM-DD format
version : # if you have a version for your code, enter it here
developer_url : # if you'd like a link back to your site, stick it here
----
//**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 [[http://forum.foxycart.com/|post in our forum]], but if we cannot offer assistance (due to unfamiliarity with this particular system or language) we apologize in advance.
Depending on which version of MODx you're working with - please review the different sections below, with approaches for MODx Revo and Evolution.
====== Automatic HMAC Price Validation for MODX Revo + FoxyCart ======
===== Description =====
Automatically validates all links and forms on pages generated by [[http://modx.com/|MODX Revolution]], according to FoxyCart's [[:static:redirect:price_validation|HMAC Price Validation]] functionality.
This plugin is easy to install, and should "just work", so it is recommended for all MODX Revo installs.
Thanks to [[https://forum.foxycart.com/discussion/comment/54748/#Comment_54748|pixelchutes on our forums]] for this solution.
===== Installation =====
- Create a directory in your ''assets/plugins'' directory called ''foxycart_validation'' (creating the ''plugins/'' folder if it doesn't already exist).
- Download the source ''foxycart.cart_validation.php'' file [[https://github.com/FoxyCart/FoxyCart-Cart-Validation--PHP|here]] and put it into the newly created ''assets/plugins/foxycart_validation/'' directory.
- Edit that file and enter the appropriate ''$secret'' and ''$cart_url'' values. (The ''$secret'' value is your store's API / datafeed key.)
- Within MODx, under "Elements" create a plugin named "FoxyCart Validation".
- Paste in the code below into the "Plugin Code" textarea.
- In the "System Events" tab, check the ''OnWebPagePrerender'' checkbox.
- Save the plugin.
- Go to your [[https://admin.foxycart.com/|FoxyCart admin]] and enable the price validation under your "advanced" section. Save.
- Test.
- Test some more.
{{ :integration:modx:modx_revo_validationplugin.png?nolink&700 |}}
After creating the plugin - any add to cart link or forms on your website should be automatically signed for you.
===== Requirements =====
* All add to carts need to have a ''code'' attribute, and it should not have leading or trailing whitespace.
* Cannot use double-pipes in an input's name.
* Empty textareas are assumed to be "open".
===== Code =====
event;
switch ($e->name) {
case 'OnWebPagePrerender':
include $modx->config["base_path"].'assets/plugins/foxycart_validation/foxycart.cart_validation.php';
$modx->resource->_output = FoxyCart_Helper::fc_hash_html($modx->resource->_output);
break;
}
return;
====== Automatic HMAC Price Validation for MODX Evolution + FoxyCart ======
===== Description =====
Automatically validates all links and forms on pages generated by [[http://modx.com/|MODX Evolution]], according to FoxyCart's [[:static:redirect:price_validation|HMAC Price Validation]] functionality.
This plugin is easy to install, and should "just work", so it is recommended for all MODX Evolution installs.
===== Installation =====
- Create a directory in your ''assets/plugins/'' directory called ''foxycart_validation''.
- Download the source file [[https://github.com/FoxyCart/FoxyCart-Cart-Validation--PHP|here]] and put it into the newly created ''assets/plugins/foxycart_validation/'' directory.
- Edit that file and enter the appropriate ''$secret'' and ''$cart_url'' values. (The ''$secret'' value is your store's API / datafeed key.)
- Create a plugin named "FoxyCart Validation".
- In the "System Events" tab, check the ''OnWebPagePrerender'' checkbox.
- Paste in the code below and save.
- Go to your [[https://admin.foxycart.com/|FoxyCart admin]] and enable the price validation under your "advanced" section. Save.
- Test.
- Test some more.
===== Requirements =====
* Form "code" values should not have leading or trailing whitespace.
* Cannot use double-pipes in an input's name.
* Empty textareas are assumed to be "open".
===== Code =====
/**
* FoxyCart Validation Plugin for MODx 1.x (Evolution)
*
* @author FoxyCart.com
* @copyright FoxyCart.com LLC, 2010
* @version 0.7.0.20100730
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
* @example http://wiki.foxycart.com/docs/cart/validation
*
* Requirements:
* - Form "code" values should not have leading or trailing whitespace.
* - Cannot use double-pipes in an input's name
* - Empty textareas are assumed to be "open"
*/
$e = &$modx->Event;
switch ($e->name) {
case "OnWebPagePrerender":
$validate = $modx->config["base_path"].'assets/plugins/foxycart_validation/foxycart.cart_validation.php';
if (file_exists($validate)) {
include_once($validate);
$doc = $modx->documentOutput;
$modx->documentOutput = FoxyCart_Helper::fc_hash_html($doc);
}
break;
default: // stop here
return;
break;
}
====== Manual HMAC Price Validation for MODX Evolution + FoxyCart ======
===== Description =====
Creates a snippet to manually validates links and forms in your pages, according to FoxyCart's [[:static:redirect:price_validation|HMAC Price Validation]] functionality.
===== Installation =====
==== Create a MODX snippet ====
**Snippet Name:**
FoxyCartGetHMAC
**Snippet Code (paste into text box):**
==== Snippet Usage ====
[[FoxyCartGetHMAC &varName=`input-name-attrib-tag-here` &varValue=`input-value-attrib-tag-here` &varCode=`sku-code-here` ]]
Example:
Notice the parts where the variable name code is the same: ''name="code and &varName=`code`''
and where the value is the same: ''value="[*sku*]" and &varValue=`[*sku*]`''
and where ''&varCode=`[*sku*]`'' should be something unique to your product, like the SKU code
===== Example Form =====
Assuming you're using template variables price as ''[*price*]'' and sku as ''[*sku*]'' and using the pagetitle and SKU for the product name as ''[*pagetitle*] - [*sku*]'', and that there's only a single SKU for a single product represented by a resource in the MODX Tree: