Skip to content

Commit

Permalink
add weight and sku to page and create-shopify-product
Browse files Browse the repository at this point in the history
  • Loading branch information
dupreesi committed Jul 30, 2024
1 parent ace122e commit d947cd4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion web/connector/mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const importedShopifyProductsFromDFC = [
title: 'Retail pack, 300g',
price: 2.49,
weight: 0,
weight_unit: 'kg',
weightUnit: 'kg',
inventoryQuantity: 55,
sku: undefined,
taxable: true,
Expand Down
7 changes: 2 additions & 5 deletions web/connector/productUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,12 @@ async function getSingleVariantSuppliedProduct(suppliedProduct) {
title: productName,
price: priceValue,
weight: quantityValue,
weight_unit: quantityUnitsObj[quantityUnit],
weightUnit: quantityUnitsObj[quantityUnit],
inventoryQuantity: isContinueSelling ? 0 : stockLimitation,
sku,
taxable: hasVat,
tracked: true,
inventoryPolicy: isContinueSelling ? 'continue' : 'deny',
// TODO check if these are needed and make these dynamic
fulfillmentService: 'manual',
inventoryManagement: 'shopify'
inventoryPolicy: isContinueSelling ? 'continue' : 'deny'
};

if (images.length) {
Expand Down
13 changes: 13 additions & 0 deletions web/frontend/components/VariantCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,25 @@ function VariantCard({ variant, index }) {
{variant.inventoryPolicy}
</p>

{/* add sku */}
{variant.sku && (
<p>
<strong>sku:</strong>
{variant.sku}
</p>
)}
{variant?.inventoryPolicy?.toUpperCase() !== 'CONTINUE' && (
<p>
<strong>inventory Quantity:</strong>
{variant.inventoryQuantity}
</p>
)}

<p>
<strong>weight:</strong>
{variant.weight}
{variant.weightUnit}
</p>
</div>
);
}
Expand Down
16 changes: 15 additions & 1 deletion web/modules/products/controllers/create-shopify-product.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import {
executeGraphQLQuery
} from '../../../utils/index.js';

const shopifyWeightUnits = {
g: 'GRAMS',
kg: 'KILOGRAMS',
oz: 'OUNCES',
lb: 'POUNDS'
};

const GET_LOCATIONS_QUERY = `
query GetLocations {
locations(first: 1) {
Expand Down Expand Up @@ -101,7 +108,14 @@ const createShopifyProductVariant = async ({
price: variantsMappingDataPrice,
inventoryPolicy: wholesaleProduct.inventoryPolicy.toUpperCase(),
inventoryItem: {
tracked: wholesaleProduct.tracked
tracked: wholesaleProduct.tracked,
sku: wholesaleProduct.sku,
measurement: {
weight: {
value: retailProduct.weight,
unit: shopifyWeightUnits[retailProduct.weightUnit]
}
}
},
inventoryQuantities: {
availableQuantity:
Expand Down

0 comments on commit d947cd4

Please sign in to comment.