Skip to content

Commit

Permalink
Merge pull request #159 from jamalsoueidan/update-api-version
Browse files Browse the repository at this point in the history
Update .gitignore and .graphqlrc.ts for admin-2024-04 schema, adjust …
  • Loading branch information
jamalsoueidan authored Jun 4, 2024
2 parents a4c0aa8 + 68a532b commit 1977ab2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,5 @@ __azurite_db*__.json
app/lib/api/model
app/lib/api/*.ts
app/lib/zod
admin-2023-10.schema.json
admin-2024-01.schema.json
admin-2024-04.schema.json
admin.types.d.ts
4 changes: 2 additions & 2 deletions .graphqlrc.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ApiType, shopifyApiProject } from "@shopify/api-codegen-preset";

export default {
schema: "https://shopify.dev/admin-graphql-direct-proxy/2024-01",
schema: "https://shopify.dev/admin-graphql-direct-proxy/2024-04",
documents: ["./src/**/*.{ts,tsx}"],
projects: {
default: shopifyApiProject({
apiType: ApiType.Admin,
apiVersion: "2024-01",
apiVersion: "2024-04",
documents: ["./src/**/*.{ts,tsx}"],
outputDir: "./src/types",
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ describe("CustomerProductUpdateOrchestration", () => {
?.variants.nodes[0].id,
price: product.price?.amount,
compareAtPrice: product.compareAtPrice?.amount,
inventoryItem: {
requiresShipping: false,
},
},
],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CustomerProductServiceGet } from "~/functions/customer/services/product/get";
import { LocationTypes } from "~/functions/location";
import { shopifyAdmin } from "~/library/shopify";

export const updatePriceName = "updatePrice";
Expand All @@ -9,10 +10,15 @@ export const updatePrice = async ({
customerId: number;
productId: number;
}) => {
const { variantId, price, compareAtPrice } = await CustomerProductServiceGet({
customerId,
productId,
});
const { variantId, price, compareAtPrice, locations } =
await CustomerProductServiceGet({
customerId,
productId,
});

const isDestination = locations.some(
(l) => l.locationType === LocationTypes.DESTINATION
);

const { data } = await shopifyAdmin().request(PRODUCT_PRICE_UPDATE, {
variables: {
Expand All @@ -22,6 +28,13 @@ export const updatePrice = async ({
id: `gid://shopify/ProductVariant/${variantId}`,
price: price.amount,
compareAtPrice: compareAtPrice.amount,
...(isDestination
? {
inventoryItem: {
requiresShipping: false,
},
}
: {}),
},
],
},
Expand Down

0 comments on commit 1977ab2

Please sign in to comment.