I try to create an app script where i need to deny the finish process of an order under defined circumstances. Therefore i need access to the date of birth from a customer and a given variable in my app config. How can i get them?
The line-items for example i get like this:
{# @var services \Shopware\Core\Framework\Script\ServiceStubs #}
{% set items = services.cart.items %}
You can get the customer from the SalesChannelContext
, given they're logged in.
{% if hook.salesChannelContext.customer %}
{% set birthday = hook.salesChannelContext.customer.birthday %}
{% endif %}
Regarding your comment, the cart manipulation hook is probably what you want to use. For instance you could use the script to add errors and notifications to the cart given a condition based on the birthday.