Shopify cart transform to update line item price using Gadget's forkable templates
I am trying to update cart line items price, and I am thinking of using
shopifyCart create and update's on-success method to listen for Cart changes and then modify the line items from there, but I am going to need the customer-id which the shopifyCart's schema does not have. Any ideas on how to do this? May I also ask for examples to follow? Thank you so much!22 Replies
Straight up answer, if you can't retrieve it in there input there isn't much way. The only way I can think of is you'd need to send the customers ID inside the cart attributes and retrieve it from that.
Thank you so much @ljspoor94 π€ let me try that
Unknown Userβ’12mo ago
Message Not Public
Sign In & Join Server To View
Please actually read what the OP has posted, he's using the Cart Transform API, you can't hit an API inside the cart transform function
You can't call a API inside of the Cart Transform API.
Unknown Userβ’12mo ago
Message Not Public
Sign In & Join Server To View
No, and please don't go DM'ing people asking them to look at your post.
Sorry, I want to understand Gadget's forkable templates for shopify, are they shopify functions or just webhooks to listen for creates or updates? How do forkable templates work? Thank you!
ljspoor is not a Gadget employee
ljspoor dude π π
Unknown Userβ’12mo ago
Message Not Public
Sign In & Join Server To View
Forkable templates use the built in functionality of Gadget and Shopify to give you a starting point. There aren't necessarily complete applications. Gadget and it's templates don't give you more than whats possible with Shopify's APIs. I don't know of a way to make what you're asking possible with your constraints. Have you asked Shopify's Slack community if they have more information to give you?
Hi @Chocci_Milk thank you for your response π€ I was reading on the documentation and it made me install the template on my local and I saw the extension folder and did some trials and errors from there and finally I successfully updated the cart line price. All that is left for me is to get the actual price that I will put on the line price, however as @ljspoor94 mentioned, and also from what I have read, the Cart transform api does not allow external API call so I am thinking of saving the price in the cart line's attribute and also encryting it first?
Why would you need to have the price be encrypted when saving it as a cart line attribute?
I was thinking it will maintain the integrity of the data? Please enlighten me if I'm wrong. Thank you!
I also want to add @Chocci_Milk or anyone from the Gadget's team, can I turn my Gadget app into something like the forkable templates while keeping its original functionalities?
Maybe I missed something in your use case but why would you need to encrypt a price? It can simply clear text.
Also, there's currently no way to late summon code into your application. You need to add the functionality from templates into existing apps or vis versa
Yes, sorry that is what I meant, I want to add the templates functionality, would that be easy? For the encryption part, I am not really sure yet and I also think I need to reconsider that since I havent fully read the documentation of it, I was thinking maybe someone would intercept the data coming to the shopify function lol
How easy it is depends on your experience. I donβt find it difficult to move code from one app to the other but it might be different for you.
Shopify should be handling encryption since youβre using their functions to save metafields and attributes
I might need your help on moving codes, but let me try and experience it first hehe thank you so much @Chocci_Milk π€
I'd like to warn you that I can only give you advice as we don't write code for our users.
Sure, I understand. The first question that comes to my mind is that what are the files I need to move from template to the custom app? I presume these are the Shopify related files and folders, but the app only needs the Cart Transform API for setting custom prices so there must be files that will be out of the equation.
What are the steps I should best follow?
I would recommend simply moving the extensions folder if all you need is the function
Hi @Chocci_Milk I just saw your reply, but that's similar to what I did and luckily it all went smoothly π
Still, thank you for the help. I really appreciate π€