Answer the question
In order to leave comments, you need to log in
How to get $_POST request in functions.php in Wordpress?
Good day!
There is a form:
<form method="POST" action="<?php echo $link_address;?>">
<input type="hidden" name="custom_price" id="custom_price" value="<?php echo round( $pricing->hours ); ?>" min="1" />
<input type="hidden" name="priceform" id="pricef" value="<?php echo $pricing->base; ?>" />
<button type="submit" class="btn btn-success">Бронь</button>
</form>
$pricequery = $_POST['custom_price'];
add_filter( 'woocommerce_get_discounted_price', 'calculate_discounted_price', 10, 2 );
add_filter( 'woocommerce_cart_item_subtotal', 'display_discounted_price', 10, 2 );
function calculate_discounted_price( $price, $values ) {
$price += $pricequery;
return $price;
}
function display_discounted_price( $values, $item ) {
return wc_price( $item[ 'line_total' ] );
}
$price += 10;
Answer the question
In order to leave comments, you need to log in
I don't see in the code that you get it. There is definitely no specified variable inside the calculate_discounted_price function. Well add:
function calculate_discounted_price( $price, $values ) {
$pricequery = (float)$_POST['custom_price'];
$price += $pricequery;
return $price;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question