【问题标题】:SimpleCart.js item link undefined, can't get the link to workSimpleCart.js 项目链接未定义,无法使链接正常工作
【发布时间】:2015-06-30 23:03:02
【问题描述】:

我正在尝试为我的网站设置SimpleCart,并且一切正常,除非我尝试在“购物车列”中将我的产品各自的链接添加到他们自己的页面。我正在关注documentation(此链接将您带到他们的文档页面,解释如何设置包括商品链接在内的购物车列)关于如何包含产品链接,但链接一直说它是“未定义的”。

请看一下我的小提琴(抱歉缺少样式):

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>

...当您单击“购买我”...您会看到该商品将添加到下方的购物车中,但是当您将鼠标悬停在“查看产品页面”上时,它显示链接为“未定义” !它应该指向/链接到谷歌!

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

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

有人可以帮我吗?

【问题讨论】:

  • 现在将鼠标悬停在“查看产品页面”上...这似乎不存在,您能更清楚一点吗?
  • 请点击这里查看 JS FIDDLE:jsfiddle.net/zdm08m99 ... 然后点击“买我”,然后将鼠标悬停在“查看产品页面”上,链接未定义

标签: javascript jquery html simplecart


【解决方案1】:

我一直在玩 simpleCart js,下面是我在购物车中添加产品名称链接的方法:https://github.com/wojodesign/simplecart-js/issues/476

我在页面 HTML 中传入 item_link &lt;span class="item_link"&gt;http://www.example.com&lt;/span&gt;,然后在 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"

});

【讨论】:

    猜你喜欢
    • 2012-12-27
    • 2017-04-30
    • 2014-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-05
    • 2017-11-28
    • 2014-12-15
    相关资源
    最近更新 更多