Hi Everyone, I'm working on a Kcart for my small online store.
I'm having a problem with customizing the regex used to validate Kcart for "sliding scale of shipping charges based on the number of this item..."
The original regex is \[\[?([^\]]*)\](\]?)\s*(%?), used to validate the shopping cart field named 'pp_shipping_scale'.
I want to customize it to allow specification of a user function name to do shipping charges calculations. This is a function I'm adding to cart_ex.php. I prefer to do this because my shipping charges are very complex, involving 8 shipping zones for international shipments (with data for about 100 countries), 8 zones for domestic (inside USA) shipments, and flat rate shipping box charges. Even the international flat rate has 8 variations depending on the country's zone.
My customization of the validation regex should allow me to specify a function name beginning "sp_" as the value of pp_shipping_scale. Here's my validation regex, which is correct: \[\[?([^\]]*)\](\]?)\s*(%?)|^sp_.*
I entered that regex in my index.php like this:
The changes are saved correctly. I also verified that they are written in the database.
However, when I try to enter the function name 'sp_carao' in the pp_shipping_scale field in the admin panel page for my product, my entry is rejected by couch's regex validation function ('validate_regex()' in functions.php). I have confirmed that validate_regex() is being passed the original regex, not my modified version. (I did that by temporarily making validate_regex() print out the regex used as part of it's error message).'
PS I just discovered that if regex validation is active, the regex specified in the template file is ignored, and the default is used. The only way to overcome this is to remove the "validator" field from the template file entry. However I don't want to remove the regex validation completely.
Any help would be greatly appreciated.
I'm having a problem with customizing the regex used to validate Kcart for "sliding scale of shipping charges based on the number of this item..."
The original regex is \[\[?([^\]]*)\](\]?)\s*(%?), used to validate the shopping cart field named 'pp_shipping_scale'.
I want to customize it to allow specification of a user function name to do shipping charges calculations. This is a function I'm adding to cart_ex.php. I prefer to do this because my shipping charges are very complex, involving 8 shipping zones for international shipments (with data for about 100 countries), 8 zones for domestic (inside USA) shipments, and flat rate shipping box charges. Even the international flat rate has 8 variations depending on the country's zone.
My customization of the validation regex should allow me to specify a function name beginning "sp_" as the value of pp_shipping_scale. Here's my validation regex, which is correct: \[\[?([^\]]*)\](\]?)\s*(%?)|^sp_.*
I entered that regex in my index.php like this:
- Code: Select all
<cms:editable
name='pp_shipping_scale'
label=':'
type='text'
validator='regex=/\[\[?([^\]]*)\](\]?)\s*(%?)|^sp_.*/'
group='group_shipping'
order='21'
/>
The changes are saved correctly. I also verified that they are written in the database.
However, when I try to enter the function name 'sp_carao' in the pp_shipping_scale field in the admin panel page for my product, my entry is rejected by couch's regex validation function ('validate_regex()' in functions.php). I have confirmed that validate_regex() is being passed the original regex, not my modified version. (I did that by temporarily making validate_regex() print out the regex used as part of it's error message).'
PS I just discovered that if regex validation is active, the regex specified in the template file is ignored, and the default is used. The only way to overcome this is to remove the "validator" field from the template file entry. However I don't want to remove the regex validation completely.
Any help would be greatly appreciated.