Woocommerce checkout in popup

I am trying to implement checkout fuctionality (+ stripe with WooCommerce Stripe Payment Gateway plugin) in a modal and I am using ajax for that. Here is my internal code to get / update the skin:

add_action('wp_ajax_refresh_checkout', 'getCheckoutPageContentCallBack');
add_action('wp_ajax_nopriv_refresh_checkout', 'getCheckoutPageContentCallBack');

function getCheckoutPageContentCallBack() {
    define('WOOCOMMERCE_CHECKOUT', true);
    echo do_shortcode('[woocommerce_checkout]');
    if (class_exists('WooCommerce')) {
        $wcurl = WooCommerce::plugin_url();

        $credit_card_form_script = file_get_contents($wcurl . '/assets/js/frontend/credit-card-form.min.js');
        if ($credit_card_form_script) {
            echo "<script>";
            echo $credit_card_form_script;
            echo "</script>";
        }

        $checkout_script = file_get_contents($wcurl . '/assets/js/frontend/checkout.min.js');
        if ($checkout_script) {
            echo "<script>";
            echo $checkout_script;
            echo "</script>";
        }
    }
    wp_die();
}

      

I have included all scripts, on the checkout page, but I still get the error:

Please enter your card details to make a payment. Developers: Make sure you have jQuery enabled and there are no JavaScript errors on the page.

jQuery is included and there are no js errors on the page. The original checkout page works just fine. I thought the problem was that I removed the payment part from the original part with this code:

remove_action('woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20);
add_action('woocommerce_checkout_order_payment', 'woocommerce_checkout_payment', 20);

      

But commenting out these lines gave me nothing. I edited the page so that now it is not even a store page (just a page with a loop). I noticed that when making payments through the checkout page, the first request goes to https://api.stripe.com/v1/tokens with card credentials, the next one goes to / checkout /? wc-ajax = checkout with stripe_token and so on. When I try to check from my modal code, there is no sripe API request, just to check. Maybe there is a few script that needs to be included every time I update the checkout? Can't find information about this.

+3


source to share





All Articles