Alpine component init and handling login
As we want to allow only logged in customers to download our products PDF, we need to request login and make sure that the user is redirected back to our “Products downloads” page.
Frontend code update
Section titled “Frontend code update”- Create a new
ProductsDownloadsAlpineJS component. - Declare this component in
brush/src/components/index.ts. - Update the Shopify page template and introduce a new
products-downloads.liquidsection. - Attach the Alpine component in the section with
x-data="ProductsDownloads()" - Use liquid
customerobject to check if customer is logged in. - If not, display a button that triggers the
loginmethod from the component. - This
loginmethod uses theBrush.Referrals.makeLoginRedirectUrl()helper to handle redirection to login and landing back on the current page. - Also make sure to update JSON translation files.