SimpleCart.js项目链接未定义,无法使链接正常工作 [英] SimpleCart.js item link undefined, can't get the link to work

查看:48
本文介绍了SimpleCart.js项目链接未定义,无法使链接正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的网站设置 SimpleCart ,并且一切正常除了当我尝试将我的产品的相应链接添加到购物车列"中自己的页面时.我正在关注文档(此链接将带您进入其文档页面,其中说明了如何设置购物车列,包括项目链接),以了解如何包含产品链接,但该链接一直说未定义".

I'm trying to set up SimpleCart for my website and everything is working 100% fine except when I try to add my products respective links to their own page in the "cart colummns". I am following the documentation (this link takes you to their documentation page explaining how to setup the cart columns including the item link) on how to include the product link but the link keeps saying it's "undefined".

请看一下我的小提琴(对不起缺少样式):

Please take a look at my fiddle (sorry for the lack of styling):

FIDDLE

根据文档,如果您输入:

According to the documentation if you put:

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

作为购物车专栏(您可以在小提琴的第98行中看到)

as a cart column (as you can see on line 98 in the fiddle)

然后添加类:

class="item-pageLink">

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

(Which I presume gleans the following href link as shown below) to the product that can be added to the cart - So in my example and in the js fiddle, I've got:

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

...当您单击购买我" ...时,您会看到该商品将添加到下面的购物车中,但是当您将鼠标悬停在查看产品页面"上时,表明该链接是未定义的" !它应该指向/链接到Google!

...when you click "buy me"... you will see that this item will be added to the cart below but when you hover your mouse over "View Product Page" it shows that the link is "undefined"! It should point / link to google!

我不知道问题出在哪里?请查看小提琴js面板中的525行-这是获取"我所看到的链接的唯一其他参考.

I don't know where the problem lies? Please see line 525 in the js panel of the fiddle - this is the only other reference to "getting" the link that I could see.

我已经尝试过搜索这个问题,尽管还有其他人也遇到过同样的问题,但是我找不到一个明确的解决方案.

I've tried googling this issue and although there were others who had experienced the same problem, I cannot find one clear cut solution.

有人可以在这里帮助我吗?

Can anyone help me here?

推荐答案

我一直在研究simpleCart js,这是我如何在购物车中添加产品名称的链接:

I've been playing around with simpleCart js and here's how I add a link the name of a product in the shopping cart: https://github.com/wojodesign/simplecart-js/issues/476

我在页面HTML中传递item_link <span class="item_link">http://www.example.com</span>,然后在simpleCartSetup.js文件中将view函数添加到attr:名称"

I pass in item_link <span class="item_link">http://www.example.com</span> in the page HTML and then in the simpleCartSetup.js file I add the view function to 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"

});

这篇关于SimpleCart.js项目链接未定义,无法使链接正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆