Stripe信用卡不使用WooCommerce模式结帐
我想将Stripe Checkout用于模态而不是结帐页面,但是当[WooCommerce_Checkout]
快捷代码移动到模态时,Stripe Checkout表单被禁用,并且它可以作为页面结帐。
这是下面的主要功能
add_action( 'wp_ajax_getCheckoutPageContent', 'getCheckoutPageContentCallBack' );
add_action( 'wp_ajax_nopriv_getCheckoutPageContent', 'getCheckoutPageContentCallBack' );
function getCheckoutPageContentCallBack() {
$product_id = absint( $_POST['product_id'] );
$quantity = absint( $_POST['quantity'] );
$product_status = get_post_status( $product_id );
$passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, $quantity );
if ( WC()->cart->add_to_cart( $product_id, $quantity ) ) {
do_action( 'woocommerce_ajax_added_to_cart', $product_id );
global $woocommerce;
$items = $woocommerce->cart->get_cart();
wc_setcookie( 'woocommerce_items_in_cart', count( $items ) );
wc_setcookie( 'woocommerce_cart_hash', md5( json_encode( $items ) ) );
do_action( 'woocommerce_set_cart_cookies', true );
define( 'WOOCOMMERCE_CHECKOUT', true );
echo do_shortcode('[woocommerce_checkout]');
}else{
define( 'WOOCOMMERCE_CHECKOUT', true );
echo do_shortcode('[woocommerce_checkout]');
}
die();
}
,下面的模式下面的
<!-- Start Booking Popup Modal Area -->
<div class="booking-popup-modal-area modal right fade" id="Booking-Popup-Modal" tabindex="-1" role="dialog" aria-labelledby="Booking-Popup-Modal" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<button type="button" class="btn-close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<div class="modal-body">
<div id="checkOutPageContent">
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function customCheckout(event){
var wp_ajax_url="<?php echo site_url();?>/wp-admin/admin-ajax.php";
var data = {
action: 'getCheckoutPageContent',
product_id: jQuery(event.target).data('productid'),
quantity: 1
};
jQuery.post( wp_ajax_url, data, function(content) {
jQuery("#checkOutPageContent").html(content);
jQuery("#Booking-Popup-Modal").modal('show');
});
}
</script>
<!-- End Booking Popup Modal Area -->
完整问题您可以在下面的屏幕截图
”在网络上找到任何合适的解决方案。
我现在该怎么办?
我在那里想念什么?
谢谢
I want to use the Stripe checkout into a modal instead of a checkout page but when the [woocommerce_checkout]
shortcode move to the modal the Stripe checkout form gets disabled and it's completely working as page checkout.
Here is the main function like below
add_action( 'wp_ajax_getCheckoutPageContent', 'getCheckoutPageContentCallBack' );
add_action( 'wp_ajax_nopriv_getCheckoutPageContent', 'getCheckoutPageContentCallBack' );
function getCheckoutPageContentCallBack() {
$product_id = absint( $_POST['product_id'] );
$quantity = absint( $_POST['quantity'] );
$product_status = get_post_status( $product_id );
$passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, $quantity );
if ( WC()->cart->add_to_cart( $product_id, $quantity ) ) {
do_action( 'woocommerce_ajax_added_to_cart', $product_id );
global $woocommerce;
$items = $woocommerce->cart->get_cart();
wc_setcookie( 'woocommerce_items_in_cart', count( $items ) );
wc_setcookie( 'woocommerce_cart_hash', md5( json_encode( $items ) ) );
do_action( 'woocommerce_set_cart_cookies', true );
define( 'WOOCOMMERCE_CHECKOUT', true );
echo do_shortcode('[woocommerce_checkout]');
}else{
define( 'WOOCOMMERCE_CHECKOUT', true );
echo do_shortcode('[woocommerce_checkout]');
}
die();
}
And the modal below
<!-- Start Booking Popup Modal Area -->
<div class="booking-popup-modal-area modal right fade" id="Booking-Popup-Modal" tabindex="-1" role="dialog" aria-labelledby="Booking-Popup-Modal" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<button type="button" class="btn-close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<div class="modal-body">
<div id="checkOutPageContent">
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function customCheckout(event){
var wp_ajax_url="<?php echo site_url();?>/wp-admin/admin-ajax.php";
var data = {
action: 'getCheckoutPageContent',
product_id: jQuery(event.target).data('productid'),
quantity: 1
};
jQuery.post( wp_ajax_url, data, function(content) {
jQuery("#checkOutPageContent").html(content);
jQuery("#Booking-Popup-Modal").modal('show');
});
}
</script>
<!-- End Booking Popup Modal Area -->
The complete issue you can see in the below screenshot
I can't understand anything and didn't find any suitable solution on the web.
What should I do now, please?
What I am missing there?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论