Welcome to our Support Portal › Forums › WooCommerce Personalized Product Options Manager (PPOM) › [Textcounter Addon] Price Calculation
- This topic has 9 replies, 2 voices, and was last updated 4 years, 1 month ago by
nmedia.
-
AuthorPosts
-
October 16, 2019 at 6:56 pm #14082
Lievelabels.nl
ParticipantIt seems that when I’m using price per character, the javascript calculation is ok, but when I add to cart, only a-zA-Z is calculated and numbers and !@#$%^&*( and spaces are ignored.
Can you please check?prices.php line 389.
Cannot add the code itself…..It seems that you need to add hidden PPOM meta, that defines if we need to count spaces or not, and we need to also include counting all characters, not only alphabet.
-
This topic was modified 4 years, 1 month ago by
Lievelabels.nl. Reason: responsible code added
-
This topic was modified 4 years, 1 month ago by
Lievelabels.nl.
October 17, 2019 at 4:19 pm #14097Lievelabels.nl
ParticipantFound the issue.
prices.php line 385 change whole case:case 'textcounter': // ppom_pa($field_meta); $count_type = $field_meta['count_type']; $enabled_space = isset($field_meta['enabled_space']) ? $field_meta['enabled_space'] : false; switch($count_type){ case 'character': if($enabled_space=="on"){ $length = preg_match_all ('/[^\.]/' , $value, $matches); } else { $length = preg_match_all ('/[^ \.]/' , $value, $matches); } break; case 'word': default: $length = str_word_count($value); } $price = $field_meta['count_price'] * $length; $field_prices[] = ppom_generate_field_price($price, $field_meta, $charge, $options, 1); break;
-
This reply was modified 4 years, 1 month ago by
Lievelabels.nl.
-
This reply was modified 4 years, 1 month ago by
Lievelabels.nl.
-
This reply was modified 4 years, 1 month ago by
Lievelabels.nl.
October 21, 2019 at 9:05 am #14114nmedia
KeymasterOk, just added this in the next version.
Thanks 🙂
October 21, 2019 at 9:07 am #14115Lievelabels.nl
ParticipantBig thumbs up!
October 24, 2019 at 11:21 am #14128Lievelabels.nl
ParticipantI did a change to the REXEX to also support Unicode Characters:
case 'character': if($enabled_space=="on"){ $length = preg_match_all ('/[^\.]/su' , $value, $matches); } else { $length = preg_match_all ('/[^ \.]/su' , $value, $matches); }
October 27, 2019 at 1:07 pm #14143nmedia
KeymasterWhere is code?
October 28, 2019 at 7:57 am #14148Lievelabels.nl
Participantwoocommerce-product-addon\inc\pices.php line 385:
case 'textcounter': // ppom_pa($field_meta); $count_type = $field_meta['count_type']; $enabled_space = isset($field_meta['enabled_space']) ? $field_meta['enabled_space'] : false; switch($count_type){ case 'character': if($enabled_space=="on"){ $length = preg_match_all ('/[^\.]/su' , $value, $matches); } else { $length = preg_match_all ('/[^ \.]/su' , $value, $matches); } break; case 'word': default: $length = str_word_count($value); } $price = $field_meta['count_price'] * $length; $field_prices[] = ppom_generate_field_price($price, $field_meta, $charge, $options, 1); break;
October 28, 2019 at 2:18 pm #14153nmedia
KeymasterOk I see, by the way you have sent the add-on with all these changes? right?
October 28, 2019 at 2:34 pm #14154Lievelabels.nl
ParticipantThis needs to be done in the core plugin: prices.php
Because this is where you have put the price calculation in the back-end.October 29, 2019 at 4:11 pm #14165nmedia
KeymasterHi,
Ok noted.
-
This topic was modified 4 years, 1 month ago by
-
AuthorPosts
- You must be logged in to reply to this topic.