Request data via graphql from an added script

Highlighted
Tourist
4 0 0

Hi,
I added a JS to make a bar on top of the store, using admin app. As a result, I got my bar with text inside of it. However, the goal is not merely have text but to make a free shipping application. Like the attached image.
Screenshot from 2020-04-30 11-37-40.png

To do that, I need to collect information from the checkout, I believe I must have one end point from the frontstore to access the check-out, so I need to make a request to graphql for inserting data in my Script.
The problem I am facing is that I have do an authentication on the server to obtain the data on the checkout, regardless this information is public (I believe so), as far as my understanding the customer can access the information of the total price that is in the cart.


Is there any possibility to explain me how I can do this?


Nothing in these links below are relevant to my question:
https://shopify.dev/docs/storefront-api/getting-started
https://shopify.dev/tutorials/create-a-checkout-with-storefront-api

 

PS: I got 403 error in the fetch for the graphql, after it was added it to my store.
code: Url:  https://testezarbo.myshopify.com/api/2020-04/graphql.json

 

fetch(url, {
 method: 'POST',
 headers: { 'Content-Type': 'application/json' },
 body: JSON.stringify( '{ shop { name } }' ),
 })
0 Likes
Highlighted
Tourist
14 0 2

Hello!

 

If your goal is to check the total amount of the current cart, you can use Shopify's AJAX Cart API here: https://shopify.dev/docs/themes/ajax-api/reference/cart#get-cart-js - it doesn't needs authentication nor GraphQL/REST. 

International team available for Store creation and Theme/App development!
0 Likes