Hello - I have a member site where members get all my products at a discounted rate over visitors. I have recreated all the products but with reduced pricing and in their own “member” collection. I am using global navigation and exposing elements to direct members or visitors to the proper product collection to then look at and purchase products.
If a member is looking at a product at a price that is only available to them, but then they copy and share the URL and a visitor clicks on it, that visitor can see and purchase the item. This is because the actual product page does not have any way to know if the product is for members only or if the person visiting is a member or not. How can I restrict that visitor from being able to buy that product the navigated to by a direct URL?
I am trying to get the product collection for the current product on the product page, then seeing if the user is logged in, and if they are not logged in, and the collection is for members only, redirecting the visitor to the proper not restricted collection.
Since the product names are the same for the visitor and member pricing, and the URL is appended with a “-1” for all the member products, I though about parsing the URL to see if it ends in “-1” and then redirecting the visitor to the proper URL without the “-1”
As for code I have no idea how do this. All I have is this simple start. When it comes to parsing out strings, comparing to logged in status, or getting product collection data, I am lost.
$w ( ‘#productPage1’ ). getProduct ()
. then (( product ) => {
let productName = product . name ;