Criação de Itens no AddOn Loja

2 participantes

Ver o tópico anterior Ver o tópico seguinte Ir para baixo

Tópico resolvido Criação de Itens no AddOn Loja

Mensagem por Mirotic 10.01.21 5:02

Detalhes da questão


Endereço do fórum: https://jogodasnacoes.forumeiros.com/
Versão do fórum: phpBB3

Descrição


Oi gente, estou utilizando um código disponibilizado pelo Daemon aqui na comunidade. Porém eu não consigo criar novos itens. Alguém que entenda pode me mostrar o que houve de errado?

Segue o código abaixo.

Código:
<script type="text/javascript">
              $(function() {
              var produtos = {
        

            'Gold Star 5': {
                    icone: 'https://i.imgur.com/taaL40o.png',
                    preco: '200',
                    status: 'A Venda',
                    descricao: 'Stars WHOA',
                    slot: 'new'
                },
            'Gold Star 0': {
                    icone: 'https://i.imgur.com/taaL40o.png',
                    preco: '200',
                    status: 'A Venda',
                    descricao: 'Stars WHOA',
                    slot: 'new'
                },
            'Gold Star 2': {
                    icone: 'https://i.imgur.com/taaL40o.png',
                    preco: '200',
                    status: 'A Venda',
                    descricao: 'Stars WHOA',
                    slot: 'new'
                },
            'Gold Star 3': {
                    icone: 'https://i.imgur.com/taaL40o.png',
                    preco: '200',
                    status: 'A Venda',
                    descricao: 'Stars WHOA',
                    slot: 'new'
                },
        
                'Helmet': {
                    icone: 'http://png.findicons.com/files/icons/2169/picnic/70/helmet2.png',
                    preco: '250',
                    status: 'A Venda',
                    descricao: 'Capacete de batalha'
                },
        
                'Charmander': {
                    icone: 'https://i.servimg.com/u/f72/18/07/42/17/shop_i33.png',
                    preco: '250',
                    status: 'A Venda',
                    descricao: 'Pokemón tipo fogo'
                },
        
                'Charmander': {
                    icone: 'https://i.servimg.com/u/f72/18/07/42/17/shop_i33.png',
                    preco: '250',
                    status: 'A Venda',
                    descricao: 'Pokemón tipo fogo'
        }
              };
        
        
              var content = $('.content .itens');
                  $.each(produtos, function (key, value) {
                      content.append(
                  '<tr class="item">' +
                  '  <td class="icone" style="width: 0px; background: transparent;"><img src="' + value.icone + '" /></td>' +
                  '  <td style="float: right; display: block; position: absolute; margin-left: 140px; margin-top: -133px; font-family: Raleway; background: transparent; border: none; text-align: left;"><strong class="nome">' + key + '</strong><br /><br />' + value.descricao + '</td>' +
                  '  <td style="position: absolute; margin-top: -67px; margin-left: 140px; height: 35px; background: transparent; border: none;">' +
                  '  <ul>' +
                  '  <li class="preco" data-myprice="' + value.preco + '"> ' + value.preco + ' créditos</li>' +
                  '  <br />' +
                  '  <li><input type="button" class="cartadd" onclick="addToCart(this)" value="Buy" /></li>' +
             '  </ul>' +
                  '  </td>' +
                  '</tr>'
                  );
              });
              $.ajax({
                url: '/u' + _userdata.user_id,
                type: 'GET',
                success: function(responseHtml)
                {
                var myPoints = $('#field_id-13 dd', responseHtml).text();
                $('.myPoints').html('Meu saldo de pontos: <span class="totalPoints">' + myPoints + '</span>');
                },
                error: function(err)
                {
                  console.log("AJAX error in request (Store points)");
                }
              });
          });
          var $total = 0;
          function addToCart(item) {
            var getItem = $(item).parents('.item').find('.nome').text();
            var getPrice = parseInt($(item).parents('.item').find('.preco').attr('data-myprice'));
            $total += getPrice;
            $('.total').html('Valor total: <span class="totalVal">' + $total + '</span> pontos');
            $('.cart').append('<span class="item-cart" onclick="removeFromCart(this)" data-myprice="' + getPrice + '">' + getItem + '</span>');
          }
          function removeFromCart(item) {
            var getPrice = parseInt($(item).attr('data-myprice'));
            $total -= getPrice;
            $('.total').html('Valor total: <span class="totalVal">' + $total + '</span> pontos');
            $(item).remove();
          }
          function resetItems() {
            $('.cart').empty();
            $total = 0;
            $('.total').empty();
          }
          function buyItems() {
            if(!$('.cart').is(':empty')) {
              var valPoints = parseInt($('.totalPoints').text());
              var valTotal = parseInt($('.totalVal').text());
              if(valPoints >= valTotal) {
              var texto = '';
              var total = 0;
              $('.item-cart').each(function() {
                var item = $(this).text();
                var preco = parseInt($(this).attr('data-myprice'));
                texto += '[b]' + item.charAt(0).toUpperCase() + item.slice(1)
                //add line break at the end
                + ':[/b] ' + preco + " pontos\n";
                total += preco;
              });
              texto += '\n\n[b]Valor total:[/b] ' + total + ' pontos';
              $.post('/privmsg', {
                    'mode': 'post',
                    'post': '1',
                    'folder': 'inbox',
                    'usergroup': '1',
                    'subject': 'Pedido da loja',
                    'message': texto
              }).done(function() {
                alert("Seu pedido foi enviado! Aguarde até que um administrador adicione seus ítens");
                resetItems();
              });
              } else {
                alert("Você não tem pontos suficiente para efetuar a compra");
              }
            } else {
              alert("O carrinho está vazio");
            }
          }
        </script>
        <style type="text/css">
        table.content {
          background: #fafafa;
          border: 1px solid #eaeaea;
          border-collapse: separate;
          empty-cells: show;
          table-layout: fixed;
          width: 100%;
        }
        .itens .nome {font-size: 14px;}
        .itens .icone {
        text-align: center;
        }
        .itens .icone img {
          height: 50px;
          width: 50px;
        }
        .item-cart {
          background: orange url(https://cdn0.iconfinder.com/data/icons/very-basic-android-l-lollipop-icon-pack/24/close-16.png) no-repeat 5px;
          margin: 3px 4px;
          cursor: pointer;
          display: inline-block;
          font-weight: bold;
          padding: 5px;
          padding-left: 25px;
          color: white;
          border-radius: 3px;
        }
 
.cartadd {
   background: #75bf75;
   margin-left: 80px;
   width: 50px;
   height: 34px;
   border: none;
   margin-top: -1px;
   color: white;
   text-transform: uppercase;
   font-size: 10px;
}
          
          table.content {
   background: #fafafa;
   border: 1px solid #eaeaea;
   border-collapse: separate;
   empty-cells: show;
   table-layout: fixed;
   width: 1017px;
   text-align: center;
   margin-top: 0px;
   padding: 5px;
   margin-top: 10px;
}
          
        table.content tr td {padding: 10px;background: #f0f0f0;border-bottom: 1px solid #e0e0e0;}
        .itens ul li {list-style-type: none;}
        .daemon {
          background: #333;
          text-align: center;
          padding: 10px;
        }
        #cart {
          background: #f0f0f0;
          border: 1px solid #e0e0e0;
          margin-top: 5px;
          padding: 5px;
        }
        .cart {
          background: white url("https://cdn1.iconfinder.com/data/icons/flat-artistic-shopping-icons/32/shopping-32.png") no-repeat 10px center;
          min-height: 50px;
          padding-left: 55px;
          border: 1px solid #ddd;
        }
          
tr.item {
   background: white;
   height: 142px;
   width: 327px !important;
   display: inline-block;
   margin-right: 10px;
   border: 1px solid #0000000d;
   margin: 2px;
}

tr.item td {
   display: block;
   width: 168px;
   text-align: center;
   margin-right: ;
}
          
          td.icone img {
   width: 100px !important;
   height: 100px !important;
   border: 1px solid #04040405;
   box-shadow: 0px 0px 8px #0000002e;
   padding: 10px;
   outline: 1px solid #f7f7f7;
   outline-offset: -1px;
}
          
          .preco {
   font-size: 12px;
   font-family: Raleway;
   position: absolute;
   margin-left: -31px;
   background: #e0e1e0;
   padding: 10px 20px;
   display: block;
   margin-top: 13px;
   color: #0009;
   font-weight: 600;
}
          
          .cartadd::before {
   content: "\f291";
   color: #db3333;
   font-family: FontAwesome;
   display: block;
   position: absolute;
   margin-left: 110px;
   z-index: 70;
   font-size: 30px;
}
          
        .total, .myPoints {font-size: 13px;display: block;margin-top: 5px;font-family: arial;display: block;font-style: italic;font-weight: bold;}
        </style>
        <div class="daemon">
          <span style="color: white;font-size: 28px;font-weight: bold;">Loja</span>
        </div>
        <table class="content">
              <tbody class="itens"></tbody>
        </table>
        <div id="cart">
          <div class="cart"></div>
          <span class="myPoints"></span>
          <span class="total"></span>
        </div>
        <div class="daemon">
          <input type="button" value="Concluir compra" onclick="buyItems()" />
          <input type="button" value="Resetar ítens" onclick="resetItems()" />
        </div>
Mirotic

Mirotic
***

Membro desde : 17/11/2018
Mensagens : 150
Pontos : 262

https://ajuda.forumeiros.com/

Ir para o topo Ir para baixo

Admineiro

Tópico resolvido Re: Criação de Itens no AddOn Loja

Mensagem por tikky 11.01.21 11:42

Olá @Mirotic,

Basta dar seguimento ao que o senhor já fez, mas os ícones não podem ter o mesmo nome, então o último, se alterar o nome, o produto vai aparecer na loja, não sei se é esta a sua dúvida Envergonhado


Cordialmente,
pedxz.
tikky

tikky
Admineiro
Admineiro

Membro desde : 13/01/2017
Mensagens : 7821
Pontos : 9063

Ir para o topo Ir para baixo

Tópico resolvido Re: Criação de Itens no AddOn Loja

Mensagem por Mirotic 11.01.21 14:57

Puts, valeu pedxz. Era realmente isso, ele não adiciona se tiver o mesmo nome. Resolvido.
Mirotic

Mirotic
***

Membro desde : 17/11/2018
Mensagens : 150
Pontos : 262

https://ajuda.forumeiros.com/

Ir para o topo Ir para baixo

Admineiro

Tópico resolvido Re: Criação de Itens no AddOn Loja

Mensagem por tikky 11.01.21 17:49

Tópico resolvido


Movido para "Questões resolvidas".
tikky

tikky
Admineiro
Admineiro

Membro desde : 13/01/2017
Mensagens : 7821
Pontos : 9063

Ir para o topo Ir para baixo

Ver o tópico anterior Ver o tópico seguinte Ir para o topo

- Tópicos semelhantes

Permissões neste sub-fórum
Não podes responder a tópicos