DEV Community

Mohin patwary
Mohin patwary

Posted on

How can I Display data on an online store from the app server?

How can I Display data on an online store from the app server? I got a guideline, app proxy. but I cannot understand that.

I have created an admin Dashboard for the app following your tutorial. I created successfully a snippet file on the current Shopify theme using asset API. I can pass any HTML code as a snippet file value. This means I can pass any HTML or liquid code in the snippet file. That snippet file was created from my app.

I've added some settings fields for my app. And I can save data into my database.https://prnt.sc/vf6fjp

Now I want to create a REST API to show the data for the Shopify client store. I created an API route.https://prnt.sc/vf6cjs
For API I have created a Controller. https://prnt.sc/vf6dlu

On the controller for the API, I need to run a query based on the same customer ID and the same Shopify shop name to get data from my database. In my database, I saved customer id and shop Name, and product id.

Now, How can I get a Shopify shop name and customer ID in the laravel controller?
So, I can run a SQL query using Shopify shop name and customer-id to get data from my database.

I can easily manage JavaScript to get the name of Shopify Shop. Example: Shopify.shop
But how can I customer ID? The customer who logged in and saved the wishlist product.

Also, How can I write javascript in laravel controller or how can I access javascript value in the laravel controller?

I really need this assistance, I am trying to for the last few days. But I cannot find a solution.

Please sir help me

Thank you

Top comments (3)

Collapse
 
zubairmohsin33 profile image
Zubair Mohsin

If you already have a snippet in theme and can pass Liquid file, you can create a hidden input with value of current customer and then retrieve it.

<input type='hidden' value="{{ customer.id }}" id="uniq_customer" />

Collapse
 
mohinpatwary profile image
Mohin patwary

Thank you so much sir for responding here.
Actually, I followed the CodeInspire video tutorial. He saw everything in the admin part. But there is no video/guide to show data show online Shopify theme/store from the database,
I was just trying to show data from the app server/database to the Shopify online store.

I am trying to follow these instructions, github.com/osiset/laravel-shopify/...

But I can properly understand these instructions. Could you please help me, sir? I will be really grateful to you.

Thank you

Collapse
 
zubairmohsin33 profile image
Zubair Mohsin

Also make sure to check YouTube tutorial series by CodeInspire on building Shopify App with Laravel. He also builds a Wishlist app as an example in his tutorial.

youtube.com/watch?v=DHKtoWrHMhI&li...

Some comments may only be visible to logged-in visitors. Sign in to view all comments.