A space to discuss online store customization, theme development, and Liquid templating.
My PartnerDashboard->App proxy settings are set as such.
My Proxy URL is set. and runs fine in its own browser tab.
I'm getting a 404 error when I make this call from 'product-template.liquid'
<script> $.get('/tools/getprice', function( data ) { alert ( "DATA: " + data ); }); </script>
I tried something different and it works. Instead of doing a $.get() using the Subpath Prefix and path, I used
the Proxy URL as the $.get() path.
This doesn't make sense and feels like it goes this goes against what Shopify documentation says, but then again
I do find the documentation confusing. I wish Shopify would show us some clear javascript and jquery examples.
I think it should be
<script> $.get('/tools/getprice/', function( data ) { alert ( "DATA: " + data ); }); </script>
can i ask what is the advantage of using app proxy?
Note that while you could use a proxy call to get data from an external database, like price and quantity, that would have no impact on Shopify since the price and quantity are set in stone in Shopify (unless you use an external fulfillment service as your inventory manager with Shopify).
The main reason you'd use an App Proxy is security. It allows you to make a callback to a service you control, out there in the wild, so you can get data, and then do something with it on the Shopify page you called from.
Was a good thought and I had tried that previously and again today, but still see a 404 error.
You call the subpath_prefix + subpath using JS. So ya... fetch('/tools/fizzbuzz') for that or $.get('/tools/fizzbuzz') or $.post('/tools/fizzbuzz').
That is not what is generating the 404. The 404 comes from Shopify taking your data, and trying to call your actual App at the Proxy URL.
So it seems your Proxy URL is not setup to respond to a GET request. Hence, the 404. So ensure your App is configured to listen to /tools/getprice.
Note that even if you get a price back, what would you do with it? It is nothing but a suggestion or decoration right? Is it some kind of compare at price?
Hi HunkyBill (a great handle btw),
Thanks for your comments on the 404 error. You are likely correct about my proxy URL
not set-up to handle a GET request. I will mention this to the programmer, but it sounds
like I will be dropping the need of using an app proxy.
As you suggest, it probably is serving little purpose, so yeah, a decoration.
I'm just starting to read up on fulfillment services that you suggested in your previous comment.
If you set it as such, Shopify will send a query direct to your service, and ask the direct question, "Hey, dude! How much of this thing is in stock".
That way, you control what the peoples can buy and how much. The implication though is that you best be sure your service is up 24/7 or you be in some kind of mess. Like running your own shipping rates service. Comes with great responsibility.