本文介绍了将条带设置为“数据量"使用带有变量的动态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要让我的脚本结帐才能将我的var $priceCheckout = $('#priceCheckout');用于结帐价格值.

I am in need of getting my script checkout to use my var $priceCheckout = $('#priceCheckout'); for the checkout price value.

我尝试用data-amount= $priceCheckout;替换data-amount ="2000",但没有任何运气.所以要清除!

I have tried to replace the data-amount="2000" with data-amount= $priceCheckout; without any luck. So to be cleare!

它需要带我的$ priceCheckout并将其放置在数据量中,以便$ priceCheckout的值将成为结帐价格!

It needs to take my $priceCheckout and get it placede at data-amount so that the value of $priceCheckout will be the checkout price!

<form action="" method="POST">
  <script
    src="https://checkout.stripe.com/checkout.js" class="stripe-button"
    data-key="Personal key"
    data-amount= ???
    data-name="Elo Calculator"
    data-description="Checkout price"
    data-image="/128x128.png"
    data-locale="auto">
  </script>
</form>

这是我的脚本.

$(function () {
            // Store references to frequently used elements - for speed.
            var $divFrom = $('#division-from');
            var $divTo = $('#division-to');
            var $tierFrom = $('#tier-from');
            var $tierTo = $('#tier-to');

            var $price = $('#price');
            var $priceCheckout = $('#priceCheckout');

            // Select price calculation callback
            $(document).on('change', '.price-modifier', function () {
                var divFrom = $divFrom.val();
                var divTo = $divTo.val();
                var tierFrom = $tierFrom.val();
                var tierTo = $tierTo.val();

                // Error handling
                var errors = validatePriceModifiers(divFrom, tierFrom, divTo, tierTo);
                if (errors.length === 0) {
                    // No errors
                    var price = getPrice(divFrom, tierFrom, divTo, tierTo);
                    $price.html(price + ' €' + '<br /> <br />' + '<button type="submit" data-toggle="modal" data-target="#myModal" class="btn btn-info">Buy</button>');
                    $priceCheckout.html(price);
                } else {
                    // Display errors
                    $price.empty();
                    for (var i = 0; i < errors.length; i++) {
                        $price.append($('<p>').html(errors[i].message));
                    }
                }
            });
        });

推荐答案

您需要使用Checkout 自定义集成.

You need to use a Checkout custom integration for this.

这是一个简单的小提琴,显示了如何以用户指定的数量使用Checkout: https://jsfiddle.净/ywain/g2ufa8xr/

Here is a simple fiddle showing how to use Checkout with a user-specified amount: https://jsfiddle.net/ywain/g2ufa8xr/

在调用handler.open()时,可以使用与amount参数相同的逻辑来插入自己的值.

You can use the same logic to plug in your own value as the amount parameter in the call to handler.open().

这篇关于将条带设置为“数据量"使用带有变量的动态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 14:25