acpkor Posted March 17, 2022 Share Posted March 17, 2022 Hello, I am working with 2 stores in prestshop with the "multi-store" option. I want to hide content in the order process so that in one of the stores it does not show something. I have two stores one with id_shop 1 and one with id_shop 2 Inside a .tpl file I introduce this line: {if $shop_id = 1} <p>hola</p> <p>pepe</p> {else} <p>pepe</p> {/if} It doesn't work for me. It always shows me all the content in both store 1 and 2 <p>hola</p> <p>pepe</p> What am I doing wrong? Link to comment Share on other sites More sharing options...
Luis C Posted March 17, 2022 Share Posted March 17, 2022 (edited) Hi, if that's your exact code in your smarty template AND your absolutely sure that variable is working as intended, then the issue is you're using a single comparator, making your statement always return true. {if $shop_id == 1} Edited March 17, 2022 by Luis C typo (see edit history) Link to comment Share on other sites More sharing options...
acpkor Posted March 17, 2022 Author Share Posted March 17, 2022 I don't really understand what you're saying... what should I do? What would be the correct code to discriminate between the 2 stores? Link to comment Share on other sites More sharing options...
Luis C Posted March 17, 2022 Share Posted March 17, 2022 4 minutes ago, acpkor said: I don't really understand what you're saying... what should I do? What would be the correct code to discriminate between the 2 stores? Your syntax is incorrect. Using one operator (=) in an if statement, makes it always return true, so it alway process the code inside. Besides, there is no global variable that stores the shop ID, so if you're not writing a module and just want to edit template files you need to change the way you determine what shop is currently being accessed. Depending on the version of your prestashop installation the variable name is different. For Prestashop 1.7, you can use these to differentiate between shops in a multi-store environment: {$shop.name} - If your stores have different names, you can use this one to detect what store is being accessed and display content consequently {$shop.base_url} - the same, if your stores have different URLs (they should) this one will also allow you to make a conditional statement to show content based on store. At any rate, please remember to use a double operator (==) since it's the one that "compares". Link to comment Share on other sites More sharing options...
acpkor Posted March 17, 2022 Author Share Posted March 17, 2022 so I can't. my version is 1.7 A store is called "BEC" Other "TCO" the intrusion would be like this? {if $shop.name == BEC} I have tried everything: {if $id.shop == 1} {if $id_shop_url == 1} but nothing. Either he takes out all the content or he cuts it in both stores I am trying to do this: {if $id_shop_url == 1} <div class="col-md-6"> <div class="card noshadow"> <div class="card-block"> <h4 class="h5 black addresshead">{l s='Your Delivery Address' d='Shop.Theme.Checkout'}</h4> {$customer.addresses[$cart.id_address_delivery]['formatted'] nofilter} </div> </div> </div> <div class="col-md-6"> <div class="card noshadow"> <div class="card-block"> <h4 class="h5 black addresshead">{l s='Your Invoice Address' d='Shop.Theme.Checkout'}</h4> {$customer.addresses[$cart.id_address_invoice]['formatted'] nofilter} </div> </div> </div> {else} <div class="col-md-6"> <div class="card noshadow"> <div class="card-block"> <h4 class="h5 black addresshead">{l s='Your Invoice Address' d='Shop.Theme.Checkout'}</h4> {$customer.addresses[$cart.id_address_invoice]['formatted'] nofilter} </div> </div> </div> {/if} It is so that in the summary of the purchase, I get the order address and the invoice address in a store. And in the other store I only got the billing address. I have to hide the order address. Link to comment Share on other sites More sharing options...
acpkor Posted March 17, 2022 Author Share Posted March 17, 2022 (edited) I have also tried with: {if $shop.name == BEC} {if $name == BEC} and some other things... but nothing... Edited March 17, 2022 by acpkor (see edit history) Link to comment Share on other sites More sharing options...
ventura Posted March 18, 2022 Share Posted March 18, 2022 {assign var=shop value=Shop::getContextShopID()} {if $shop == 3} Link to comment Share on other sites More sharing options...
acpkor Posted March 18, 2022 Author Share Posted March 18, 2022 Thanks a lot! works correctly. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now