Last active
January 23, 2018 15:26
-
-
Save plugin-republic/4746b252462a36963b8de3643580c13d 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 add_cart_item_data( $cart_item_data, $product_id, $variation_id ) { | |
// Has our option been selected? | |
if( ! empty( $_POST['extended_warranty'] ) ) { | |
$product = wc_get_product( $product_id ); | |
$price = $product->get_price(); | |
// Store the overall price for the product, including the cost of the warranty | |
$cart_item_data['warranty_price'] = $price + 250; | |
} | |
return $cart_item_data; | |
} | |
add_filter( 'woocommerce_add_cart_item_data', 'add_cart_item_data', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment