【问题标题】:How to use WooCommerce product base price with jQuery | Gravity Form如何在 jQuery 中使用 WooCommerce 产品基础价格 |重力形式
【发布时间】:2021-11-20 00:32:24
【问题描述】:

为什么下面的方法不起作用,我应该怎么做? 你有更好更短的方法来编写这段代码吗?

我也查看了此页面,但没有注意到: enter link description here

$(function() {

var FinalPrice;
var BasePrice = $('.woocommerce-variation-price .amount').text();
// I think the problem is here


$('.Select_plooi input[type="radio"]').on('change',function(){  
var plooi=$('input[name="input_4"]:checked').val();

switch (plooi)
{
    case 'Enkele':
        FinalPrice=BasePrice*2;
        break;
    case 'Dubble':
        FinalPrice=BasePrice*5;
        break;
    case 'Wave':
        FinalPrice=BasePrice*6;
        break;
        }
    });
    
$("#input_2_9").val(parseFloat(FinalPrice).toFixed(2));
});

【问题讨论】:

    标签: jquery woocommerce gravity-forms-plugin gravityforms


    【解决方案1】:

    $('.woocommerce-variation-price .amount') 将返回带有货币符号的价格 html 元素不是 Int 试试这个:

    var BasePrice = parseFloat($('.woocommerce-variation-price .amount').text().replace(/[^\d.,]/g, '')); // remove all non numeric
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-15
      • 2021-05-19
      • 2020-07-20
      • 2019-12-25
      • 2021-08-01
      相关资源
      最近更新 更多