0

I'm using CarthThrob and a modify by quantity price field (CartThrob Price - Quantity). What it does:

1-3 = $5

3-9999 = $4

It lets you set a lower price as you buy more. Nice feature, but the people entering the data are adding a $ before the prices. You need to enter just the digits: 5 not $5. If the $ is added it breaks the order total calculations. All kinds of weird stuff happens, mainly the effected products are free.

How can I prevent users from entering the $ value? The setting on the field don't let me choose numeric and the CT docs don't mention this little (Big) problem.

  • 1
    Put instructions in the field telling them not to enter a $. Let your client know that's how it works. Report the bug to CT. – Jason Varga Jun 6 '13 at 2:00
  • Big bold "Just the Digits, no $" didn't help. Nor did the one-on-one training I gave them. arghhh. I can report it to CT, but these days thats not worth much. – Doug Jun 6 '13 at 16:32
  • They're getting their act together - worth a shot anyway. – Jason Varga Jun 6 '13 at 19:39
2

If your site is in HTML5, try using patterns. This answer assumes you have template-level control over the form you provide people for the price, as in Safecracker (but you'll have to explicitly code your forms, and NOT use the {display_field} inside the custom_fields loop.)

<input type="text" placeholder="" name="" pattern="[0-9]* value="{cf_name}">

or perhaps

<input type="number" etc="etc" pattern="[0-9]*>

  • It is in the CP, not front end via Safecracker. – Doug Jun 6 '13 at 16:33
1

Workaround it with JS - either via a custom accessory or, easier, the CP Add CSS/JS Add-on:

Install the CP CSS & JS add-on from here: http://devot-ee.com/add-ons/cp-css and put this in the settings for Custom JavaScript:

if ($('.cartthrobPriceQuantityThresholds').length){
    $('.cartthrobPriceQuantityThresholds input').blur(function(){
        $(this).val( $(this).val().replace(/[$]/g, '') );
    });   
}

Done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.