rusivada
Forum Replies Created
-
Forum: Plugins
In reply to: [WPC Order Tip for WooCommerce] Does not calculate percentage@janilyn409 – Here is the fix that needs to be implemented by your development team in class-frontend.php. I have commented out the original code and added the statement below. The float(value) will always be a number and will not be a string, which is what is entered on the front end.
if ( isset( $all_tips[ $key ] ) ) {
//$tips[ $key ][‘value’] = abs( (float) $value );
$tips[ $key ][‘value’] = $value ;
Forum: Plugins
In reply to: [WPC Order Tip for WooCommerce] Does not calculate percentageI tried by putting in a min and max value. Still doesn’t work. I think the developer needs to look at this piece of code from the class_frontend.php. I think he is first cleaning the string (which will strip out the ‘%’) and then doing a check in the IF statement to see if there is a ‘%’ sign to do a calculation as a percentage. If no ‘%’ sign is there, it will treat is as an absolute number and apply the amount. No matter what, it will always go into the ELSE part of the command.
if ( isset( $all_tips[ $k ] ) ) {
$tip = array_merge( $tip, [ ‘key’ => $k ], $all_tips[ $k ] );
$value = self::clean_value( $tip[‘value’] );
if ( ! empty( $value ) ) {
if ( str_contains( $value, ‘%’ ) ) {
$subtotal = apply_filters( ‘wpcot_cart_subtotal’, WC()->cart->get_subtotal() );
$amount = ( (float) $value / 100 ) * $subtotal;
} else {
$amount = (float) $value;
}
Forum: Plugins
In reply to: [WPC Order Tip for WooCommerce] Does not calculate percentageCannot get the tip block to show up after product summary and before subtotal.