I'm building a Magento 2 webshop with one default-store and 36 "sub-stores". Each of those are Websites (not store views), because the prices differ per store. When a user enters the site he/she needs to go through the store-locator to find the nearest store to order the goods from.
On the default store we:
I'd like to do something like this:
if(storeViewCode=="default") {
// Show store-locator button || redirect to Store locator
}
else {
// Show price && add-to-cart button
}
Can this be done? Is it a good approach? Where do I put the code?
That's not a good approach,
To shop/hide prices you can create 2 themes extending both your main theme. Then apply the no price theme to the "default-store" and the other one to the other stores.
Then on each theme you can overide the templates to change the behaviour as you wish.
You then need to add a security to prevent users from accessing pages you don't wish on the "default-store"(such as cart) you can do this by some custom code + a configuration.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.