Last active
January 23, 2018 16:09
-
-
Save plugin-republic/b22a91760439d07bea9b1ec0dc601b48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function before_calculate_totals( $cart_obj ) { | |
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { | |
return; | |
} | |
// Iterate through each cart item | |
foreach( $cart_obj->get_cart() as $key=>$value ) { | |
if( isset( $value['warranty_price'] ) ) { | |
$price = $value['warranty_price']; | |
$value['data']->set_price( ( $price ) ); | |
} | |
} | |
} | |
add_action( 'woocommerce_before_calculate_totals', 'before_calculate_totals', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment