I have created discount function for shipping using discountAutomaticAppCreate mutation. it is working well and good. the details are fetched from the frontend and passed for applying discount logic in the storefront.
now I want to update the function using update mutation. can someone who is familiar with this help me out??.
so like I’m passing some additional details through metafields for the backend discount logic to have dynamic behaviour. When trying to update, how should I send the updated details?
I’m sending in this format.
In the discountAutomaticAppCreate mutation, there is no metafield Id or other details about it returned. Could you tell me how can I get the metafield details associated to the discount function… So that I can store those details into DB and use it for update purpose.
I’m attaching my create mutation code also. Kindly have a look into it.
This is what I was also thinking about ( to create the metafield using MetafieldSet and map with the discount function). For the update mutation, can I just update the metafield alone using the discountID of the discount function. In such case, we do not need update mutation right. I just think of this way. What is your suggestion… Is there any alternate way to update the mutation, when there is a change from the UI. Say, I’m passing three values from the UI in the initial creation process and later I update the values from UI and want the discount function to work with the updated values.
Thanks for the great help. It is actually working well. I implemented the discount function and metafield creation successfully. I’m facing an issue in the data storing into DB; I’m working on it. After that, I’ll let you know once the update mutation is also working fine.
I have another query. This is a remix app. By default when installing an app in the dev store, the details of the store is received. The shopify creates a session schema on its own to handle authentication right. In session schema, the shop field is available which stores the URL of the store. But when I fetched the store details using GraphQL mutation, it has a field named shopId. When I authenticate user in the server-side actions, the session schema should be used. But it doesn’t have a field named shopId right. If then how can we authenticate the store when accessing to the server-side actions?
Thank you Mr. Prakhar. It was great communicating with you. I’m completely new to this shopify development. I’m learning by doing. Sometimes I get issues and stuck somewhere. It takes a bit of time to solve it. But, this update issue was a prolonged one which I was facing. Your help in this played a crucial role to get me out this and learn how it works. Thank you once again for the continuous help.