Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Show total and remaining amount on the front end product page.
function bkap_appending_additional_information_to_price( $display_price, $wp_send_json ) {
$total = $wp_send_json['total_price_calculated'];
$price = $wp_send_json['bkap_price_charged'];
if ( $total != $price ) {
$wc_price_args = bkap_common::get_currency_args();
$remaining = $total - $price;
$total_label = get_option( 'bkap_total_amt_label', '' );
$total_display = $total_label . wc_price( $total, $wc_price_args ) . '<br>'; // Total Price.
$remaining_label = get_option( 'bkap_remaining_amt_label', '' );
$remaining_display = $remaining_label . wc_price( $remaining, $wc_price_args ); // Remaining Price.
$display_price = $total_display . $display_price . '<br>' . $remaining_display;
}
return $display_price;
}
add_filter( 'bkap_appending_additional_information_to_price', 'bkap_appending_additional_information_to_price', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment