Closed kevinzaki closed 8 years ago
A couple things: Are you planning on managing cart associations to users yourself? If you're not, use fetchRecentCart
. Also, if you console.error(error)
the error that's sent to catch, can you post the trace?
I do plan on managing cart associations. Basically my plan is to use the buy SDK to generate and manage carts for products stored on Shopify. Once I have a completed cart I am going to use the regular API to create an order and process payments separately. The error I am getting is the following:
[ReferenceError: localStorage is not defined]
What environment are you running this in? Node or browser?
Node, running my server using Gulp locally at the moment.
Ah... OK. Yeah. This is a thing we failed to implement.
For the time being, somewhere in your startup code, if you did something like
global.localStorage = {
_storage: {},
setItem: function(key, value) {
this._storage[key] = value;
},
getItem: function(key) {
return this._storage[key]
},
clear: function() {
this._storage = {};
}
};
I understand this is ugly, but it'll get you by for now. I'll post here when we make this functionality work properly in node.
Thanks it worked, wouldn't of figured that out without some help.
How can I set up background colors and other stuffs using createCart() ? Anyone have idea. I am researching but not able to find anything which can solve.
Here is the code :
ui.createCart({ "styles": { "button": { "background-color": "#cccccc", "font-family": "Raleway, sans-serif", "font-size": "18px", "padding-top": "17px", "padding-bottom": "17px", ":hover": { "background-color": "#cccccc" }, ":focus": { "background-color": "#cccccc" }, "font-weight": "normal" }, "footer": { "background-color": "#cccccc" } }, "googleFonts": [ "Raleway" ] });
Thanks
@muzuitech Can you please create a new issue for this in the https://github.com/Shopify/buy-button-js repo?
Can't figure this out. (Most of the below code is for test purposes)
Fetching all products works: (The reason I am showing the working code is so you can see everything else is right, the cart route immediately follows the products route.
The following to createCart and log the cart ID does not work.