我有一個OpenCart VQMod,它目前按字符計數字符串長度和收費。它完美的作品,但我需要它的規則如下收費:基於字符數計算字符串長度和收費價格的PHP函數
30-45個字符:$ 8.50
46+字符:$ 12.00
編輯: 截至目前,這個mod乘以串長度與每個角色的價格有關,但我需要它只收取30-45個字符的單位8.50美元,或46個字符以上的12美元。任何人都可以幫我修改下面的PHP嗎?我在這裏粘貼整個文件。迄今爲止,非常感謝您的回覆。我非常感謝社區的幫助。
編輯2:刪除不必要的代碼,只顯示字符串長度的藥水。
//Q: Option Price By 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;
什麼是與你的代碼的具體問題? – StephenTG
@StephenTG,我需要幫助邏輯,特別是這部分://Q:選項價格按字符 $ 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; } } – stmikhail