[英]Woocommerce Variable Products not adding to the Cart
Hi Everyone i am using a woocommerce website. 大家好,我正在使用woocommerce网站。 I have added different products on my website. 我在网站上添加了其他产品。 Some of them are single and some of them are variable. 其中有些是单身的,有些是可变的。 Single products are working fine. 单一产品运行良好。 Now the issue is when i open up a variable product and tries to add into the cart i am getting an error "Please choose product options…" although i already selected an option of that product. 现在的问题是,当我打开可变产品并尝试将其添加到购物车中时,尽管我已经选择了该产品的一个选项,但是却收到错误消息“请选择产品选项...”。 When i open up the console i found this error 当我打开控制台时,我发现此错误
ReferenceError: wp is not defined
...=!1,j=!1,k=c.find(".reset_variations"),l=wp.template("variation-template"),m=wp....
The file referencing to this error is add-to-cart-variation.min.js which is located inside the woocommerce plugin folder. 涉及此错误的文件是add-to-cart-variation.min.js,该文件位于woocommerce插件文件夹中。 I have searched allot and tried different things but could not find out the result. 我已经搜索了分配,并尝试了其他方法,但找不到结果。 I have also tried disabling all the plugins and but error still remain. 我也尝试禁用所有插件,但错误仍然存在。 Please Help me out on this. 请帮我解决这个问题。
To solve this issue you can apply a simple jquery fix: 要解决此问题,您可以应用一个简单的jquery修复程序:
Add the below code in function.php 在function.php中添加以下代码
if ( ! is_admin() ) {
add_action( 'wp_enqueue_scripts', 'woocommerce_jquery_cookie_script' );
function woocommerce_jquery_cookie_script() {
// deregister script
wp_deregister_script( 'jquery-cookie' );
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_register_script( 'jquery-cookie', plugins_url( 'jquery_cookie' . $suffix . '.js', __FILE__ ), array( 'jquery' ), '1.3.1', true );
}
}
and the 2 js file can be download from the below link: 并且可以从以下链接下载2 js文件:
https://support.woothemes.com/hc/en-us/article_attachments/200746747/woocommerce-jquery-cookie-fix.zip https://support.woothemes.com/hc/zh-CN/article_attachments/200746747/woocommerce-jquery-cookie-fix.zip
Hope that helps! 希望有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.