Skip to contents

Inserts or updates the print store URL for an artwork. Use this when an artist wants to link their artwork to an external print-on-demand service. The function determines INSERT vs UPDATE based on whether the artwork already has a print record.

Usage

.upsert_print_url(url, artist, artwork, has_print, cn = NULL)

Arguments

url

Character. The print store URL. If `NULL` or empty string, the function returns early without making changes.

artist

Character. Artist UUID.

artwork

Character. Artwork UUID.

has_print

Logical. If `TRUE`, updates existing record in `app.artwork_print`. If `FALSE`, inserts new record and sets `is_print = TRUE` in `app.artwork_index`.

cn

Database connection. If `NULL`, opens and closes automatically.

Value

`invisible(NULL)`. Called for side effects (database writes).

Details

This function performs two different operations based on `has_print`:

**When `has_print = TRUE` (UPDATE):** - Updates `print_url` in existing `app.artwork_print` record

**When `has_print = FALSE` (INSERT):** - Inserts new row into `app.artwork_print` - Sets `is_print = TRUE` in `app.artwork_index`

The `has_print` flag should come from `app.artwork_index.is_print` to ensure consistency.

See also

[.upsert_nft_url()] for OpenSea NFT links

Examples

if (FALSE) { # \dontrun{
# Update existing print URL
.upsert_print_url(
  url = "https://society6.com/artist/artwork",
  artist = "746b8207-72f5-4ab6-8d19-a91d03daec3d",
  artwork = "99a61148-1d3b-4340-8cf6-92ad26046b0f",
  has_print = TRUE
)

# Add new print URL (artwork not yet print-enabled)
.upsert_print_url(
  url = "https://redbubble.com/shop/artwork",
  artist = artist_uuid,
  artwork = artwork_uuid,
  has_print = FALSE
)
} # }