Shopify: How to make new products hidden by default? - shopify

I have a shopify site that is hooked up with Lightspeed via MerchantOS. I need new products added via MerchantOS to be hidden upon sync/creation. All help is appreciated.

The Shopify product creation via API allows you to define the product visiblity (published / hidden). You should dig into MerchantOS to make sure when doing a POST to create a product at your Shopify store, it has the following property:
"published": false
Create a new, but unpublished product:
POST /admin/products.json
{
"product": {
"title": "Burton Custom Freestlye 151",
"body_html": "<strong>Good snowboard!<\/strong>",
"vendor": "Burton",
"product_type": "Snowboard",
"published": false
}
}

Related

Shopify - Modify Page Template & Sections Reference For Custom Page

I am attempting to modify a specific route/template in my Shopify theme, however nothing from examples I have seen or the documentation seems to take.
Currently I have created a page in the Shopify Admin team which is auto assigned to the route /pages/team-page.
In my templates directory I have tried creating different variations as to assign it a custom section such as
team.json
team_page.json
page.team.json
page.team_page.json
And within those json files referenced to my sections directory liquid file custom.liquid with the following:
{
"sections": {
"custom": {
"type": "custom",
"settings": {}
},
"order": [ "custom" ]
}
But to no avail it always references back to the template index.json which renders main.liquid from sections.
Attempting to print out the page.handle returns team-page, while page.template_suffx seems to return nothing.

Is there a way to create a project via Youtrack API with a non-standard template?

I'm trying to create a new project with the Youtrack API. And now I want to create a project with a template that I've created by myself on Youtrack. The API have only "scrum" and "kanban" as possible template parameters. Is there a way to create a project with my own template?
I used this API Call from the Youtrack API documentation site: Add a New Project
Thank you for your help.
Try passing the name of your template as a parameter:
POST https://username.myjetbrains.com/youtrack/api/admin/projects?fields=name,shortName,id&template=<template_name>
{
"leader": {
"login": "root",
"id": "24-0"
},
"shortName": "MSP",
"name": "Project from REST",
"description": "Template Project"
}

Shopify App: Any event for detecting change of theme or make theme sections persist even after theme changes?

I've created a shopify app which adds a new theme section to active theme when it is installed. Now I am concerned that if the shopify store user changed their store's theme then my theme section changes will get removed.
Is there a way to persist my theme section changes. If not, can I listen to an event/webhook from shopify which will inform me of the change in theme?
There are webhooks for themes/update and themes/publish. You might try monitoring for publish events with theme_id or name properties that don't match your expected theme and issue warning notifications about those section data going away.
This is an example response from the docs:
{
"id": null,
"name": "Comfort",
"created_at": "2021-04-01T14:58:14-04:00",
"updated_at": "2021-04-01T14:58:14-04:00",
"role": "main",
"theme_store_id": 1234,
"previewable": true,
"processing": false
}

Add Product Images with Shopify API

We have a bunch of disassociated product images in our Shopify store that support could not re-associate. I set up a Postman collection runner to update all these missing images, and it seems to be working in our test environment....
Except, the API call is replacing the default product image with a new image rather than adding the image. I'm using a standard PUT request to the API using the example in their API docs:
PUT /admin/api/2019-04/products/#{product_id}.json
{
"product": {
"id": 632910392,
"images": [
{
"src": "http://example.com/rails_logo.gif"
}
]
}
}
I get that it's an array I'm sending in, so I'm thinking it's overwriting the array each time rather than adding a new element. I tried using a single element variable of "image" in the JSON but that didn't work.
Any ideas?
If you want to add the image use ProductImage resource instead of Product resource.
Product Image Documentation
POST /admin/api/2019-04/products/#{product_id}/images.json
{
"image": {
"src": "http://example.com/rails_logo.gif"
}
}

Creating a shopify template with unique content blocks

I have an ecommerce site, and I'm trying to create a "Lookbook" template. I want my client to be able to create a new lookbook (just as a simple page with a template of "page.lookbook" or similar), then be able to go into the page admin and select and upload images, links, descriptions etc.
So far I have:
page.lookbook.liquid -> calls in the section, lookbook-template.liquid
lookbook-template.liquid has an HTML template
It also has this schema:
{% schema %}
{
"name": "Lookbook",
"blocks": [
{
"type": "Image",
"name": "Lookbook image",
"settings":[
{
"type": "image_picker",
"id": "img",
"label": "Image"
},
{
"type": "text",
"id": "description",
"label": "Description",
"default": "<p>You can write <em>html</em> in here!</p>"
}
]
}
]
}
{% endschema %}
This way, my client can use the simple admin tools to add a new image block. Very nice!
However, this method means that every single lookbook gets the SAME image data as whatever I apply to the lookbook-template.liquid, and this isn't ideal at all.
What am I doing wrong here, and what's the right solution? I want one template that the client choose to attach to a page, and then for each template to have a unique set of images, links and descriptions that the client creates.
Unfortunately, section won't work to get some different content for each page with lookbook.page template.
A solution would be to install (or create) an app to manage metafields attached to pages. Then you can use metafields in your template.
Metafields is a way to add some extra fields in database:
https://help.shopify.com/themes/liquid/objects/metafield