Skip to content

Instantly share code, notes, and snippets.

@MjHead
Last active July 1, 2019 07:30
Show Gist options
  • Select an option

  • Save MjHead/90f529b822cc636244c0171090932358 to your computer and use it in GitHub Desktop.

Select an option

Save MjHead/90f529b822cc636244c0171090932358 to your computer and use it in GitHub Desktop.
<?php
add_filter( 'jet-engine/listings/allowed-callbacks', 'jet_he_add_calc_callback', 10, 2 );
function jet_he_add_calc_callback( $callbacks ) {
$callbacks['jet_he_calc_fileds'] = 'Calculated total price';
$callbacks['jet_he_calc_fileds_no_discount'] = 'Calculated total price (without discount)';
return $callbacks;
}
function jet_he_calc_fileds( $field_1_value ) {
$license_fee = absint( get_post_meta( get_the_ID(), 'license-fee', true ) );
$discount = absint( get_post_meta( get_the_ID(), 'discount', true ) );
return $field_1_value + $license_fee - $discount;
}
function jet_he_calc_fileds_no_discount( $field_1_value ) {
$license_fee = absint( get_post_meta( get_the_ID(), 'license-fee', true ) );
return $field_1_value + $license_fee;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment