woocommerce 基于重力形式单选按钮添加到购物车
wooommerce add to cart based on gravity form radio button
我有一个 WooCommerce 重力表单,用户可以根据单选按钮选择选择一个包进行注册。我想根据选择将 woocommerce 产品添加到购物车。下面是单选按钮组的 html 和 js 但它没有触发:
<script>
$('#choice_1_112_0').click(function() {
window.location.href = 'www.domian.com/?add-to-cart=125';
return false;
});
</script>
<ul class="gfield_radio" id="input_1_112">
<li class="gchoice_1_112_0">
<input name="input_112" type="radio" value="Normal Package" id="choice_1_112_0">
<label for="choice_1_112_0" id="label_1_112_0">Normal Package</label>
</li>
<li class="gchoice_1_112_1">
<input name="input_112" type="radio" value="eTrade Package" id="choice_1_112_1">
<label for="choice_1_112_1" id="label_1_112_1">eTrade Package</label>
</li>
</ul>
我用一个简单的 JS 脚本来实现触发按钮点击并将产品直接添加到购物车
jQuery("#btn_349").on("click", function(){
jQuery("#choice_1_112_0").prop("checked", true);
jQuery("#btn_350").text("Select");
jQuery("#btn_349").text("Selected");
jQuery(this).css("background-color", "#c11c2d");
jQuery("#btn_350").css("background-color", "#333335");
});
jQuery("#btn_350").on("click", function(){
jQuery("#choice_1_112_1").prop("checked", true);
jQuery("#btn_349").text("Select");
jQuery("#btn_350").text("Selected");
jQuery(this).css("background-color", "#c11c2d");
jQuery("#btn_349").css("background-color", "#333335");
});
我有一个 WooCommerce 重力表单,用户可以根据单选按钮选择选择一个包进行注册。我想根据选择将 woocommerce 产品添加到购物车。下面是单选按钮组的 html 和 js 但它没有触发:
<script>
$('#choice_1_112_0').click(function() {
window.location.href = 'www.domian.com/?add-to-cart=125';
return false;
});
</script>
<ul class="gfield_radio" id="input_1_112">
<li class="gchoice_1_112_0">
<input name="input_112" type="radio" value="Normal Package" id="choice_1_112_0">
<label for="choice_1_112_0" id="label_1_112_0">Normal Package</label>
</li>
<li class="gchoice_1_112_1">
<input name="input_112" type="radio" value="eTrade Package" id="choice_1_112_1">
<label for="choice_1_112_1" id="label_1_112_1">eTrade Package</label>
</li>
</ul>
我用一个简单的 JS 脚本来实现触发按钮点击并将产品直接添加到购物车
jQuery("#btn_349").on("click", function(){
jQuery("#choice_1_112_0").prop("checked", true);
jQuery("#btn_350").text("Select");
jQuery("#btn_349").text("Selected");
jQuery(this).css("background-color", "#c11c2d");
jQuery("#btn_350").css("background-color", "#333335");
});
jQuery("#btn_350").on("click", function(){
jQuery("#choice_1_112_1").prop("checked", true);
jQuery("#btn_349").text("Select");
jQuery("#btn_350").text("Selected");
jQuery(this).css("background-color", "#c11c2d");
jQuery("#btn_349").css("background-color", "#333335");
});