diff --git a/packages/nx-shopify/src/generators/theme/files/src/theme/templates/cart/cart.liquid.template b/packages/nx-shopify/src/generators/theme/files/src/theme/templates/cart/cart.liquid.template new file mode 100644 index 0000000..e608e2f --- /dev/null +++ b/packages/nx-shopify/src/generators/theme/files/src/theme/templates/cart/cart.liquid.template @@ -0,0 +1,63 @@ +{% if cart.item_count > 0 %} +

My Cart

+
+ + + + + + + + + + + {% for item in cart.items %} + + + + + + + + {% endfor %} + +
ProductPriceQuantityTotal Price
+ {% if item.image != blank %} + + {{ item | img_url: '240x240' | img_tag: item.title }} + + {% endif %} + + {{ item.product.title }} + {% unless item.product.has_only_default_variant %} +

{{ item.variant.title }}

+ {% endunless %} + + Remove + +
+ {% if item.original_line_price != item.line_price %} + {{ item.price | money }} + {{ item.original_price | money }} + {% else %} + {{ item.price | money }} + {% endif %} + + + + {{ item.line_price | money }} +
+ +

Subtotal

+

{{ cart.total_price | money }}

+ + + +
+{% else %} +

My Cart

+{% endif %} diff --git a/packages/nx-shopify/src/generators/theme/files/src/theme/templates/cart/cart.template.scss.template b/packages/nx-shopify/src/generators/theme/files/src/theme/templates/cart/cart.template.scss.template new file mode 100644 index 0000000..e69de29 diff --git a/packages/nx-shopify/src/generators/theme/files/src/theme/templates/cart/cart.template.spec.ts.template b/packages/nx-shopify/src/generators/theme/files/src/theme/templates/cart/cart.template.spec.ts.template new file mode 100644 index 0000000..8d5fd68 --- /dev/null +++ b/packages/nx-shopify/src/generators/theme/files/src/theme/templates/cart/cart.template.spec.ts.template @@ -0,0 +1,19 @@ +import { CartTemplate } from './cart.template'; + +describe('CartTemplate', () => { + const mockThemeContext = { themeName: 'TestName' }; + + let cartTemplate: CartTemplate; + + beforeEach(() => { + cartTemplate = new CartTemplate(mockThemeContext); + }); + + it('should initiate successfully', () => { + expect(cartTemplate).toBeTruthy(); + }); + + it('should not mutate the context', () => { + expect(cartTemplate.context).toMatchObject(mockThemeContext); + }); +}); diff --git a/packages/nx-shopify/src/generators/theme/files/src/theme/templates/cart/cart.template.ts.template b/packages/nx-shopify/src/generators/theme/files/src/theme/templates/cart/cart.template.ts.template new file mode 100644 index 0000000..a31dc37 --- /dev/null +++ b/packages/nx-shopify/src/generators/theme/files/src/theme/templates/cart/cart.template.ts.template @@ -0,0 +1,17 @@ +import { + ThemeModule, + ThemeContext, + ThemeOnReady, +} from '<%= importPath %>/core'; + +import './cart.template.scss'; + +export class CartTemplate extends ThemeModule implements ThemeOnReady { + constructor(context: ThemeContext) { + super(context); + } + + onReady() { + console.log('Cart Template: onReady() called'); + } +} diff --git a/packages/nx-shopify/src/generators/theme/files/src/theme/templates/theme-templates.ts.template b/packages/nx-shopify/src/generators/theme/files/src/theme/templates/theme-templates.ts.template index b12833b..f7fa719 100644 --- a/packages/nx-shopify/src/generators/theme/files/src/theme/templates/theme-templates.ts.template +++ b/packages/nx-shopify/src/generators/theme/files/src/theme/templates/theme-templates.ts.template @@ -3,6 +3,10 @@ export const themeTemplates = { article: () => import('./article/article.template').then((m) => m.ArticleTemplate), blog: () => import('./blog/blog.template').then((m) => m.BlogTemplate), + cart: () => + import('./cart/cart.template').then( + (m) => m.CartTemplate + ), collection: () => import('./collection/collection.template').then( (m) => m.CollectionTemplate