admin管理员组文章数量:1289874
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"
/* PHP Code on functions.php */
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="http://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
// this is used for taxing:
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
本文标签: WooCommercedynamically loading checkout page using ajax not showing payment methods for guest
版权声明:本文标题:WooCommerce - dynamically loading checkout page using ajax not showing payment methods for guest 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741474557a2380802.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论