I’m little frustrated with a problem.
Externally i load to my website a custom query variable on the URL.
Example: https://mywebsite.com/mypage/?source=webview?origin=Android
Varibles: source=webview and origin=Android or origin=IOS
This variables let me know if the web is loaded from my webview app and what OS has the device (IOS or Android).
I try a lots of ways to get this work.
One of this ways is trying to use $_GET like this example:
add_action('woocommerce_checkout_create_order', 'before_checkout_create_order3', 20, 2);
function before_checkout_create_order3( $order, $data ) {
$origen3 = $_GET('device');
$order->update_meta_data( '_origen3', $origen3 );
}
But i can’t save with php the Device and always have an empty value on my var.
Y also try with get_query_var and here i have two problems.
When i try to save the variable with get_query_var like this:
$device = get_query_var( 'Device' );
I have an empty variable.
If i declare the query_var i have a redirection error.
This is my example:
function test_query_vars( $qvars ) {
$qvars() = 'device';
return $qvars;
}
add_filter( 'query_vars', 'test_query_vars' );
Here i think is something missing because i get the device saved but when i try to go to the home the page redirect to another page. I try re-save the permalinks and the .htaccess file but nothing works.
tnks on advice.