Don't work button add to cart
« on: October 07, 2018, 03:21:26 PM »
Hello, I can't add promote to the item, don't work button add to cart. Help pls.
It's error:
Quote
user.js:202 Uncaught ReferenceError: ospButtonCartURL is not defined
    at HTMLAnchorElement.<anonymous> (user.js:202)
    at HTMLBodyElement.dispatch (jquery.min.js:2)
    at HTMLBodyElement.h (jquery.min.js:2)
(anonymous) @ user.js:202
dispatch @ jquery.min.js:2
h @ jquery.min.js:2

it's my code in user.js
Quote
// GENERATE ADD TO CART URL ON ITEMS
  $('body').on('click', 'a.osp-item-to-cart', function(e){
    e.preventDefault();
    var enableAjaxLoad = 1;    // set to 0 in case of problems with adding products to cart

    var item = $(this).attr('data-item');
    var checks = $('.osp-options[data-item="' + item + '"]').find('input:checkbox:checked');
    var i = 0;
    var url = $(this).attr('href');

    checks.each(function(){
      if(i > 0 && $(this).attr('name') != '601_2') { url += '|'; }
      url += $(this).attr('code');
      i = i + 1;
    });


    if(enableAjaxLoad == 1) {
      var button = $(this);
      var buttonText = $(this).html();

      if(button.hasClass('osp-in-cart')) {
        window.location.href = ospButtonCartURL;
        return false;
      }

      if(i > 0) {
        button.addClass('osp-in-cart').attr('href', ospButtonCartURL).html('<i class="fa fa-check-circle"></i> ' + ospButtonInCart);
      } else {
        button.addClass('osp-notin-cart').html('<i class="fa fa-exclamation-circle osp-cart-problems"></i> ' + ospButtonNotInCart);

        setTimeout(function(){
          button.removeClass('osp-notin-cart').html(buttonText);
        }, 1500);

        return false;
      }

      // Now submit cart content via ajax, no need to reload page
      $.ajax({
        url: url,
        success: function(result){
          console.log(result);
        }
      });

      return false;

    } else {
      if(i == 0) {
        return false;
      }

      window.location.href = url;
    }
  });
« Last Edit: October 07, 2018, 03:37:13 PM by Aleksey Averkin »

*

MB Themes

Re: Don't work button add to cart
« Reply #1 on: October 07, 2018, 05:45:06 PM »
Please test on bender theme to test functionality of plugin. Your theme probably in custom.php and user-custom.php does not include footer.php or footer.php does not run hook 'footer'
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Don't work button add to cart
« Reply #2 on: October 07, 2018, 07:32:39 PM »
Please test on bender theme to test functionality of plugin. Your theme probably in custom.php and user-custom.php does not include footer.php or footer.php does not run hook 'footer'

Yes, Thanks, I added in the footer.php
<?php osc_run_hook ('footer');?>
but how to remove a link to your website, that opens hook? :D:D:D:D ;D

*

MB Themes

Re: Don't work button add to cart
« Reply #3 on: October 08, 2018, 08:09:33 AM »
What link?
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots