Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ecommerce as easy as an UI component

Ecommerce as easy as an UI component

Frontend development is about connecting with your audience and creating a memorable experience for them. And with eCommerce, it's even more important to make that connection. However, don't let the thought of a steep learning curve scare you off from eCommerce projects - You don't need to be an expert to start building with Vue.js and Shopware Frontends. Join us as we show you how to add eCommerce features to a small application and create a fun and engaging experience for your customers. Let's craft an eCommerce story together!

Ramona Schwering

February 10, 2023
Tweet

More Decks by Ramona Schwering

Other Decks in Technology

Transcript

  1. # Install dependencies pnpm i # Run project base pnpm

    run dev # Clone repo npx tiged shopware/frontends/templates/vue-blank vue-blank && cd vue-blank
  2. # Install dependencies pnpm i # Run project base pnpm

    run dev # Clone repo npx tiged shopware/frontends/templates/vue-blank vue-blank && cd vue-blank
  3. # Install dependencies pnpm i # Run project base pnpm

    run dev # Clone repo npx tiged shopware/frontends/templates/vue-blank vue-blank && cd vue-blank
  4. <script setup lang='ts'> const { search } = useProductSearch(); const

    { product } = await search('a-product-id'); </script> <template> <!— Template goes here… —> </template>
  5. <script setup lang='ts'> const { search } = useProductSearch(); const

    { product } = await search('a-product-id'); </script> <template> <!— Template goes here… —> </template>
  6. <script setup lang='ts'> const { search } = useProductSearch(); const

    { product } = await search('a-product-id'); </script> <template> <img :src='product.cover.media.url' :alt='product.cover.media.title' /> <h2>{{ product.name }}</h2> </template>
  7. <script setup lang='ts'> const { search } = useProductSearch(); const

    { product } = await search('a-product-id'); </script> <template> <img :src='product.cover.media.url' :alt='product.cover.media.title' /> <h2>{{ product.name }}</h2> </template>
  8. <script setup lang='ts'> … const { getFormattedPrice } = usePrice();

    const { unitPrice } = useProductPrice(ref(product)); </script> <template> <img :src='product.cover.media.url' :alt='product.cover.media.title' /> <h2>{{ product.name }}</h2> <span>{{ getFormattedPrice(unitPrice) }}</span> </template>
  9. <script setup lang='ts'> … const { getFormattedPrice } = usePrice();

    const { unitPrice } = useProductPrice(ref(product)); </script> <template> <img :src='product.cover.media.url' :alt='product.cover.media.title' /> <h2>{{ product.name }}</h2> <span>{{ getFormattedPrice(unitPrice) }}</span> </template>
  10. <script setup lang='ts'> … const { getFormattedPrice } = usePrice();

    const { unitPrice } = useProductPrice(ref(product)); </script> <template> <img :src='product.cover.media.url' :alt='product.cover.media.title' /> <h2>{{ product.name }}</h2> <span>{{ getFormattedPrice(unitPrice) }}</span> </template>
  11. <script setup lang='ts'> … const { addToCart } = useAddToCart(ref(product));

    </script> <template> <!— This is the Product card from before… —> <button v-on:click='addToCart()'>
 Add to cart
 </button> </template>
  12. <script setup lang='ts'> … const { addToCart } = useAddToCart(ref(product));

    </script> <template> <!— This is the Product card from before… —> <button v-on:click='addToCart()'>
 Add to cart
 </button> </template>
  13. <script setup> const { cartItems, refreshCart, totalPrice, shippingTotal,
 subtotal, removeItem

    } = useCart(); onMounted(() => { refreshCart(); }); </script> <template> <!— Template goes here… —> </template>
  14. <script setup> const { cartItems, refreshCart, totalPrice, shippingTotal,
 subtotal, removeItem

    } = useCart(); onMounted(() => { refreshCart(); }); </script> <template> <!— Template goes here… —> </template>
  15. <script setup> const { cartItems, refreshCart, totalPrice, shippingTotal,
 subtotal, removeItem

    } = useCart(); onMounted(() => { refreshCart(); }); </script> <template> <!— Template goes here… —> </template>
  16. <template> … <!-- Cart items --> <div v-on:click='removeItem(item)' 
 v-for='item

    in cartItems'> <h2>{{ item.quantity }} x {{ item.label }}</h2> <p>{{ getFormattedPrice(item.price.unitPrice) }}</p> </div> <div> <!-- Some more cart data and sums can go here --> <p>Total {{ getFormattedPrice(totalPrice) }}</p> </div> … </template>
  17. <template> … <!-- Cart items --> <div v-on:click='removeItem(item)' 
 v-for='item

    in cartItems'> <h2>{{ item.quantity }} x {{ item.label }}</h2> <p>{{ getFormattedPrice(item.price.unitPrice) }}</p> </div> <div> <!-- Some more cart data and sums can go here --> <p>Total {{ getFormattedPrice(totalPrice) }}</p> </div> … </template>
  18. <template> … <!-- Cart items --> <div v-on:click='removeItem(item)' 
 v-for='item

    in cartItems'> <h2>{{ item.quantity }} x {{ item.label }}</h2> <p>{{ getFormattedPrice(item.price.unitPrice) }}</p> </div> <div> <!-- Some more cart data and sums can go here --> <p>Total {{ getFormattedPrice(totalPrice) }}</p> </div> … </template>