App reviews, troubleshooting, and recommendations
Hi everyone!
I am developing my Shopify app and I am struggling to find solution for checking if my app embed block is active in the user's theme editor, the Shopify documentation about it is very short and not informative.
I would really appreciate help with that!
Hi @Ido1425,
You could check in themes config/settings_data.json. Like the picture below, if an app embed is active, its information should be displayed
let activeAppEmbeds = true;
let contentFile = null;
let searchBlock = false;
// You should write your own getContentFile
let resContentFile = await getContentFile(domain, token,themeId,"config/settings_data.json");
if (resContentFile) {
contentFile = JSON.parse(resContentFile);
}
if (contentFile && contentFile?.current?.blocks) {
const appEmbeds = contentFile?.current?.blocks;
for (const key in appEmbeds) {
if (Object.prototype.hasOwnProperty.call(appEmbeds, key)) {
searchBlock = true;
const app = appEmbeds[key];
// extensionId is your theme app extension id after deployed
if (app.type.includes(extensionId) && app.disabled) {
activeAppEmbeds = false;
break;
}
}
}
if(!searchBlock) {
activeAppEmbeds = false;
}
} else {
activeAppEmbeds = false;
}
I hope this is helpful to you.
B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.
B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.
B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.
BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now
Thank you for that!
The only thing I don't understand is how do I get the content file I want from the current theme.
I couldn't find explanation for that in the Shopify docs
(I am using Gadget.dev)
You need `read_themes` scopes and use Shopify Theme API to get the current/main theme ID (the current theme has its role value as main like the first picture below, you could get the theme list and do filter to get the current theme) and use the returned theme ID to make request to Shopify Asset API to get theme file content, with query param asset[key]=config/settings_data.json
1.
2.
Hope this is helpful to you.
B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.
B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.
B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.
BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now
As 2024 wraps up, the dropshipping landscape is already shifting towards 2025's trends....
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024