On the WP homepage I have a Form like this:
<form action="'.esc_url( admin_url('admin-post.php')).'" method="post">
//etc.
//etc.
and in the file functions.php I have this snipped of code.
function redirect_form() {
if (isset($_POST["var1"]) && !empty($_POST["var1"]) && isset($_POST["var2"]) && isset($_POST["var3"]) && !empty($_POST["var3"])) {
if ($_POST["var1"] == 'product1'){
wp_redirect(home_url('/product/product1/')); exit;
// etc.
// etc.
Everything is working as expected.
But the question is how can I get those variables on the WooCommerce single product page? I want echo those variables on the page of the product.
UPDATED:
I am trying the same thing with global variables. What I am missing?
function redirect_form() {
if (isset($_POST["var1"]) && !empty($_POST["var1"]) && isset($_POST["var2"]) && isset($_POST["var3"]) && !empty($_POST["var3"])) {
global $abc;
$abc = $_POST["var2"];
if ($_POST["var1"] == 'product1'){
wp_redirect(home_url('/products/product1/')); exit;
// etc.
// etc.
then
add_action( 'woocommerce_single_product_summary', 'dev_designs_show_sku', 5 );
function dev_designs_show_sku(){
global $product, $abc;
echo $abc;
}
It is not working. What I am missing?
UPDATED 2
then I want adjust price of the product based on those variables. Something like this.
function return_custom_price($price, $product) {
global $post, $blog_id, $abc;
$price = get_post_meta($post->ID, '_regular_price');
$post_id = $post->ID;
$price = ($price[0] + $abc);
return $price;
}
add_filter('woocommerce_get_price', 'return_custom_price', 10, 2);