目前我只能将文本传递给ajax-cart-template,但是当我尝试传递我创建的元素时,返回[object Object]。
这是我在ajax-cart.js中的代码。现在hiddenProductText确实传递了。不是我创造的元素。
var hiddenProductText = "Add $99+ to Your Cart to get a Free Gift",
bleh = $("#hiddenFree"),
blehbleh = $("<div>", {id: "hiddenFreeTwo"});
if(cart.total_price >= 9900){
hiddenProductText = "Grab this Storage Box for Free!";
var blehbleh2 = bleh.append(blehbleh);
console.log(blehbleh2);
}
data = {
items: items,
note: cart.note,
totalPrice: Shopify.formatMoney(cart.total_price, settings.moneyFormat),
hidden_Product_Text: hiddenProductText,
free_Product_Gift: blehbleh2
}
我将数据传递给ajax-cart-template。
<div class="ajaxcart__footer">
<div class="grid--full">
<span style="width:100%;color:#e75300;">{{hidden_Product_Text}}</span>
<div id="hiddenFree">
{{free_Product_Gift}}
</div>
<div class="grid__item two-thirds">
<p>{% endraw %}{{ 'cart.general.subtotal' | t }}{% raw %}</p>
</div>
<div class="grid__item one-third text-right">
<p>{{{totalPrice}}}</p>
</div>
</div>
<p class="text-center">{% endraw %}{{ 'cart.general.shipping_at_checkout' | t }}{% raw %}</p>
<button type="submit" class="btn btn1 btnBlock btnGreen cart__checkout" name="checkout" style="display:{{checkout_button_display}};" >
<i class="fa fa-lock"></i>
{% endraw %}{{ 'cart.general.checkout' | t }}{% raw %}
<div id="checkoutButtonOverlay"></div>
</button>
{% endraw %}{% if additional_checkout_buttons %}
<div class="additional_checkout_buttons" style="display:{%raw %}{{checkout_button_display}}{% endraw %};" >{{ content_for_additional_checkout_buttons }}</div>
{% endif %}{% raw %}
<span style='color:red;'>{{checkout_hidden_text}}</span>
</div>