Support » Plugin: WooCommerce » Checkout not working as ‘key’ variable not passed

  • Resolved tradik

    (@tradik)


    We are sharing a solution to a problem we had:

    1. Add to /woocommerce/woocomerce.php:

    add_filter('init', 'add_query_vars');
    
    function add_query_vars() {
    global $wp;
    $wp->add_query_var('key');
    }

    2. Replace line 194 : /woocommerce/includes/shortcodes/class-wc-shortcode-checkout.php

    
    $order_key = isset( $_GET['key'] ) ? wc_clean( wp_unslash( $_GET['key'] ) ) : ''; // WPCS: input var ok, CSRF ok.

    with:

    $order_key = get_query_var('key','');

    3. Make sure Nginx configuration has a not question mark in configuration ( official one stated to have ) as variable becomes “?key” variable not “key”

        location / {
            set $try "$uri/";
            try_files $uri $uri/ /index.php?$is_args$args;
        }

    to

        location / {
            set $try "$uri/";
            try_files $uri $uri/ /index.php$is_args$args;
        }

    Please consider changes if you find them useful. Thanks.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.