cart code- handle

mail@pastecode.io avatar
unknown
plain_text
a month ago
884 B
3
Indexable
Never
if (lineItem.variant.product.handle == null) {

          const masterProduct = await dataSource

            .getRepository(Product)

            .createQueryBuilder('prod')

            .select(['prod.handle as handle'])

            .where('prod.id = :master_product_id', { master_product_id: lineItem.variant.product.master_product_id })

            .getRawOne();

          lineItem.variant.product.handle = masterProduct.handle;

          let array = {

            handle: masterProduct.handle,

          };

          lineItem.metadata = { ...lineItem.metadata, ...lineItem.variant.metadata, ...array };

        } else {

          let array = {

            handle: lineItem.variant.product.handle,

          };

          lineItem.metadata = {

            ...lineItem.metadata,

            ...lineItem.variant.metadata,

            ...array,

          };

        }
Leave a Comment