我是WordPress/WooCommerce的新手。
我正在尝试通过Variable Products中的fancybox弹出快速查看,添加到购物车功能。
我找到并写了下面的代码;当客户登录时,它可以正常工作,但对于 guest 用户,它的显示消息是产品已添加到购物车,但在实际的购物车中没有添加。
我在用
WordPress version: 4.3.1
WooCommerce version: 2.4.12
插件:woocommerce-ajax-add-to-cart-for-variable-products
<?php include 'wp-load.php'; ?>
<script src="<?php echo get_site_url() ?>/jquery.min.js"></script>
<script type='text/javascript' src='<?php echo get_site_url() ?>/wp-content/plugins/woocommerce/assets/js/frontend/single-product.min.js'></script>
<script type='text/javascript' src='<?php echo get_site_url() ?>/wp-content/plugins/woocommerce/assets/js/frontend/add-to-cart.min.js'></script>
<script type='text/javascript' src='<?php echo get_site_url() ?>/wp-content/plugins/woocommerce-ajax-add-to-cart-for-variable-products/js/add-to-cart-variation.min.js'></script>
<script type='text/javascript' src='<?php echo get_site_url() ?>/wp-content/plugins/woocommerce/assets/js/frontend/add-to-cart-variation.min.js'></script>
<?php global $product, $woocommerce, $yith_wcwl_init; ?>
<?php wc_print_notices(); ?>
<?php
woocommerce_variable_add_to_cart();
echo do_action( 'woocommerce_add_to_cart_form' );
?>
提前致谢。
最佳答案
请转到Woocommerce-设置
导航到“帐户和隐私”
在“客户结帐”中打勾“允许客户在没有帐户的情况下下订单”
关于php - woocommerce_variable_add_to_cart对访客用户不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49271786/