pidong1 2015-07-28 01:48 采纳率: 0%
浏览 3323

如何获取这个购物车的订单数据

js代码太多分割为两部分

!function (t, e, a, n) {
"use strict";
function i(e, a) {
this.element = t(e), this.settings = t.extend(!0, {}, s, a), this.cart = this.element.find("." + this.settings.cart), this.product = this.element.find("." + this.settings.product), this._defaults = s, this._name = r, this.init()
}

var r = "ctshop", s = {
    cart: "ct-cart",
    product: "ct-product",
    product_title: "ct-product-title",
    product_price: "ct-product-price",
    product_button: "ct-product-button",
    currency: "$",
    currency_after_number: "false",
    permanent_cart_buttons: "false",
    display_total_value: "true",
    permanent_total_value: "false",
    animation: "fadeIn",
    empty_disable: "false",
    empty_text: "Your cart is empty",
    paypal: {
        business: "office@createit.pl",
        currency_code: "USD",
        lc: "EN",
        cpp_cart_border_color: "",
        cpp_payflow_color: "",
        no_note: "0",
        no_shipping: "0",
        "return": "",
        cancel_return: ""
    },
    init: !1,
    before_add_to_cart: !1,
    after_add_to_cart: !1,
    remove_item_from_cart: !1,
    before_checkout: !1,
    after_clear_cart: !1,
    after_value_changes: !1
};
  • 写回答

3条回答 默认 最新

  • pidong1 2015-07-28 01:49
    关注

    下半部分
    t.extend(i.prototype, {
    init: function () {
    var a = this;
    if (a.cart = a.cart.append("

      ").find("ol"), a.permanent_total(), a.permanent_cart_buttons(), e.sessionStorage.cart) {
      var n = a.cart.find("li"), i = n.find("." + a.settings.cart + "-input"), r = n.length;
      a.create_storage_cart(), "false" === a.settings.permanent_cart_buttons && a.add_cart_buttons(), "true" === a.settings.display_total_value && "false" === a.settings.permanent_total_value && a.append_total(), a.calculate_total_value(), a.quantity_change(i), a.remove_item(r)
      }
      a.settings.init && a.settings.init(), a.cart_empty(), a.product.each(function (e) {
      var n = t(this), i = n.find("." + a.settings.product_title), r = n.find("." + a.settings.product_price), s = n.find("." + a.settings.product_button), c = i.text(), o = r.text().replace(",", "").replace(/[^\d.]/g, "");
      s.on("click touchend", function (t) {
      t.preventDefault(), a.settings.before_add_to_cart && a.settings.before_add_to_cart(), c = a.check_if_title(i, c), o = a.check_if_price(r, o);
      var s, u = n.attr("data-id", c.replace(/ /g, "").replace(/\r\n|\r|\n/g, "").replace(/[^a-zA-Z 0-9]+/g, "") + r.text().replace(/\r\n|\r|\n/g, "").replace(/[^a-zA-Z 0-9]+/g, "") + "_" + (e + 1)).attr("data-id"), l = a.cart.find("li"), _ = a.cart.find("[data-id=" + u + "]"), p = .attr("data-id"), d = l.find("." + a.settings.cart + "-input");
      d.val();
      return 0 !== l.length ? p !== u ? a.add_to_cart(c, o, u) : _.find("input").val(function (t, e) {
      return parseInt(e, 10) + 1
      }) : (a.add_to_cart(c, o, u), "false" === a.settings.permanent_cart_buttons && a.add_cart_buttons(), "true" === a.settings.display_total_value && "false" === a.settings.permanent_total_value && a.append_total()), l = a.cart.find("li"), d = l.find("." + a.settings.cart + "-input"), s = l.length, a.quantity_change(d), a.calculate_total_value(), a.remove_item(s), a.settings.after_add_to_cart && a.settings.after_add_to_cart(), !1
      })
      })
      }, add_to_cart: function (t, e, a) {
      var n = this;
      n.cart.append("true" === n.settings.currency_after_number ? '×" : '×"), n.storage_set()
      }, add_cart_buttons: function () {
      var t = this;
      t.cart.parent().append('Clear Cart'), t.cart.parent().append('Checkout'), t.clear_cart(), t.checkout_button()
      }, checkout: function () {
      var e, a = this, n = {cmd: "_cart", upload: 1}, i = t(""), r = {
      name: "item_name",
      quantity: "quantity",
      amount: "amount"
      };
      t.extend(n, a.settings.paypal), i.attr("action", "http://sc.chinaz.com/"), i.attr("method", "post"), i.attr("target", "_blank");
      for (var s in n)e = t(''), e.attr("name", s), e.attr("value", n[s]), i.append(e);
      a.cart.find("li").each(function (e) {
      var n = t(this), s = n.find("." + a.settings.cart + "-name").text(), c = parseFloat(n.find("." + a.settings.cart + "-price").text().replace(/^\D+/g, "")), o = n.find("input").val(), u = {
      name: t("", {
      type: "hidden",
      name: r.name + "
      " + (e + 1),
      value: s
      }),
      amount: t("", {type: "hidden", name: r.amount + "_" + (e + 1), value: c}),
      quantity: t("", {type: "hidden", name: r.quantity + "_" + (e + 1), value: o})
      };
      i.append(u.name).append(u.amount).append(u.quantity)
      }), t("body").append(i), i.submit()
      }, checkout_button: function () {
      var e = this;
      t("." + e.settings.cart + "-checkout").unbind().on("click", function () {
      e.settings.before_checkout && e.settings.before_checkout(), e.checkout()
      })
      }, remove_item: function (e) {
      var a = this;
      t("." + a.settings.cart + "-remove").unbind().on("click", function () {
      var e = t(this), n = a.cart.find("li").length;
      e.parent().remove(), a.calculate_total_value(), a.storage_set(), 1 === n && (a.remove_cart_buttons(), a.remove_total(a.total), a.storage_clear()), a.settings.remove_item_from_cart && a.settings.remove_item_from_cart()
      })
      }, clear_cart: function () {
      var e = this;
      t("." + e.settings.cart + "-clear").on("click", function () {
      e.cart.find("li").each(function () {
      t(this).remove()
      }), e.remove_cart_buttons(), e.remove_total(e.total), e.storage_clear(), e.cart_empty(), e.settings.after_clear_cart && e.settings.after_clear_cart()
      })
      }, remove_cart_buttons: function () {
      var t = this;
      "false" === t.settings.permanent_cart_buttons && t.cart.parent().find("button").remove()
      }, check_if_title: function (t, e) {
      return 0 !== t.find("select").length ? e = 0 !== t.find("span").length ? t.find("span").text() + " - " + t.find("option:selected").val() : t.find("option:selected").text() : 0 !== t.find("input").length ? e = t.find("input").val() : t.is(":empty") && (e = t.val()), e
      }, check_if_price: function (t, e) {
      return 0 !== t.find("select").length ? e = parseFloat(t.find("option:selected").val().replace(/^\D+/g, "")) : 0 !== t.find("input").length && (e = parseFloat(t.find("input").val().replace(/^\D+/g, ""))), e
      }, permanent_cart_buttons: function () {
      var t = this;
      "true" === t.settings.permanent_cart_buttons && t.add_cart_buttons()
      }, calculate_total_value: function (e) {
      var a = this, n = 0, i = 0;
      return a.cart.find("li").each(function () {
      var e = parseFloat(t(this).find("." + a.settings.cart + "-price").text().replace(/^\D+/g, "")), r = t(this).find("input").val();
      i += e * r, n = parseFloat(i.toString()).toFixed(2)
      }), "true" === a.settings.display_total_value && a.total.html("true" === a.settings.currency_after_number ? n + a.settings.currency : a.settings.currency + n), a.cart_empty(), a.settings.after_value_changes && a.settings.after_value_changes(), n
      }, quantity_change: function (t, e) {
      var a = this;
      t.change(function () {
      a.calculate_total_value(e), a.storage_set()
      })
      }, append_total: function () {
      var t = this;
      t.total = t.cart.parent().prepend('').find("." + t.settings.cart + "-total")
      }, remove_total: function (t) {
      var e = this;
      "true" === e.settings.display_total_value && "false" === e.settings.permanent_total_value ? t.remove() : "true" === e.settings.permanent_total_value && "true" === e.settings.display_total_value && e.calculate_total_value(t)
      }, permanent_total: function () {
      var t = this;
      "true" === t.settings.permanent_total_value && "true" === t.settings.display_total_value && (t.append_total(), "true" === t.settings.display_total_value && t.total.html("true" === t.settings.currency_after_number ? "0" + t.settings.currency : t.settings.currency + "0"))
      }, storage_set: function () {
      var t = this, a = {items: []};
      $(t.cart).find("li").each(function () {
      var e = $(this), n = e.attr("data-id"), i = e.find("." + t.settings.cart + "-name").text(), r = e.find("." + t.settings.cart + "-price").text(), s = e.find("input").val(), c = {
      name: i,
      id: n,
      price: r,
      input: s
      };
      a.items.push(c)
      }), e.sessionStorage.setItem("cart", JSON.stringify(a))
      }, storage_get: function () {
      var t = e.sessionStorage.cart;
      return t = JSON.parse(t)
      }, storage_clear: function () {
      e.sessionStorage.removeItem("cart")
      }, create_storage_cart: function () {
      for (var t = this, e = t.storage_get(), a = 0, n = e.items.length; n > a; a++) {
      var i = e.items[a].id, r = e.items[a].name, s = e.items[a].price, c = e.items[a].input;
      t.cart.append('' + t.settings.empty_text + ""))
      }
      }), t.fn[r] = function (e) {
      return this.each(function () {
      t.data(this, "plugin_" + r) || t.data(this, "plugin_" + r, new i(this, e))
      })
      }
      }(jQuery, window, document);

      上面是购物车的js源码

      购物车源码预览地址http://www.17sucai.com/pins/demoshow/11530[购物车源码预览地址](http://www.17sucai.com/pins/demoshow/11530 "无")

      评论

    报告相同问题?

    悬赏问题

    • ¥15 matlab数字图像处理频率域滤波
    • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
    • ¥15 ELGamal和paillier计算效率谁快?
    • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
    • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
    • ¥15 Arcgis相交分析无法绘制一个或多个图形
    • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
    • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
    • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
    • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误