-
-
Notifications
You must be signed in to change notification settings - Fork 312
Themes
Joshua Harms edited this page Dec 20, 2023
·
1 revision
The ThemeService
lets you create, update, list, get and delete a store's themes.
When you create a theme, you can optionally pass in a URL that points to a .zip file containing all of the new theme's files. Shopify will then copy those files into the theme. Be aware that copying files is not instant, and the theme's Processing
flag will be set to true
until it's done.
You cannot update or delete a theme that is still processing.
var service = new ThemeService(myShopifyUrl, shopAccessToken);
var theme = new Theme()
{
Name = "My new theme.",
Role = "unpublished"
}
theme = await service.CreateAsync(theme);
//Or, create a theme and copy its files from a .zip file URL
theme = await service.CreateAsync(theme, 'https://my-domain.com/my-theme-files.zip');
var service = new ThemeService(myShopifyUrl, shopAccessToken);
var theme = await service.GetAsync(themeId);
Remember, you can't update a theme if its Processing
flag is set to true
. Shopify will automatically set it to false
once it's done processing. Additionally, you cannot set a theme's role from "main"
to "unpublished"
. Instead, you need to set a different theme's role to "main"
.
var service = new ThemeService(myShopifyUrl, shopAccessToken);
var theme = await service.UpdateAsync(themeId, new Theme()
{
Role = ThemeRole.Main,
Name = "My updated theme."
});
var service = new ThemeService(myShopifyUrl, shopAccessToken);
await service.DeleteAsync(themeId);
var service = new ThemeService(myShopifyUrl, shopAccessToken);
var themes = await service.ListAsync();