Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

third batch of REST to GraphQL conversions for products and variants #407

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ This directory is built automatically. Each task's documentation is generated fr
* [Auto-remove a product tag x days after it's added](./auto-remove-a-product-tag-x-days-after-its-added)
* [Auto-remove attributes on new orders after X minutes](./auto-remove-attributes-on-new-orders-after-x-minutes)
* [Auto-reserve draft order items for X days](./auto-reserve-draft-order-items-for-x-days)
* [Auto-sort collections by a product property](./auto-sort-collections-by-product-properties)
* [Auto-sort collections by inventory levels](./auto-sort-collections-by-inventory-levels)
* [Auto-sort collections by product properties](./auto-sort-collections-by-product-properties)
* [Auto-tag a customer's first order](./auto-tag-a-customers-first-order)
* [Auto-tag cancelled orders](./auto-tag-cancelled-orders)
* [Auto-tag customers based on discount codes used](./auto-tag-customers-based-on-discount-codes-used)
Expand Down Expand Up @@ -622,8 +622,8 @@ This directory is built automatically. Each task's documentation is generated fr
* [Auto create collections by metafield values](./auto-create-collections-by-metafield-values)
* [Auto-add products to a custom collection when tagged](./auto-add-products-to-a-custom-collection-when-tagged)
* [Auto-create collections by product type or vendor](./auto-create-collections-by-product-type-or-vendor)
* [Auto-sort collections by a product property](./auto-sort-collections-by-product-properties)
* [Auto-sort collections by inventory levels](./auto-sort-collections-by-inventory-levels)
* [Auto-sort collections by product properties](./auto-sort-collections-by-product-properties)
* [Auto-tag orders by product collections](./auto-tag-orders-by-product-collections)
* [Auto-tag products in a manual collection](./auto-tag-products-in-a-manual-collection)
* [Delete the oldest x products from a specific collection](./delete-the-oldest-x-products-from-a-specific-collection)
Expand Down Expand Up @@ -1353,7 +1353,7 @@ This directory is built automatically. Each task's documentation is generated fr
* [Auto-publish new products](./auto-publish-new-products)
* [Auto-publish products tagged with the current day](./auto-publish-products-tagged-with-the-current-day)
* [Auto-reserve draft order items for X days](./auto-reserve-draft-order-items-for-x-days)
* [Auto-sort collections by product properties](./auto-sort-collections-by-product-properties)
* [Auto-sort collections by a product property](./auto-sort-collections-by-product-properties)
* [Auto-tag customers when they purchase a matching product](./auto-tag-customers-upon-product-purchase)
* [Auto-tag customers who purchase an item on sale](./auto-tag-customers-who-purchase-an-item-on-sale)
* [Auto-tag customers with product tags from their order](./tag-customers-with-product-tags-from-their-order)
Expand Down Expand Up @@ -1641,8 +1641,8 @@ This directory is built automatically. Each task's documentation is generated fr

### Sort

* [Auto-sort collections by a product property](./auto-sort-collections-by-product-properties)
* [Auto-sort collections by inventory levels](./auto-sort-collections-by-inventory-levels)
* [Auto-sort collections by product properties](./auto-sort-collections-by-product-properties)
* [Move out-of-stock products to the end of a collection](./move-out-of-stock-products-to-the-end-of-a-collection)

### Spend
Expand Down
4 changes: 2 additions & 2 deletions docs/abandoned-checkout-emails/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Tags: Abandoned Checkout, Email, Retention

This task monitors checkouts in your store, and kicks off an email a configurable number of hours after a checkout is created if the checkout wasn't completed, and if the customer provided their email address.
This task monitors checkouts in your store, and kicks off an email a configurable number of hours after a checkout is created - if the checkout wasn't completed, and if the customer provided their email address.

* View in the task library: [tasks.mechanic.dev/abandoned-checkout-emails](https://tasks.mechanic.dev/abandoned-checkout-emails)
* Task JSON, for direct import: [task.json](../../tasks/abandoned-checkout-emails.json)
Expand Down Expand Up @@ -36,7 +36,7 @@ shopify/orders/create

## Documentation

This task monitors checkouts in your store, and kicks off an email a configurable number of hours after a checkout is created if the checkout wasn't completed, and if the customer provided their email address.
This task monitors checkouts in your store, and kicks off an email a configurable number of hours after a checkout is created - if the checkout wasn't completed, and if the customer provided their email address.

This task uses the same basic formatting as the standard Shopify abandoned checkout notification template. You may override the action button background with your own brand color, provided it is entered as an RGB hex value (e.g. #abc123).

Expand Down
72 changes: 66 additions & 6 deletions docs/abandoned-checkout-emails/script.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,78 @@
{% assign line_item_output = array %}

{% for line_item in checkout.line_items %}
{% assign product = shop.products[line_item.product_id] %}
{% assign variant = shop.variants[line_item.variant_id] %}
{% assign variant_image = product.images | where: "id", variant.image_id | first %}
{% assign image = variant_image | default: product.image %}
{% comment %}
-- query GraphQL variant and product resource to determine line item image to use
{% endcomment %}

{% capture query %}
query {
productVariant(id: {{ line_item.variant_id | prepend: "gid://shopify/ProductVariant/" | json }}) {
image {
url(transform: {
maxWidth: 60
maxHeight: 60
scale: 3
crop: CENTER
})
}
product {
featuredMedia {
mediaContentType
... on MediaImage {
image {
url(transform: {
maxWidth: 60
maxHeight: 60
scale: 3
crop: CENTER
})
}
}
}
media(
first: 1
query: "media_type:image"
) {
nodes {
... on MediaImage {
image {
url(transform: {
maxWidth: 60
maxHeight: 60
scale: 3
crop: CENTER
})
}
}
}
}
}
}
}
{% endcapture %}

{% assign result = query | shopify %}

{% assign variant = result.data.productVariant %}

{% comment %}
-- use image assigned to variant if it exists; else use the featured media for the product if it is an image; else use the first product image
{% endcomment %}

{% assign image_url
= variant.image.url
| default: variant.product.featuredMedia.image.url
| default: variant.product.media.nodes.first.image.url
%}

{%- capture line_item_html -%}
<tr class="order-list__item">
<td class="order-list__item__cell">
<table>
<td>
{% if image %}
<img src="{{ image.src | img_url: 'compact_cropped' }}" align="left" width="60" height="60" class="order-list__product-image"/>
{% if image_url %}
<img src="{{ image_url }}" align="left" width="60" height="60" class="order-list__product-image"/>
{% endif %}
</td>
<td class="order-list__product-description-cell">
Expand Down
2 changes: 1 addition & 1 deletion docs/auto-fulfill-orders-when-tagged/script.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
{% for keyval in fulfillment_order_ids_by_location_and_type %}
{% action "shopify" %}
mutation {
fulfillmentCreateV2(
fulfillmentCreate(
fulfillment: {
lineItemsByFulfillmentOrder: [
{% for fulfillment_order_id in keyval[1] %}
Expand Down
10 changes: 7 additions & 3 deletions docs/auto-invite-customers-after-an-order/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Tags: Email, Invite, Orders, Retention

Automatically prompt customers to activate their customer accounts, after placing an order in your store, by triggering a customizable Shopify-powered email. Useful if your online store unlocks special offers, functionality, or content after making a purchase. Optionally, only send invitations if the customer has ordered a product with a specific tag.
Automatically prompt customers to activate their customer accounts, after placing an order in your store, by triggering a customizable Shopify-powered email. Useful if your online store unlocks special offers, functionality, or content after making a purchase. Optionally, only send invitations if the customer has a certain tag and/or has ordered a product with a specific tag.

* View in the task library: [tasks.mechanic.dev/auto-invite-customers-after-an-order](https://tasks.mechanic.dev/auto-invite-customers-after-an-order)
* Task JSON, for direct import: [task.json](../../tasks/auto-invite-customers-after-an-order.json)
Expand Down Expand Up @@ -33,9 +33,13 @@ shopify/orders/create

## Documentation

Automatically prompt customers to activate their customer accounts, after placing an order in your store, by triggering a customizable Shopify-powered email. Useful if your online store unlocks special offers, functionality, or content after making a purchase. Optionally, only send invitations if the customer has ordered a product with a specific tag.
Automatically prompt customers to activate their customer accounts, after placing an order in your store, by triggering a customizable Shopify-powered email. Useful if your online store unlocks special offers, functionality, or content after making a purchase. Optionally, only send invitations if the customer has a certain tag and/or has ordered a product with a specific tag.

This task works by asking Shopify to send along an invitation email, using the subject and body that you configure here. The email will use your Shopify account's "Customer account invite" email template, available in the "Notifications" area of your Shopify settings.

**Note:** Because this task triggers a Shopify-powered email, and because this email already uses a Shopify template, the actual message body is optional. (If provided, HTML and CSS are not supported.) And, there's no need to add in an invitation link yourself – this will be taken care of by the Shopify email template as well.


This task works by asking Shopify to send along an invitation email, using the subject and body that you configure here. The email will use your Shopify account's "Customer account invite" email template, available in the "Notifications" area of your Shopify settings. Note: Because this task triggers a Shopify-powered email, and because this email already uses a Shopify template, the actual message body is optional. (If provided, HTML and CSS are not supported.) And, there's no need to add in an invitation link yourself – this will be taken care of by the Shopify email template as well.

## Installing this task

Expand Down
Loading