Please tell <?php echo $cart; ?> how to correctly output to common / header.tpl two times: <?php echo $cart; ?> <?php echo $cart; ?> ? Now everything is displayed correctly, but there is a problem with the addition of products. When I add a product in the mobile version, the basket is not updated, AJAX does not work, the added goods show only after a full page reload.

OC: Opencart 2.3.0.2 Subject: Default

 <body class="<?php echo $class; ?>"> <!-- Start PC --> <nav id="top" class="hidden-xs"> <div class="container"> <div class="col-sm-6 col-md-2"> <div class="city hidden-xs"> <!-- <?php echo $currency; ?> --> Город: <span>Санкт-Петербург</span> <!-- <?php echo $language; ?> --> </div> </div> <div class="col-sm-8 col-md-7 hidden-sm"> <div class="link hidden-xs"> <ul> <li><a href="/index.php?route=information/information&information_id=7">Доставка и оплата</a></li> <!-- <li><a href="#">Гарантия и возрат</a></li> <li><a href="#">Контакты</a></li> --> </ul> </div> </div> <div class="col-sm-6 col-xs-12 col-md-3"> <div id="top-links" class="nav pull-right"> <ul class="list-inline"> <li class="hidden-md hidden-sm hidden-lg"><a href="<?php echo $contact; ?>"><i class="fa fa-phone"></i></a> <span class="hidden-xs hidden-sm hidden-md"><?php echo $telephone; ?></span></li> <li class="dropdown"><a href="<?php echo $account; ?>" title="<?php echo $text_account; ?>" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $text_account; ?></span> <span class="caret"></span></a> <ul class="dropdown-menu dropdown-menu-right"> <?php if ($logged) { ?> <li><a href="<?php echo $account; ?>"><?php echo $text_account; ?></a></li> <li><a href="<?php echo $order; ?>"><?php echo $text_order; ?></a></li> <li><a href="<?php echo $transaction; ?>"><?php echo $text_transaction; ?></a></li> <li><a href="<?php echo $download; ?>"><?php echo $text_download; ?></a></li> <li><a href="<?php echo $logout; ?>"><?php echo $text_logout; ?></a></li> <?php } else { ?> <li><a href="<?php echo $register; ?>"><?php echo $text_register; ?></a></li> <li><a href="<?php echo $login; ?>"><?php echo $text_login; ?></a></li> <?php } ?> </ul> </li> </ul> </div> </div> </div> </nav> <header class="hidden-xs"> <div class="sticky"> <div class="container"> <div class="row"> <div class="col-sm-4 col-md-3"> <div id="logo"> <!-- <?php if ($logo) { ?> --> <!-- <img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" class="img-responsive" /> --> <a href="<?php echo $home; ?>" class="logo"> <span>М</span>АГАЗИН <img src="/image/logo-shop.png" alt="" style="margin-top:-10px;"> <p><span>Д</span>оставка еды в СПБ</p> </a> <?php } else { ?> <h3><a href="<?php echo $home; ?>"><?php echo $name; ?></a></h3> <?php } ?> </div> </div> <div class="col-sm-4 col-md-5 hidden-xs hidden-sm"> <?php echo $search; ?> </div> <div class="col-sm-4 col-md-2 hidden-xs"> <ul class="list-phone"> <li><a href="mailto:info@shop.net>"></a> <span class="hidden-xs hidden-sm hidden-md">info@shop.net</span></li> </ul> </div> <div class="col-sm-4 col-md-2 hidden-xs"> <?php echo $cart; ?> </div> </div> </div> </div> </header> <!-- End PC --> <!-- Start Mobile --> <nav id="top" class="hidden-sm hidden-md hidden-lg"> <div class="container"> <div class="row"> <!-- Start Mobile Logotype --> <div class="col-xs-6 hidden-sm hidden-md hidden-lg"> <div id="logo"> <!-- <?php if ($logo) { ?> --> <!-- <img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" class="img-responsive" /> --> <a href="<?php echo $home; ?>" class="logo"> <span>М</span>АГАЗИН <img src="/image/logo-shop.png" alt="" style="margin-top:-10px;"> <p><span>Д</span>оставка еды в СПБ</p> </a> <?php } else { ?> <h3><a href="<?php echo $home; ?>"><?php echo $name; ?></a></h3> <?php } ?> </div> </div> <!-- End Mobile Logotype --> <!-- Start Mobile Account --> <div class="col-xs-6 hidden-sm hidden-md hidden-lg"> <div id="top-links" class="nav pull-right"> <ul class="list-inline"> <li class="dropdown"><a href="<?php echo $account; ?>" title="<?php echo $text_account; ?>" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $text_account; ?></span> <span class="caret"></span></a> <ul class="dropdown-menu dropdown-menu-right"> <?php if ($logged) { ?> <li><a href="<?php echo $account; ?>"><?php echo $text_account; ?></a></li> <li><a href="<?php echo $order; ?>"><?php echo $text_order; ?></a></li> <li><a href="<?php echo $transaction; ?>"><?php echo $text_transaction; ?></a></li> <li><a href="<?php echo $download; ?>"><?php echo $text_download; ?></a></li> <li><a href="<?php echo $logout; ?>"><?php echo $text_logout; ?></a></li> <?php } else { ?> <li><a href="<?php echo $register; ?>"><?php echo $text_register; ?></a></li> <li><a href="<?php echo $login; ?>"><?php echo $text_login; ?></a></li> <?php } ?> </ul> </li> </ul> </div> </div> <!-- End Mobile Account --> </div> </div> </nav> <div class="sticky-mobile"> <div class="container"> <div class="row"> <div class="sticky hidden-sm hidden-md hidden-lg"> <div class="col-xs-12"> <?php echo $cart; ?> </div> <div class="col-xs-12"> <?php if ($categories) { ?> <nav id="menu" class="navbar hidden-md hidden-sm hidden-lg"> <div class="navbar-header"><span id="category" class="visible-xs"><?php echo $text_category; ?></span> <button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"><i class="fa fa-bars"></i></button> </div> <div class="collapse navbar-collapse navbar-ex1-collapse"> <ul class="nav navbar-nav"> <?php foreach ($categories as $category) { ?> <?php if ($category['children']) { ?> <li class="dropdown"><a href="<?php echo $category['href']; ?>" class="dropdown-toggle" data-toggle="dropdown"><?php echo $category['name']; ?></a> <div class="dropdown-menu"> <div class="dropdown-inner"> <?php foreach (array_chunk($category['children'], ceil(count($category['children']) / $category['column'])) as $children) { ?> <ul class="list-unstyled"> <?php foreach ($children as $child) { ?> <li><a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li> <?php } ?> </ul> <?php } ?> </div> <a href="<?php echo $category['href']; ?>" class="see-all"><?php echo $text_all; ?> <?php echo $category['name']; ?></a> </div> </li> <?php } else { ?> <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li> <?php } ?> <?php } ?> </ul> </div> </nav> <?php } ?> </div> </div> </div> </div> </div> <!-- End Mobile --> 

  • Code where? Or should we write a new basket for you? - And
  • @And I'm sorry, I added the code header.tpl in the first message - JWDGA
  • I advise you to read about @media requests. - And
  • @And read with pleasure if you direct me in the right direction where to go. Just the header of the site is very different from the Desktop version, so I tried to do so. I know a terrible decision, but have not yet understood how to implement it differently. - JWDGA

1 answer 1

When updating information about products in the js cart, the function refers to id="cart" (such is the ID in the cart block). This is a unique identifier, but now you have two on the page. Either change the id to class with the replacement also in common.js in the part of the cart.add function (approximately here $('#cart > button').html('... ) or add some variable in the header controller that identifies the browser ( mobile / desktop) and output the recycle header.tpl through the condition of checking this variable.

  • Thank you, I will consider. It turned out that the problem was still in the additional module on opencart (flycart). Disconnected the module - it all worked. - JWDGA