We're fairly inexperience with json and are having trouble displaying an object from a json string from a Big Cartel store in to our WordPress site.

So, if on our Big Cartel site, we load the following URL (which is just the link to the store's cart location with .json on the end):

e.g. ourstore.com/cart.json

We get the following string of variables:

{"items":[{"id":59269479,"name":"Test 4","price":"8.0","unit_price":"4.0","shipping":0.0,"tax":0.0,"total":"4.0","quantity":2,"product":"test-4","option":59269479},{"id":59269434,"name":"Test 2","price":"2.0","unit_price":"1.0","shipping":0.0,"tax":0.0,"total":"1.0","quantity":2,"product":"test-2","option":59269434},{"id":59271363,"name":"Test 6","price":"544.0","unit_price":"544.0","shipping":0.0,"tax":0.0,"total":"544.0","quantity":1,"product":"test-6","option":59271363}],"item_count":5,"price":"554.0","total":"554.0"}

From that string, we're basically just trying to display the "item_count":5 variable in to the external WordPress site.

If anyone has any ideas that would be greatly appreciated! Thanks!

有帮助吗?

解决方案

Unfortunately the javascript API you're trying to use on your external Wordpress site won't work with shopping cart data -- the Cart information can only be displayed directly in a Big Cartel store. More information on that is here: http://help.bigcartel.com/customer/portal/articles/772751-javascript-ajax

You can use our API to display other store and product information on your website though, more details and a brief tutorial are here: http://help.bigcartel.com/customer/portal/articles/772771-api

其他提示

Please use this code in javascript.

var jsonString = '{"items":[{"id":59269479,"name":"Test 4","price":"8.0","unit_price":"4.0","shipping":0.0,"tax":0.0,"total":"4.0","quantity":2,"product":"test-4","option":59269479},{"id":59269434,"name":"Test 2","price":"2.0","unit_price":"1.0","shipping":0.0,"tax":0.0,"total":"1.0","quantity":2,"product":"test-2","option":59269434},{"id":59271363,"name":"Test 6","price":"544.0","unit_price":"544.0","shipping":0.0,"tax":0.0,"total":"544.0","quantity":1,"product":"test-6","option":59271363}],"item_count":5,"price":"554.0","total":"554.0"}';
var jsonObj = JSON.parse(jsonString);

Now just use the following line in the place where you want to display

jsonObj.item_count
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top