This question has been flagged
829 Views

Hello, I'm trying to hide the prices of logged out users on the product page.


These prices are inside a "form" element which when submitted, updates the cast of the user. My initial thinking was to remove the entire form element using xpath.


I started with creating a new view, which is an extension of "Product" view.


With the following code, I managed to replace the form, when the user is not logged it, but it currently breaks the code when the user is logged in.


My extension code:

 









Please login to view prices








I want to conditionally apply the xpath only when the user is logged out, but it doesn't seem like there's a way to currently do it?

Avatar
Discard
Author

I keep trying to edit the code, but it doesn't update. here's the actual code I used.

<data>
<xpath expr="//form" position="replace">
<t t-set="isNotLoggedIn" t-value="request.env.user.id == request.env.ref('base.public_user').id"/>

<t t-if="isNotLoggedIn">
<p>Please login to view prices</p>
</t>
</xpath>
</data>