Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Открытие товаров в модальном окне


OpenArt
 Share

Recommended Posts

Сделал открытие товаров в модальном окне на OpenCartt 2.3 таким способом.

В common.js добавил такой код:

$(document).delegate('a.clickmodal', 'click', function(e) {
    e.preventDefault();
 
    $('#modal-inf').remove();
 
    var element = this;
 
    $.ajax({
        url: $(element).attr('href'),
        type: 'get',
        dataType: 'html',
        success: function(data) {
            html  = '<div id="modal-inf" class="modal">';
            html += '  <div class="modal-dialog">';
            html += '    <div class="modal-content">';
            html += '      <div class="modal-header">';
            html += '        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>';
            html += '        <h4 class="modal-title">' + $(element).text() + '</h4>';
            html += '      </div>';
            html += '      <div class="modal-body">' + $('#content', data).html() + '</div>';
            html += '    </div';
            html += '  </div>';
            html += '</div>';
 
            $('body').append(html);
 
            $('#modal-inf').modal('show');
        }
    });
});

 

К ссылкам в модулях рекомендуемые, в категориях и т.д. добавил class="clickmodal"

Товар открывается, но кнопка купить не работает, подскажите в чём может быть проблема?

Link to comment
Share on other sites


18.05.2022 в 12:27, esculapra сказал:

а где в модалке кнопка купить?

Я в шаблон category.tpl, featured.tpl, latest.tpl и т.д. к ссылкам на страницу товара добавил class="clickmodal" и он открывает товар в модальном окне 

<div class="image"><a href="<?php echo $product['href']; ?>" class="clickmodal"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-responsive" /></a></div>

<h4><a href="<?php echo $product['href']; ?>" class="clickmodal"><?php echo $product['name']; ?></a></h4>

 

Link to comment
Share on other sites


18.05.2022 в 11:58, OpenArt сказал:
18.05.2022 в 08:27, esculapra сказал:

 

Я в шаблон category.tpl, featured.tpl, latest.tpl и т.д. к ссылкам на страницу товара добавил class="clickmodal" и он открывает товар в модальном окне 

Значит не рабтает функция купить. ЕЕ еужно предусмотреть в указанніх шаблонах.

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
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.