• Resolved buzibuzi

    (@buzibuzi)


    Following this answer on how to dynamically load checkout page using ajax in Woocommerce.

    when using this js/php code to get the checkout page fragment

    1.If im logged in it works fine and the defined payment methods (Paypal, bank transfer, checks) are showing up (OK)

    2.for guest users, im getting the error: “Sorry, it seems that there are no available payment methods for your state”

    add_action( 'wp_ajax_getCheckoutPageContent', 'getCheckoutPageContentCallBack' );
    add_action( 'wp_ajax_nopriv_getCheckoutPageContent', 'getCheckoutPageContentCallBack' );
    
    function getCheckoutPageContentCallBack() {
    
        define( 'WOOCOMMERCE_CHECKOUT', true );
        echo do_shortcode('[woocommerce_checkout]'); 
    
        die();
    }
    
    /* JS Code to be called on callback*/
    var wp_ajax_url="https://yourwebsite/wp-admin/admin-ajax.php";
    var data = {
        action: 'getCheckoutPageContent'
    };
    
    jQuery.post( wp_ajax_url, data, function(content) {
        // append content to my custom one page checkout 
    });

    i tried to add this filter

    
    add_filter('woocommerce_countries_base_country', 'set_base_to_usercountry', 1, 1);
    
    // and this is used for shipping:
    add_filter('woocommerce_customer_default_location', 'set_base_to_usercountry', 1, 1);
    
    function set_base_to_usercountry($country) {
        $country = MYCOUNTRYCODE; 
        return $country;
    }

    but this didnt help. Any ideas how to fix this ? Thank you

    • This topic was modified 3 years, 8 months ago by buzibuzi.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Hi there ??

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers.

    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

    Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘loading checkout page using ajax not showing payment methods for guest users’ is closed to new replies.