简体   繁体   中英

Get current store id in opencart

i try to show different header image in frontend based on store id mean every store has different header image .

the problem is how to echo current store_id in frontend (in header )

so i can proceed with my code something like below :

<?php
if($store_id == '1') {  // 1 is default store
    //echo image here   
}
else {  //if not default show different image
    //echo image here   
}
?>

Opencart version : 1.4.9.6

The current store_id of Your store is in $this->config->get('config_store_id') .

That means if You need it in the template, edit header controller ( catalog/controller/common/header.php ) - some in the index() function add this code (id it is not present already):

$this->data['store_id'] = $this->config->get('config_store_id');

Then in Your header.tpl of Your template ( catalog/view/theme/<YOUR_THEME>/template/common/header.tpl ) use it this way:

<?php if ($tore_id == 0) { ?>
<div>Main store</div>
<?php } else { ?>
<div>Subdomain store</div>
<?php } ?>

or this way:

<div class="container-<?php echo $store_id; ?>"> ... </div>

It is upon You.

EDIT: Also consider moving on with newer OpenCart (latest is 1.5.4.1 as of 15 th December, 2012) - it is worth the redesign and the functions and gadgets it has.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM