Query value from another blueprint

Hi, I’m writing a cart plugin for Kirby.
I created a page with some toggles to set some plugin settings, for example a toggle to set if there is stock count or not.
On the product page I’d like to display a field regarding the stock availability if the stock option is true. As the “when” is available only in the same page, how can I check if the toggle on the main page is set to true? Thanks!

The only way that I know of is via a little trick, a hidden field in the same page with the same default value as the toggle field that is updated via a hook when the value of the toggle field in the parent page is changed. Then you can use when depending on the value of the hidden field.

Sounds great! Do you have an example of how the hidden field query the other value? I tried this but is not working…
if_stock:
type: hidden
querty: “{{site.find(‘cart’).stock}}”

No, you can’t use a query but have to use a hook to fill the value of this field. Maybe it’s possible to use a query for the default value, but I’m not sure if query language can be used with defaults or not. And defaults only work at page creation, anyway. So you can try if this works for the default, but you will still need a hook to update the field when the value in the parent page is changed.

if_stock:
  type: hidden
  default: “{{site.find('cart').stock}}”

If this doesn’t work, then you need two hooks: one at page creation and the second when the parent is updated.

Right! I think I need the hooks so. It’s something I never did yet :slight_smile:

Yay, a chance to learn something new!

:partying_face: