URL Validator-based Option [VQMOD]
Supported OpenCart Versions:
What does it do:
This plugin adds support to opencart for "URL-Based options". These types of options now contain two new properties which are used to validate the data provided by the customer when the customer tries to add the associated product to their shopping cart. The properties are:
a) URL: the URL which must be called when the user adds tries to add the item to their shopping cart. It is expected that the URL will return a JSON structure that can be evaluated. This returned JSON structure is then converted into an internal XML structure.
b) XPath expression: The provided expression is evaluated against the internal XML structure. Must return either true or false.
The admin section also contains a "tester" which allows the administrator to validate the configuration with test data.
Included is very basic PHP script which will indicate whether a provided number is even or odd or unknown.
- URL: http://OPENCART_INSTALL_URL/option_url_validation-tester-is_number_even.php?input=$INPUT
- XPATH: //is_even='YES'
On the client side the following happens:
a) URL-based option is presented to the user
b) The User's input replaces the $INPUT variable in the configured URL
c) The URL is "downloaded" using PHP curl
d) The resulting JSON is converted into an XML Structure by wrapping it around a "root" element
e) The configured XPATH is evaluated against the XML structure. If it evaluates to "false" then the cart validation fails and the user is alerted of the problem, indicating the provided input is invalid. Otherwise it is alloped.
Put another way, for step (e) above, if the xpath expression evaluates to false, then the validation will fail and the user will not be allowed to add the item to the cart.
If you have like this extension, please vote for it.
- Currently only HTTP-GET URLs are supported. Currently only a single variable is supported,
- User-provided input replaces $INPUT in the specified URL.
- The URL provided MUST return a JSON structure.
* The XPATH expression must be a valid xpath expression that evaluates to a boolean value.
It's recommended to install VQMod Manager to enable or disable the extension.
How to install it:
1) Unzip and upload the "vqmod" folder to the root of your OpenCart install. No files are overwritten and it's required to have vqmod installed.