So i have a customer that wants to keep his inventory in sync with the supplier (who has a stock API) in magento I wrote a plugin that on page load updated the inventory and then re-rendered the page showing the updated value.
I've seen that shopify has an API, but I couldn't see if what I wanted to do was do-able.
Has anyone got any thoughts?
I could hit the API every 15mins and updated all the products, but this seems like an overkill
You cannot update Shopify inventory in real-time without using an App. Install your custom App in your client store. That App can then securely call the supplier API and get values for inventory. Using your API permissions in the Shopify you can then update Shopify
As David said you need an app. It can be a custom app, that is an app that you don't think to put on the market place and that is only available on a particular store.
In particular, I don't think you need an embedded app, you just need to have the access token and make your REST calls.
You will need to create one webhook on Shopify and one webhook on Magento, to syncrhonize the two stocks.
I don't have any knowledege of Magento but on Shopify the webhook that I think you should use is inventory_levels/update that is triggered whenever the stock changes, and that also depends on the location of your products. The same you should do on Magento.
This is a python script that is doing the update when receiving the webhook
def sync_inventory():
inventory_request = app.current_request.json_body
inventory_id = inventory_request["inventory_item_id"]
location_id = inventory_request["location_id"]
if location_id not in WAREHOUSE_IDS or inventory_id not in INVENTORY_IDS:
# Discarded inventory event
return {}
return sync_inventory_data(inventory_id) # do your magento call here
Related
I've a client that wants certain clients to buy with Store Credit. The amount of credit is stored in their external ERP system. My idea was to create a manual custom payment, show this payment method for users with a certain customer tag and add some scripts in the checkout in order to execute a web request and get how much credit the client has at that moment and do some validations (don't let them order if the checkout is bigger than the credit) in order to let them complete the order or not.
The only link I've found basically says:
With a few exceptions, Shopify Scripts are not capable of input/output. This means that scripts can't execute web requests or database calls, and can't get input from a user. Source: https://help.shopify.com/en/manual/checkout-settings/script-editor/limitations#input-output
The client is aware they need to upgrade to Shopify Plus, but I can't find examples or any information that indicates this idea is doable.
I don't think Shopify Script is the solution in this case. (You can't make any outside call inside a script)
If you plan to use Shopify Plus you can modify checkout.liquid. You can create an app that has an endpoints that
Tells you how many points the customer has
Redeems X points and returns a discount code
Having that you can put a javascript that when checking out insert a button to redeem the points and if it's clicked you call the api and apply the discount.
To apply dynamically a coupon at checkout this is a working piece of code.
document.querySelector("#checkout_reduction_code").value = YOUR_CODE;
document.querySelector(".field__input-btn.btn").disabled = false;
document.querySelector(".field__input-btn.btn").click();
Other solution is to use Shopify Functions (https://shopify.dev/api/functions). This is a new feature that is availble in preview and lets you customize the checkout experience. I don't have experience with that but I suppose you can do something similar.
My company would like to sell products through the Shopify Platform, but be they want to be able to get their prices and stock levels from an external data base. We have developers that know how to create an API, but we do not quite understand how to set up a private app to do this.
For instance, we want to make an ajax call to this endpoint www.{ourDomain}/shopify/getPrice.html?Part=UserRequestedPart and the endpoint would return some JSON or XML data which I would expect to parse and display in Shopify.
Create a private app with write_products and write_inventory scopes.
Access your endpoint to get current prices/inventory from your external database.
Update Shopify product prices/inventory using Shopify API.
Use Product Variant to update prices.
Use Inventory Level endpoint to update the quantity.
More details can be found here: Shopify Admin API
I am attempting to work on some integration with Shopify and Shippo, part of the process is sending an email to our warehouse including the order line items with the Shipping Label attached as a PDF.
When we create the label in Shippo, the fulfillment information is updated in Shopify correctly, but I was wondering if there was any way to link the two back up reliably from an API perspective since the Shippo API appears to not include any invoice information. I see a link to an internal order object, but the API docs don't seem to stipulate any further information and the Shopify Fulfillment record does not appear to include any Shippo object id.
The only thing I see if the Shippo Order Metadata field which includes the order number, so I suppose I could parse this and make the request to Shopify's API but I would prefer a more concrete link if one is available.
We (I'm working on Shippo's product team) currently don't officially support Shopify Fulfillments with Shippo API label purchases.
That said, we have an Orders API endpoint in beta. The Orders endpoint allows you to retrieve all Orders of a Shippo account, including those imported automatically from Shopify. Each order, like all other Shippo resources, has an object_id field.
When you create a label through the Shippo API's Transaction endpoint, you can link the Order to the Transaction by sending the additional flag order, setting it to the object_id of the corresponding Order (e.g.: { ... "order": "<order-object-id>" ... }). This will trigger the corresponding Fulfillment of the order on its shopping cart platform, in your case Shopify.
Feel free to reach out to product#goshippo.com if you have more questions about this endpoint. Please keep in mind that it is still in closed beta and the endpoint might change in the future.
All I'm wanting to do is track sales of certain products from a certain date. My company is wanting to add a banner to track sales goals for raising money for charities. So basically, we'd tag a few products as being part of that goal, set a goal, and then need to update the goal progress by a certain amount every time a sale is made on one of those products. As far as I can tell, without access to Shopify's analytics API, this is not possible. How can I do this?
What you want to build is perfectly possible. However, you need to generate Private App Credentials, so you can use Shopify API. It doesn't matter if you have an account by yourself, someone else can follow these steps and send you the credentials your way.
If you don't actually need to modify anything through the API, you could have them set a webhook (Settings -> Notifications -> Webhook) on Order Creation (or similar) that posts to your server and you can check what product got sold and see if it has got the tag.
The "easy" way to do this is to create an app that receives order webhooks and can check on tagged products and keep a sum of target items sold.
Then the app should have use a script tag to insert a simple script with the current value into the web page at a configured place by css selector
OR the app could update one or more snippet files that you could include until the promo is done.
I'd tend to go with the script tag option since that's a bit more flexible and you should be able to change your theme when the promo is over to report results without having to touch the app again.
I have a webshop and im almost there, but I have a number of items for purchase which are downloadable content. I fixed so when a user has paid they are redirected to my pdt.php where they get a receipt, Now I written code for also displaying content if the item-id are == something. Now I wanna make a sandbox/test-purchase of all products that are downloadable ontent which are 28. I can create 28 buttons and have the id 1-28 but that seems stupid. How can I do this easier?
Check out the cart upload command method of sending transaction data to PayPal. It's similar to standard buttons except that you'll include all items in a single form.
Alternatively, if you're familiar with web service API's I'd recommend using the Express Checkout API. This gives you more freedom over your checkout and provides more advanced features as well.