我正在尝试为我的网站设置SimpleCart,除了我尝试将我的产品各自的链接添加到"购物车列"中自己的页面时,一切都100%正常。我正在关注文档(此链接将带您进入他们的文档页面,解释如何设置购物车列,包括商品链接),了解如何包括产品链接,但链接一直说它是"未定义的"。
请看一下我的小提琴(很抱歉没有造型):
小提琴
根据文件,如果你放:
{ view: "link", label: "Details", attr: "pageLink", text: "View Product Page" }
作为一个推车列(正如你在小提琴中第98行看到的)
然后添加类:
class="item-pageLink">
(我认为它收集了如下所示的href链接)到可以添加到购物车的产品-所以在我的例子和js fiddle中,我得到了:
<div class="item-pageLink"><a href="http://www.google.com">View More</a></div>
当你点击"买我"。。。你会看到这个项目将被添加到下面的购物车中,但当你将鼠标悬停在"查看产品页面"上时,它显示链接是"未定义的"!它应该指向/链接到谷歌!
我不知道问题出在哪里?请参阅fiddle的js面板中的第525行——这是我能看到的唯一一个关于"获取"链接的引用。
我试过在谷歌上搜索这个问题,尽管也有其他人遇到过同样的问题,但我找不到一个明确的解决方案。
有人能帮我吗?
我一直在玩simpleCart js,下面是我如何在购物车中添加产品名称链接的方法:https://github.com/wojodesign/simplecart-js/issues/476
我在页面HTML中传入item_link <span class="item_link">http://www.example.com</span>
,然后在simpleCartSetup.js
文件中向attr:"name"添加视图函数
// simpleCartSetup.js
simpleCart({
// array representing the format and columns of the cart, see
// the cart columns documentation
cartColumns: [
{ attr: "name" , label: "Name",
// Link function
view: function (item, column) {
return "<a href='" + item.get("link") + "'>" + item.get(column.attr) + "</a>";
}
},
{ attr: "price" , label: "Price", view: 'currency' },
{ view: "decrement" , label: false },
{ attr: "quantity" , label: "Qty" },
{ view: "increment" , label: false },
{ attr: "total" , label: "SubTotal", view: 'currency' },
{ view: "remove" , text: "Remove" , label: false }
],
// "div" or "table" - builds the cart as a table or collection of divs
cartStyle: "div",
// how simpleCart should checkout, see the checkout reference for more info
checkout: {
type: "PayPal" ,
email: "you@yours.com"
},
// set the currency, see the currency reference for more info
currency: "AUD"
});