Jump to content

select with php store to show or hide content (multistore)


Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...