Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Suggestion on how to build order creating?

default discord avatar
icedcacaolast year
6

Hi! Currently i'm building a website that's need a virtual field that is visible and not editable to user (There is a way to do that on payload website)


However, it's a calculated field that's need to fetch the data from another collection. Good example is product item inside order.


Is there a way to display the subtotal in each array box and the grand total outside the block while the admin is creating order? Thank you

  • default discord avatar
    paulpopuslast year

    You should probably use a custom component here

    https://payloadcms.com/docs/beta/admin/fields#the-field-component

    See this slug field for inspiration (v3)

    https://github.com/payloadcms/payload/blob/beta/templates/website/src/fields/slug/SlugComponent.tsx

    You can essentially listen in on data from other fields, do whatever you need and display it as needed

  • default discord avatar
    icedcacaolast year

    Thank you so much! I will try it tomorrow.



    if I want to change the component dynamically I would have to use react client instead of server? Right since the field component will be render in the server not dynamically?

  • default discord avatar
    paulpopuslast year

    yep



    you can also write a server component that returns a client if you need to pass down some logic to it



    you cant use the local API in the client server so there you need to use the rest api

  • default discord avatar
    icedcacaolast year

    as in your slug field it is using client component right? In my case where you need to listen to data input as you choose (relationship) is it much better to use client component or server component?

  • default discord avatar
    paulpopuslast year

    client



    it will be able to get it from the state

  • default discord avatar
    icedcacaolast year

    Thank you so much!

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.