switch mockup generator to UK print providers and add --replace flag
- Prefer Print Clever (72) for canvas, Monster Digital (29) for apparel and mugs where available, fall back to default providers - Rename Art Print products to Canvas (new Satin Canvas blueprint) - Add Canvas Prints category in Printify tag extraction - Add --replace/-r flag to purge existing Printify products before generating (with interactive confirmation) - Add purge_all_products/1 to generator module - Remove old art print mockups, add new canvas + extra provider mockups Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -21,43 +21,43 @@ defmodule SimpleshopTheme.Mockups.Generator do
|
||||
def product_definitions do
|
||||
[
|
||||
%{
|
||||
name: "Mountain Sunrise Art Print",
|
||||
slug: "mountain-sunrise-print",
|
||||
category: "Art Prints",
|
||||
name: "Mountain Sunrise Canvas",
|
||||
slug: "mountain-sunrise-canvas",
|
||||
category: "Canvas Prints",
|
||||
artwork_url: unsplash_download_url("UweNcthlmDc"),
|
||||
product_type: :poster,
|
||||
product_type: :canvas,
|
||||
price: 2400
|
||||
},
|
||||
%{
|
||||
name: "Ocean Waves Art Print",
|
||||
slug: "ocean-waves-print",
|
||||
category: "Art Prints",
|
||||
name: "Ocean Waves Canvas",
|
||||
slug: "ocean-waves-canvas",
|
||||
category: "Canvas Prints",
|
||||
artwork_url: unsplash_download_url("XRhUTUVuXAE"),
|
||||
product_type: :poster,
|
||||
product_type: :canvas,
|
||||
price: 2400
|
||||
},
|
||||
%{
|
||||
name: "Wildflower Meadow Art Print",
|
||||
slug: "wildflower-meadow-print",
|
||||
category: "Art Prints",
|
||||
name: "Wildflower Meadow Canvas",
|
||||
slug: "wildflower-meadow-canvas",
|
||||
category: "Canvas Prints",
|
||||
artwork_url: unsplash_download_url("QvjL4y7SF9k"),
|
||||
product_type: :poster,
|
||||
product_type: :canvas,
|
||||
price: 2400
|
||||
},
|
||||
%{
|
||||
name: "Geometric Abstract Art Print",
|
||||
slug: "geometric-abstract-print",
|
||||
category: "Art Prints",
|
||||
name: "Geometric Abstract Canvas",
|
||||
slug: "geometric-abstract-canvas",
|
||||
category: "Canvas Prints",
|
||||
artwork_url: unsplash_download_url("-6GvTDpkkPU"),
|
||||
product_type: :poster,
|
||||
product_type: :canvas,
|
||||
price: 2800
|
||||
},
|
||||
%{
|
||||
name: "Botanical Illustration Print",
|
||||
slug: "botanical-illustration-print",
|
||||
category: "Art Prints",
|
||||
name: "Botanical Illustration Canvas",
|
||||
slug: "botanical-illustration-canvas",
|
||||
category: "Canvas Prints",
|
||||
artwork_url: unsplash_download_url("FNtNIDQWUZY"),
|
||||
product_type: :poster,
|
||||
product_type: :canvas,
|
||||
price: 2400
|
||||
},
|
||||
%{
|
||||
@@ -157,25 +157,20 @@ defmodule SimpleshopTheme.Mockups.Generator do
|
||||
"""
|
||||
def blueprint_config do
|
||||
%{
|
||||
# Search terms matched to Printify's actual blueprint titles (partial match)
|
||||
poster: %{blueprint_id: nil, print_provider_id: nil, search_term: "Matte Posters"},
|
||||
tshirt: %{blueprint_id: nil, print_provider_id: nil, search_term: "Softstyle T-Shirt"},
|
||||
hoodie: %{blueprint_id: nil, print_provider_id: nil, search_term: "Pullover Hoodie"},
|
||||
tote: %{blueprint_id: nil, print_provider_id: nil, search_term: "Cotton Tote Bag"},
|
||||
mug: %{blueprint_id: nil, print_provider_id: nil, search_term: "Mug 11oz"},
|
||||
cushion: %{
|
||||
blueprint_id: nil,
|
||||
print_provider_id: nil,
|
||||
search_term: "Spun Polyester Square Pillow"
|
||||
},
|
||||
blanket: %{blueprint_id: nil, print_provider_id: nil, search_term: "Sherpa Fleece Blanket"},
|
||||
notebook: %{
|
||||
blueprint_id: nil,
|
||||
print_provider_id: nil,
|
||||
search_term: "Hardcover Journal Matte"
|
||||
},
|
||||
phone_case: %{blueprint_id: nil, print_provider_id: nil, search_term: "Tough Phone Cases"},
|
||||
laptop_sleeve: %{blueprint_id: nil, print_provider_id: nil, search_term: "Laptop Sleeve"}
|
||||
# Search terms matched to Printify's actual blueprint titles (partial match).
|
||||
# preferred_provider_id selects a UK-based provider where available:
|
||||
# 29 = Monster Digital (UK) — apparel, mugs
|
||||
# 72 = Print Clever (UK) — canvas prints
|
||||
canvas: %{search_term: "Satin Canvas, Stretched", preferred_provider_id: 72},
|
||||
tshirt: %{search_term: "Softstyle T-Shirt", preferred_provider_id: 29},
|
||||
hoodie: %{search_term: "Heavy Blend™ Hooded Sweatshirt", preferred_provider_id: 29},
|
||||
tote: %{search_term: "Cotton Tote Bag", preferred_provider_id: nil},
|
||||
mug: %{search_term: "Ceramic Mug", preferred_provider_id: 29},
|
||||
cushion: %{search_term: "Spun Polyester Square Pillow", preferred_provider_id: nil},
|
||||
blanket: %{search_term: "Sherpa Fleece Blanket", preferred_provider_id: nil},
|
||||
notebook: %{search_term: "Hardcover Journal Matte", preferred_provider_id: nil},
|
||||
phone_case: %{search_term: "Tough Phone Cases", preferred_provider_id: nil},
|
||||
laptop_sleeve: %{search_term: "Laptop Sleeve", preferred_provider_id: nil}
|
||||
}
|
||||
end
|
||||
|
||||
@@ -210,13 +205,19 @@ defmodule SimpleshopTheme.Mockups.Generator do
|
||||
|
||||
@doc """
|
||||
Find a suitable print provider for a blueprint.
|
||||
Prefers providers with good ratings and reasonable pricing.
|
||||
|
||||
When `preferred_provider_id` is given, uses that provider if available
|
||||
for the blueprint. Falls back to the first provider otherwise.
|
||||
"""
|
||||
def find_print_provider(blueprint_id) do
|
||||
def find_print_provider(blueprint_id, preferred_provider_id \\ nil) do
|
||||
case Client.get_print_providers(blueprint_id) do
|
||||
{:ok, providers} when is_list(providers) and providers != [] ->
|
||||
# Just pick the first provider for simplicity
|
||||
{:ok, hd(providers)}
|
||||
provider =
|
||||
if preferred_provider_id do
|
||||
Enum.find(providers, fn p -> p["id"] == preferred_provider_id end)
|
||||
end
|
||||
|
||||
{:ok, provider || hd(providers)}
|
||||
|
||||
{:ok, []} ->
|
||||
{:error, :no_providers}
|
||||
@@ -384,6 +385,26 @@ defmodule SimpleshopTheme.Mockups.Generator do
|
||||
end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Deletes all products from the Printify shop.
|
||||
Returns the number of products deleted.
|
||||
"""
|
||||
def purge_all_products(shop_id) do
|
||||
case Client.list_products(shop_id) do
|
||||
{:ok, %{"data" => products}} when is_list(products) ->
|
||||
Enum.each(products, fn p ->
|
||||
IO.puts(" Deleting: #{p["title"]} (#{p["id"]})")
|
||||
Client.delete_product(shop_id, p["id"])
|
||||
Process.sleep(200)
|
||||
end)
|
||||
|
||||
length(products)
|
||||
|
||||
_ ->
|
||||
0
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Generate mockups for all products.
|
||||
"""
|
||||
@@ -450,7 +471,7 @@ defmodule SimpleshopTheme.Mockups.Generator do
|
||||
with {:ok, blueprint} <- find_blueprint(config.search_term),
|
||||
blueprint_id = blueprint["id"],
|
||||
_ = IO.puts(" Found blueprint: #{blueprint["title"]} (#{blueprint_id})"),
|
||||
{:ok, provider} <- find_print_provider(blueprint_id),
|
||||
{:ok, provider} <- find_print_provider(blueprint_id, config[:preferred_provider_id]),
|
||||
provider_id = provider["id"],
|
||||
_ = IO.puts(" Using provider: #{provider["title"]} (#{provider_id})"),
|
||||
{:ok, variants} <- get_variant_info(blueprint_id, provider_id),
|
||||
|
||||
Reference in New Issue
Block a user