简体   繁体   English

minicart.js无法正常工作,购物车未弹出

[英]minicart.js not working, cart is not popping up

I am using Minicart.JS for my simple paypal shopping cart. 我将Minicart.JS用于简单的Paypal购物车。 But this is not working as it should. 但这并不能正常工作。 The cart is not popping up if I click 'add to cart' button. 如果单击“添加到购物车”按钮,则购物车不会弹出。

Here's my code. 这是我的代码。

<html>
<body>
        <script src="//cdnjs.cloudflare.com/ajax/libs/minicart/3.0.3/minicart.min.js"></script>
        <script>
            paypal.minicart.render();
        </script>


        <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
                <input type="hidden" name="cmd" value="_cart" />
                <input type="hidden" name="add" value="1" />
                <input type="hidden" name="business" value="labs-feedback-minicart@paypal.com" />
                <input type="hidden" name="item_name" value="Test Product" />
                <input type="hidden" name="quantity" value="1" />
                <input type="hidden" name="amount" value="1.00" />
                <input type="hidden" name="currency_code" value="USD" />
                <input type="hidden" name="no_shipping" value="2">
                <input type="hidden" name="no_note" value="1">
                <input type="hidden" name="shipping2" value="1.50">
                <input type="hidden" name="shipping" value="2.50">
                <strong>Test Product</strong>

                <p>
                    <label><input type="checkbox" id="terms" name="terms" value="" /> I agree to the terms</label>
                </p>

                <input type="submit" name="submit" value="Add to cart" />
            </form>

    <script>
        paypal.minicart.render();

        paypal.minicart.cart.on('checkout', function (evt) {
            var hasAgreed = !!document.getElementById('terms').checked;

            if (!hasAgreed) {
                alert('You must agree to the terms!');
        evt.preventDefault();
            }
        });
    </script>
</body>
</html>

Here is the actual site. 这是实际的站点。 , I found an error in console that said: ,我在控制台中发现一条错误消息:

Uncaught TypeError: Cannot call method 'appendChild' of null 

I am not sure how to fix this, please let me know what's wrong with my setup. 我不确定如何解决此问题,请让我知道我的设置有什么问题。 Thanks. 谢谢。

You need to change the Add to cart button to not be saved on PayPal (In Profit and loss Section) and also unprotect code after the button is created right before you copy and paste it :) 您需要更改“添加到购物车”按钮以使其不保存在贝宝(“损益”部分)中,并且还需要在创建按钮后立即取消保护代码,然后再复制并粘贴它:)

Hope this helps :) 希望这可以帮助 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM