如果数量增加,WooCommerce 添加到购物车按钮文本会使用 jQuery 更改 [英] WooCommerce Add To Cart Button text change using jQuery if Quantity increase
查看:17
javascript
php
jquery
wordpress
woocommerce
本文介绍了如果数量增加,WooCommerce 添加到购物车按钮文本会使用 jQuery 更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果数量增加,WooCommerce 添加到购物车按钮文本会使用 jQuery 更改.
jQuery(document).on("change",'.minus', function() {var productquantity = jQuery('.qty').attr('value');如果(产品数量 == 15){jQuery('.single-product').each(function() {jQuery(".single_add_to_cart_button").text("请求报价");});}})
虽然选择按钮值永远不会改变:S
按钮和选择器的 HTML
<input type="button" value="-" class="minus button is-form"><input type="number" step="1" min="1" max="9999" name="数量" value="1" title="数量" class="input-text qty text" size="4" pattern="[0-9]*" inputmode="numeric"><input type="button" value="+" class="plus button is-form"></div><button type="submit" name="add-to-cart" value="1520" class="single_add_to_cart_button button alt" style="display: block !important">加入购物车</button> 解决方案 jQuery(document).on("click",'.plus, .minus', function() {var productquantity = jQuery('.qty').attr('value');如果(产品数量 == 15){jQuery('.single-product').each(function() {jQuery(".single_add_to_cart_button").text("请求报价");});}否则如果(产品数量!= 15){jQuery('.single-product').each(function() {jQuery(".single_add_to_cart_button").text("现在加入购物车");});}})
唯一的问题是更改为 onclick.
WooCommerce Add To Cart Button text change using jQuery if Quantity increase.
jQuery(document).on("change",'.minus', function() {
var productquantity = jQuery('.qty').attr('value');
if (productquantity == 15) {
jQuery('.single-product').each(function() {
jQuery(".single_add_to_cart_button").text("REQUEST A QUOTE");
});
}
})
While selecting buttons value never changes :S
HTML FOR BUTTON AND SELECTOR
<div class="quantity buttons_added">
<input type="button" value="-" class="minus button is-form"><input type="number" step="1" min="1" max="9999" name="quantity" value="1" title="Qty" class="input-text qty text" size="4" pattern="[0-9]*" inputmode="numeric"><input type="button" value="+" class="plus button is-form"></div>
<button type="submit" name="add-to-cart" value="1520" class="single_add_to_cart_button button alt" style="display: block !important">Add to Cart</button>
解决方案 jQuery(document).on("click",'.plus, .minus', function() {
var productquantity = jQuery('.qty').attr('value');
if (productquantity == 15) {
jQuery('.single-product').each(function() {
jQuery(".single_add_to_cart_button").text("REQUEST A QUOTE");
});
} else if(productquantity != 15) {
jQuery('.single-product').each(function() {
jQuery(".single_add_to_cart_button").text("ADD TO CART NOW");
});
}
})
Only problem was on change to onclick.
这篇关于如果数量增加,WooCommerce 添加到购物车按钮文本会使用 jQuery 更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文
相关文章
- 删除添加到购物车通知并更改“添加到购物车"Woocommerce 中的按钮;
- 在WooCommerce中更改添加到购物车按钮的文本;
- WooCommerce 添加到购物车验证:防止添加到购物车;
- 如果产品已在购物车中,请禁用 Woocommerce 添加到购物车按钮;
- 自定义添加到购物车按钮可将多个产品添加到购物车中,数量为:woocommerce;
- woocommerce for wordpress 删除添加到购物车按钮;
- 将模式添加到woocommerce添加到购物车按钮;
- Woocommerce中产品在购物车中时,更改添加到购物车按钮样式;
- 在WooCommerce中添加到购物车后,更改自定义Ajax的“添加到购物车"按钮文本;
- 如果购物车包含特定类别(WooCommerce),则阻止添加到购物车;
- WooCommerce 添加到购物车消息通知文本;
- 添加到购物车(woocommerce)下的文本;
- 重新标记“添加到购物车"在 WooCommerce 中添加到购物车后的按钮;
- 重新标记“添加到购物车"在WooCommerce中添加到购物车后的按钮;
- Woocommerce添加到购物车ajax和微型购物车;
- 如果产品已经在购物车中,则禁用Woocommerce添加到购物车按钮;
- 在Woocommerce中单击后,将“添加到购物车"按钮更改为“查看购物车"按钮;
- WooCommerce 商店页面:添加到购物车按钮上的数量输入;
- 更改WooCommerce中特定产品的添加到购物车按钮文本;
- WooCommerce:当购物车中已有物品时,更改“添加到购物车”按钮的颜色;
- 更改Woocommerce的“添加到购物车"按钮以“查看产品"按钮;
- 更改“添加到购物车"Woocommerce 中购买产品的按钮;
- 更改 WooCommerce 添加到特定标签的购物车文本;
- woocommerce 在添加到购物车时更改价格;
- 在 WooCommerce 中添加到购物车之前清空购物车;
PHP最新文章
- 请求头字段Access-Control-Allow-Headers在预检响应中不允许Access-Control-Allow-Headers;
- 路由问题导致Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException错误;
- 什么是NCFB和NOFB模式?;
- 警告:mysqli_connect():(HY000 / 1045):访问被拒绝用户'用户名'@'localhost'(使用密码:是);
- 如何处理致命错误:cURL错误7:无法连接到xxxx端口443;
- 参数3传递给GuzzleHttp\Client :: request()必须是数组类型,给定字符串;
- phpMyAdmin的#2054无法登录到MySQL服务器;
- SSL错误SSL3_GET_SERVER_CERTIFICATE:证书验证失败;
- 在PHPExcel中设置字体颜色,字体和字体大小;
- 如何解决cURL错误(7):无法连接到主机?;