Link Anchors in OpenCart 2

In OpenCart 2.3, if you want to put a regular anchor link in the text of the article, then you will be in for a big bummer - when you click on such a link, you will be redirected to the main page of the site. Adding a slash to the link doesn't help either.

<a href="/#id">link</a>

Cause in line

<base href="<?php echo $base; ?>" />

header.tpl file. However, you do not need to delete it thoughtlessly. In this case, all the paths of scripts, styles will go astray, and in general the site will look very dull))

<script type="text/javascript">
   $('.delivery').click(function(){
      var target = $(this).attr('href');
    $('html, body').animate({scrollTop: $(target).offset().top}, 800);
      return false;
   });
</script>

For anchor links, you need to add a class, in the example above it is "delivery".

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
The comment language code.