PHP Function that Counts String Length and Charges Price Based on # of Characters -
i've got opencart vqmod counts string length , charges character. works perfectly, need charge following rules:
30-45 characters: $8.50
46+ characters: $12.00
edit: of now, mod multiplies string length set price per character, need charge flat $8.50 30-45 characters, or $12 46+ characters. can me modify following php? i'm pasting entire file here. responses far. appreciate of community.
edit 2: removed unnecessary code, showing string length potion.
//q: option price character $optprice = ''; $optprefix = ''; if ($option_query->row['type'] == 'text' || $option_query->row['type'] == 'textarea') { if (strlen($option_value)) { $optprice = (strlen($option_value) * $option_query->row['price_per_char']); $optprefix = '+'; $option_price += $optprice;
if ($option_query->row['type'] == 'text' || $option_query->row['type'] == 'textarea') { if (strlen($option_value)) { // lumberjack's new code $string_length = strlen($option_value); if($string_length >= 30 && $string_length <= 45) { $optprice = 8.5; } else if($string_length >= 46) { $optprice = 12.00; } else { // end new code $optprice = (strlen($option_value) * $option_query->row['price_per_char']); } // moved 2 lines $optprefix = '+'; $option_price += $optprice; } }
Comments
Post a Comment