Nuxtjs - How to use localstorage - vuejs2

In my current e-commerce project I use localstorage to store cart items as well as authUser token
The nuxt guide has a implementation of express-session which stores user data.
How to store cart items of the user?

Related

Shopify API Configuration

When we created a API, I figured that I need to configure a new Shopify like this
const Shopify = require('shopify-api-node');
const shopify = new Shopify({
shopName: 'your-shop-name',
apiKey: 'your-api-key',
});
Is there any way to get the Shopify "your-shop-name" programmatically? So If I installed the app on another one it won't need to change. Or is there any other way to configure the API on Shopify?
I primarily need to update the product description using Admin REST API.
In your store, where you want to change descriptions using API calls, use the Admin App section to issue yourself an API key pair. You can give that key pair permission to edit products. And you're done! You have the store name obviously, and you have your access token. Nothing to it!

How to data store and get everywhere in site of bigcommerce like React state management and Angularjs manage scope or data service

I am very new in Bigcommerce. I want some data store or set like state management of React and manage scope or data service of Angularjs and use set data anywhere of Bigcommerce site.
Our any other way to set data and use anywhere of site.
Bigcommerce work same as JS with graphQL.

Shopify cart - FrontStore API (cart ID) X ajax API (Token)

I'm trying manipulate the same cart both from Ajax API (via frontend) and StoreFront API (via backend) but i'm not figuring out if the cart created from one have a correlation ID with another approach.
I know that when i add an item in cart via Ajax API a cookie called "cart" is added with an token that persists my cart, in another hand when i create a cart via StoreFront API i get an cartId (a base64 encoded string) that have an token too but it seems that the tokens are not correlated each other, so someone have any clue if a cart created via ajax API is available for manipulation via StoreFront API?

How to add script to the front side of the shopify app

As i am new to shopify app i created an app and installed over a store with script tag having read and write permission . How can i dynamically add the javascript to the front side of shopify app.
Use the Script Tag API to create the javascript you want to load dynamically.
# POST /admin/script_tags.json
{
"script_tag": {
"event": "onload",
"src": "https://djavaskripped.org/fancy.js"
}
}
Documentation: Link
When your App is installed in a Shop, the merchant usually gets two dialogs to confirm. One is if you are asking for a billing charge. The other is for the scopes access to their shop. Assuming they approve both, you will get an oAuth token allowing you to read/write ScriptTag endpoint.
So when you get that oAuth token, you save it along with the shop name, and that is finally when you can POST your script tag payload in the store.

how to link purchases to user records in another system?

sorry I posted this in the google group before I realized you had moved this type of question to stackoverflow
I'm developing a web app with an e-commerce component based on shopify as a white-labelled product for our clients. Our app allows our clients' customers to purchase a subscription to a product for use within the app. Each of our clients will have a separate shopify store. We have a web interface that allows our clients to create products and we use the shopify api to create the products in their store via an app. We have installed web hooks to receive notification of payments so that we can create the appropriate records in our system to allow the customer access to the product they purchased.
So far, the plan has been to provide a product list on our site with a 'Buy Now' button that adds the product to the store's cart and then direct the user to checkout using Shopify's checkout system. In the fulfillment web hook, we get the cart token so all we need to do to link the two systems is record the cart token temporarily in our customer database and then we can credit the right user with the purchase.
The problem that we are running in to is that there seems to be no way to link the cart / order / payment to the user that is actually logged in to our system. We are still under development so we are using test stores and the domain of the app is different from the domain of the store (and that may be the case in the production system too) and it is seemingly impossible to figure out how to link the two systems.
I have tried a couple of different approaches ...
1) use a form and post to the store's cart/add.js with a return_to=back
This seems successful in that the items are added to the cart and opening the cart in a new window takes them to the cart they added the item to, but there is no way to associate that cart with the user on our system since we can't access the cart token in a separate domain
2) use a proxy (our system is written in nodes) to post to the store's cart and intercept the cart token.
This also works in that an item is added to a cart and we can access the _session_id and cart cookies from the response, but I don't seem to be able to set those cookies in the browser. Going to the store's cart doesn't show the item just added and the store gets a different cart token.
Is there a different approach or should one of those work?
Should we be doing this entirely differently?
Cheers
Paul
Your best bet is to put something in cart attributes when the order is created and use that when you get the webhook to link the order to the other system. You could have a simple json endpoint on the other server to get back the currently logged in user, or have them enter some user is on the cart page and store them in the cart atributes. More on cart attributes http://wiki.shopify.com/Ask_customer_for_additional_information
To implement John's suggestion, I put the following into my cart.liquid file:
<script type="text/javascript">
(function($){
$(document).ready(function(){
$.ajax({
url: 'http://<server>/token',
dataType: 'jsonp',
success: function(data, status, xhr) {
$('#cartform').append('<input type="hidden" name="attributes[token]" value="'+data.token+'" />');
},
error: function(xhr, status, error) {
alert('Error');
}
});
});
})(jQuery);
</script>
My server runs on a different domain than the shop, so I'm using jsonp. The token is something I can use to uniquely identify a customer record in my database. I am using an attribute so that it doesn't conflict with our client's use of shopify's note feature if they want to use it themselves for something. I have not yet tested this with my web hook but I assume that I can make this work from here on.
I'm not completely satisfied with this as it requires that our clients put this into their templates in order for shopify to work with our system. I still think that there should be a way through the JSON /cart API to set the value of the note for a cart.