SimpleCart.js项链接未定义,无法使链接生效

时间:2015-06-30 23:03:02

标签: javascript jquery html simplecart

我试图为我的网站设置SimpleCart,一切正常100%正常工作,除非我尝试将我的产品各自的链接添加到他们自己的页面中" cart colummns&# 34 ;.我正在关注documentation(此链接将您带到他们的文档页面,解释如何设置购物车列,包括项目链接),了解如何包含产品链接,但链接一直在说明' s&#34 ;未定义"

请看看我的小提琴(抱歉缺乏造型):

FIDDLE

根据文件,如果你提出:

{ view: "link", label: "Details", attr: "pageLink", text: "View Product Page" }

作为购物车栏目(如小提琴第98行所示)

然后添加类:

class="item-pageLink">

(我认为下面的href链接如下所示)可以添加到购物车中的产品 - 所以在我的例子和js小提琴中,我得到了:

<div class="item-pageLink"><a href="http://www.google.com">View More</a></div>

...当您点击&#34;给我购买&#34; ...您会看到此项目将被添加到下方的购物车中,但当您将鼠标悬停在&#34;查看产品页面&#34 ;它表明链接是&#34;未定义&#34;!它应该指向/链接到谷歌!

我不知道问题出在哪里?请参阅小提琴的js面板中的第525行 - 这是对#34;获得&#34;的唯一其他参考。我能看到的链接。

我试过谷歌搜索这个问题,虽然还有其他人遇到过同样的问题,但我找不到一个明确的解决方案。

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

我一直在使用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"

});