cart->add_to_cart( get_option('sg_donation_product_id'), 1, null, null, $cart_item_data ); wp_safe_redirect( wc_get_checkout_url() ); exit(); } } // adding custom price add_action( 'woocommerce_before_calculate_totals','add_custom_price'); function add_custom_price( $cart_object ) { foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { if($cart_item['product_id'] == get_option('sg_donation_product_id')){ $custom_price = $cart_item['_other_options']['product-price']; // This will be your custom price $cart_item['data']->set_price($custom_price); } } }