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
ljspoor94
ljspoor94β€’12mo ago
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.
Charles13
Charles13OPβ€’12mo ago
Thank you so much @ljspoor94 🀍 let me try that
Unknown User
Unknown Userβ€’12mo ago
Message Not Public
Sign In & Join Server To View
ljspoor94
ljspoor94β€’12mo ago
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
Unknown Userβ€’12mo ago
Message Not Public
Sign In & Join Server To View
ljspoor94
ljspoor94β€’12mo ago
No, and please don't go DM'ing people asking them to look at your post.
Charles13
Charles13OPβ€’12mo ago
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!
Chocci_Milk
Chocci_Milkβ€’12mo ago
ljspoor is not a Gadget employee
ljspoor94
ljspoor94β€’12mo ago
ljspoor dude 😭 πŸ˜‚
Unknown User
Unknown Userβ€’12mo ago
Message Not Public
Sign In & Join Server To View
Chocci_Milk
Chocci_Milkβ€’12mo ago
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?
Charles13
Charles13OPβ€’12mo ago
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?
Chocci_Milk
Chocci_Milkβ€’12mo ago
Why would you need to have the price be encrypted when saving it as a cart line attribute?
Charles13
Charles13OPβ€’12mo ago
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?
Chocci_Milk
Chocci_Milkβ€’12mo ago
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
Charles13
Charles13OPβ€’12mo ago
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
Chocci_Milk
Chocci_Milkβ€’12mo ago
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
Charles13
Charles13OPβ€’12mo ago
I might need your help on moving codes, but let me try and experience it first hehe thank you so much @Chocci_Milk 🀍
Chocci_Milk
Chocci_Milkβ€’12mo ago
I'd like to warn you that I can only give you advice as we don't write code for our users.
Charles13
Charles13OPβ€’12mo ago
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?
Chocci_Milk
Chocci_Milkβ€’12mo ago
I would recommend simply moving the extensions folder if all you need is the function
Charles13
Charles13OPβ€’12mo ago
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 🀍

Did you find this page helpful?