News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

[BUGFIX?] Custom field Customer Text Input - Pricing

Started by sleepigrl, August 09, 2012, 20:17:10 PM

Previous topic - Next topic

sleepigrl

I ran across what I think is a small issue with the pricing for the custom field "Customer Text Input."   If I set the "Price Per Letter" value to Yes, everything works fine.  However, if I set it to No, the customer is charged the amount assigned in the product, whether they enter text or not.

Seems to me that the logical flow for pricing for a should be like this:

Field is Empty: NO charge

Field has text:
- Price per letter is Yes, charged per letter amount as assigned in product
- Price per letter is No, charged flat amount as assigned in product

I tracked down the code to \plugins\vmcustom\textinput\textinput.php.   Adding the following else statement to the plgVmCalculateCustomVariant function around line 336 (right after the closing } from if ($productCustomsPrice->custom_price_by_letter ==1)  allows the calculation to work as stated above.  The logic is a bit different as I didn't want to rewrite the existing code, but it seems to be working just fine for me.   


else {
if (!empty($customVariant['comment'])) {
$productCustomsPrice->custom_price = 1 * $productCustomsPrice->custom_price ;
} else {
$productCustomsPrice->custom_price = 0.0;
}
}






Milbo

I wonder about your version, my file has only 190 lines, but I think I corrected it, take a look

if (!empty($customVariant['comment'])) {
if ($productCustomsPrice->custom_price_by_letter ==1) {
$charcount = strlen ($customVariant['comment']);
} else {
$charcount = 1.0;
}
$productCustomsPrice->custom_price = $charcount * $productCustomsPrice->custom_price ;
} else {
$productCustomsPrice->custom_price = 0.0;
}
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

sleepigrl

Thanks, Milbo!  That works well and the logic makes sense, at least the way it seems to me this should work.

I'm using 2.0.8e, but my file has lots of extra whitespace.  I think that's from unix to windows linefeed conversion, I probably need to grab new copies via FTP/binary so the line numbers are correct.