Post-installation, your app can provide deep links to help merchants add app blocks.> …> > Adding an app block to the main section> > The main section is a section with ID=“main”.> > The following example shows a deep link structure for adding an app block to the main section of a template:> > https://
So how and where do I add this deep link?
Like so? This won’t work.
The following is the deep link structure for adding an app block to any JSON template in a new Apps section.
https:///admin/themes/current/editor?template=${template}&addAppBlockId={uuid}/{handle}&target=newAppsSection
In this structure you need
1.myshopifyDomain : Store URL
2. Template:The JSON template to which the app block should be added. If not set, then Shopify will default to the index.json template.
3. UUID: This file is only available after you run the deploy command for the first time in .env file
4.newAppsSection: Your theme app extension name
Joy Matubber| Brain Station 23 - Was my reply helpful? Click Like to let me know! - Was your question answered? Mark it as an Accepted Solution - To learn more contact us : js.team@brainstation-23.com
Thanks! That’s an example the documentation lacks.
But several things are still not clear.
How do I get ${shopDomain} in hadleDeepLink()?
What template should I use? I want to add the App block as a section, not to some product.
Should I use &target=mainSection? That seems not to work.
I tried to hardcode my test store domain so far.
When I click the button the new window opens with the editor, but no App Block is added to the page, no prompt to add it.
Can we make deep link to add an app block in the editor?
@awidget
You can get shopDomain from the current session data
here is an example:
const { admin, session } = await authenticate.admin(request);
const shopData = await admin.rest.resources.Shop.all({ session: session });
const shopDomain= shopData?.data[0].domain;
If you went to add an app block as a section you could flow
{template}
The JSON template to which the app block should be added. If not set, then Shopify will default to the index.json template.
@Av18
Yes, it is possible to add your section in the app block using deep linking
You need to use an app-embedded block.
Procedure:
By default, app embed blocks are deactivated after an app is installed. Merchants need to activate app embed blocks in the theme editor, from Theme Settings > App embeds. However, your app can provide merchants with a deep link, post-installation, to activate an app embed block automatically.
Like and reply to reach you further
Joy Matubber | Brain Station 23
Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it as an Accepted Solution
“Hi @BrainStation23 ,
I wanted to thank you for your previous response - it worked perfectly!
I do have a question regarding AppBlocks (not App embeds) though. I’ve created a deep link: https://${shopData.shopify_domain}/admin/themes/current/editor?template=product&addAppBlockId=${AppBlockId}/custom_bundle&target=mainSection
The issue I’m facing is that if I click on this link multiple times, the AppBlock gets added multiple times too. I’d like to avoid this from happening. Could you please suggest a solution for this?
Thank you!”.
@Av18
Kindly click on this (https://shopify.dev/docs/apps/online-store/theme-app-extensions/extensions-framework#detecting-app-blocks-and-app-embed-blocks) to see it. You should use Admin API, Rest, or GraphQL to access the shop’s theme settings, which have the asset name/address config/settings_data.json. Using the field type, you can locate your block in the blocks array when you read this asset. If you locate it there, you will see a field labeled disabled. If the value is false, it indicates that the merchant is now active on your block.
Accept, Like, and reply to reach you further
Joy Matubber | Brain Station 23
Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it as an Accepted Solution
Look here this is my product.json after clicking twice on the same Deeplink.
here two blocks are created, if I want to remove one block then I must need to remove one of these blocks from product.json but how is it possible that if the user clicks multiple times on DeepLink then only one block will be added not more than one?