Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Pedro bezerra

Manter dados carrinho Woocomerce

Recommended Posts

Seguinte, meu site e http://elojobmundo.com/?post_type=product tem um simulador de elos la, quando tento comprar ele redereciona para o carrinho mais o problema e que o produto não vai junto, ele alega que não tem nenhum produto. o que eu preciso fazer? pois tenho o codigo php e quero que va para o carrinho do woocommerce.

codigo do simulador:

<center>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
function EloEvolution(attrs) {
  var image_path = 'http://elojob.com.br/calculadora/tier/';
  this._products = {
    b5: {
      id: 2854,
      price: 0,
      image: image_path + 'bronze_5.png'
    },
    b4: {
      id: 2854,
      price: 25,
      image: image_path + 'bronze_4.png'
    },
    b3: {
      id: 2854,
      price: 25,
      image: image_path + 'bronze_3.png'
    },
    b2: {
      id: 2854,
      price: 25,
      image: image_path + 'bronze_2.png'
    },
    b1: {
      id: 2854,
      price: 25,
      image: image_path + 'bronze_1.png'
    },
    s5: {
      id: 2855,
      price: 30,
      image: image_path + 'silver_5.png'
    },
    s4: {
      id: 2855,
      price: 30,
      image: image_path + 'silver_4.png'
    },
    s3: {
      id: 2855,
      price: 30,
      image: image_path + 'silver_3.png'
    },
    s2: {
      id: 2855,
      price: 30,
      image: image_path + 'silver_2.png'
    },
    s1: {
      id: 2855,
      price: 30,
      image: image_path + 'silver_1.png'
    },
    g5: {
      id: 2856,
      price: 35,
      image: image_path + 'gold_5.png'
    },
    g4: {
      id: 2856,
      price: 35,
      image: image_path + 'gold_4.png'
    },
    g3: {
      id: 2856,
      price: 35,
      image: image_path + 'gold_3.png'
    },
    g2: {
      id: 2856,
      price: 35,
      image: image_path + 'gold_2.png'
    },
    g1: {
      id: 2856,
      price: 35,
      image: image_path + 'gold_1.png'
    },
    p5: {
      id: 2857,
      price: 50,
      image: image_path + 'platinum_5.png'
    },
    p4: {
      id: 2857,
      price: 50,
      image: image_path + 'platinum_4.png'
    },
    p3: {
      id: 2857,
      price: 50,
      image: image_path + 'platinum_3.png'
    },
    p2: {
      id: 2857,
      price: 50,
      image: image_path + 'platinum_2.png'
    },
    p1: {
      id: 2857,
      price: 50,
      image: image_path + 'platinum_1.png'
    },
    d5: {
      id: 2858,
      price: 100,
      image: image_path + 'diamond_5.png'
    },
    d4: {
      id: 2858,
      price: 120,
      image: image_path + 'diamond_4.png'
    },
    d3: {
      id: 2858,
      price: 100,
      image: image_path + 'diamond_3.png'
    },
    d2: {
      id: 2858,
      price: 100,
      image: image_path + 'diamond_2.png'
    },
    d1: {
      id: 2858,
      price: 100,
      image: image_path + 'diamond_1.png'
    },
    c5: {
      id: 2896,
      price: 200,
      image: image_path + 'challenger_1-2.png'
    },
    c4: {
      id: 0,
      price: 0,
      image: image_path + 'challenger_1-2.png'
    },
    c3: {
      id: 0,
      price: 0,
      image: image_path + 'challenger_1-2.png'
    },
    c2: {
      id: 0,
      price: 0,
      image: image_path + 'challenger_1-2.png'
    },
    c1: {
      id: 0,
      price: 0,
      image: image_path + 'challenger_1-2.png'
    }
  };
 
  this.currencyFormat = 'R$';
  this.currencyDecimalSeparator = ',';
 
  this._errorMessages = {
    dest_lt_cur: "Nível Desejado é menor que o Atual"
  }
  this._sequence = [
    'b5','b4', 'b3', 'b2', 'b1',
    's5','s4', 's3', 's2', 's1',
    'g5','g4', 'g3', 'g2', 'g1',
    'p5','p4', 'p3', 'p2', 'p1',
    'd5','d4', 'd3', 'd2', 'd1',
    'c5','c4', 'c3', 'c2', 'c1'
  ];
  this.errors = [];
 
 
// ============== PUBLIC METHODS ================
 
  // Need to set these settings
  // this.selectCurrentTier = attrs['selectCurrentTier'];
  // this.selectCurrentDivision = attrs['selectCurrentDivision'];
  // this.currentWrapImage = attrs['currentWrapImage'];
  // this.selectDestinationTier = attrs['selectDestinationTier'];
  // this.selectDestinationDivision = attrs['selectDestinationDivision'];
  // this.destinationWrapImage = attrs['destinationWrapImage'];
  // this.priceContainer = attrs['priceContainer'];
  // this.addToCartButton = attrs['addToCartButton'];
  // this.addToCartUrl = attrs['addToCartUrl'];
  
  this.settings = function(attrs) {
    for (var key in attrs) {
      this[key] = attrs[key];
    }
    this._attachAddToCart();
 
    return this;
  }
 
  this.change = function() {
    this.ck = $(this.selectCurrentTier).val() + $(this.selectCurrentDivision).val();
    this.dk = $(this.selectDestinationTier).val() + $(this.selectDestinationDivision).val();
    this.current = this._products[this.ck];
    this.destination = this._products[this.dk];
 
    this.updateImage();
    var price = this.sumValue();
    $(this.priceContainer).text(this._formatCurrency(price));
    return this;
  }
 
  this.updateImage = function() {
    $(this.currentWrapImage).css('background-image', 'url(' + this.current.image + ')');
    $(this.destinationWrapImage).css('background-image', 'url(' + this.destination.image + ')');
 
    if($(this.selectDestinationTier).val() == 'c') {
     $(this.selectDestinationDivision).attr('disabled', 'disabled');
    }
    else {
     $(this.selectDestinationDivision).removeAttr('disabled');
}
  }
 
  this.sumValue = function() {
    this._getSequence();
    if(this.i_dest < this.i_cur) {
      this._addError('dest_gt_cur');
      return false;
    }
 
    var sum = 0;
    this._execInSequence(function(p, k){
      sum += p.price;
    });
    return sum;
  }
 
  this.addToCart = function() {
    var evo = this;
    if(evo.beforeAddToCart) evo.beforeAddToCart();
    evo._getSequence();
 
    var products = [];
    evo._execInSequence(function(p){
      products.push(p);
    });
 
    function ajaxOrRedirectToCart(_products) {
      var p = products.shift();
      if(!p){
        window.parent.location = evo.cartUrl;
      }
      var url = evo.addToCartUrl.replace('%product_id', p.id);
      jQuery.get(url).success(function(){
        ajaxOrRedirectToCart(_products);
      });
    }
 
    ajaxOrRedirectToCart(products);
  }
 
  this.errorMessages = function () {
    var trErrors = [];
    for(var i = 0; i < this.errors.length; i++) {
      var k = this.errors[i];
      if(this._errorMessages[k]) {
        trErrors.push(this._errorMessages[k]);
      } else {
        trErrors.push(k);
      }
      return trErrors;
    }
  }
 
// ============== PRIVATE METHODS ================
  this._getSequence = function() {
    for(var i = 0; i < this._sequence.length; i++) {
      if(this.ck === this._sequence[i]) {
        this.i_cur = i;
      }
      if(this.dk === this._sequence[i]) {
        this.i_dest = i;
      }
    }
  }
 
  this._execInSequence = function(func) {
    for(var i = this.i_cur + 1; i <= this.i_dest; i++) {
      var p_key = this._sequence[i];
      var product = this._products[p_key];
      func(product, p_key);
    }
  }
 
  this._formatCurrency = function(val) {
    var o = [];
    var decPart = new String(parseInt((val - parseInt(val)) * Math.pow(10, this._currencyDecimalQty)) || 0);
    var intPart = new String(parseInt(val) || 0);
    if (decPart < 10) {
      decPart = "0" + decPart;
    }
 
    o.push(this.currencyFormat);
    o.push(' ')
    o.push(intPart);
 
    o.push(this.currencyDecimalSeparator);
    o.push(decPart);
 
    return o.join('');
  }
 
  this._attachAddToCart = function() {
    var evo = this;
    jQuery(evo.addToCartButton).click(function(){
      evo.addToCart();
    });
  }
 
  this._addError = function(err) {
    this.errors.push(err);
  }
 
  this.init = function(attrs) {
    if(attrs) {
      this.settings(attrs);
    }
  }
  this.init(attrs);
}
 
$(function(){
  var evo = new EloEvolution({
    selectCurrentTier: '#ct',
    selectCurrentDivision: '#cd',
    selectDestinationTier: '#dt',
    selectDestinationDivision: '#dd',
    currentWrapImage: '#cti',
    destinationWrapImage: '#dti',
    priceContainer: '#price',
    addToCartButton: '#cart',
    addToCartUrl: '/?post_type=product&add-to-cart=%product_id',
    cartUrl: '/carrinho',
    beforeAddToCart: function() {
      jQuery('#loader').show();
    }
  }).change();
  $('#ct,#cd,#dt,#dd').change(function(){
    // we need to call inside an anonymous function
    // because we use `this`, inside evo.change function,
    // referring to evo instance, instead the dom object
    // that was changed.
    evo.change();
  });
});
</script>
 
<style>
 
* {
  -webkit-transition: all 0.4s ease-in-out;
  -moz-transition: all 0.4s ease-in-out;
  -o-transition: all 0.4s ease-in-out;
  transition: all 0.4s ease-in-out;
}
 
#content2 {
  width:725px;
  background:url('http://elojob.com.br/calculadora/bg_calc.png') no-repeat center top;
  height:410px;
  background-size: 100%;
}
 
.current_tier_img,
.desired_tier_img {
  width: 192px;
  height: 192px;
  background-image: url(http://elojob.com.br/calculadora/tier/bronze_5.png);
  text-align: center;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  background-repeat: no-repeat;
  font-size: 18px;
  position: absolute;
  left: 50%;
  top: 70px;
  ;
}
 
#wrapper {position: relative;}
 
.desired_tier_img {
  ;
}
 
.desired_division {
  background:#FFF;
}
 
.current_tier_img span,
.desired_tier_img span,
#loader, h2 {display: none;}
 
br {clear:both;}
 
/*
#loader {
  width: 100%;
  height: 100%;
  display: none;
  background-color: #fff;
  opacity: 0.9;
  position: absolute;
  text-align: center;
  vertical-align: middle;
  padding-top: 300px;
}*/
 
.current_tier_division,
.desired_tier_division {
  width:49%;
  float:left;
  margin-bottom:20px;
  position: relative;
}
 
#price {
  position: absolute;
  width: 100px;
  left:50%;
  text-align: center;
  font-family: 'Trebuchet Ms';
  color:#FFF;
  ;
  top: 170px;
  font-size: 18px;
 
}
 
#cart {
  width: 150px;
  height:72px;
  position: absolute;
  border: 0px;
  background:url(http://elojob.com.br/calculadora/bt_comprar.png) no-repeat center top;
  left: 50%;
  ;
  top: 220px;
  
}
 
#cart:hover {
  cursor: pointer;
  background:url(http://elojob.com.br/calculadora/bt_comprar2.png) no-repeat center top;
}
 
.current_tier,
.desired_tier {
  background:#FFF;
  position: absolute;
  top: 250px;
  left: 50%;
  ;
  width: 150px;
  height: 28px;
  ;
  width: 130px;
}
 
.current_tier select,
.desired_tier select {
  border:0px;
  background: none;
  height: 28px;
}
 
.current_tier select:first-child
.desired_tier select:first-child {
  width:100px;
}
 
.current_tier select:last-child,
.desired_tier select:last-child {
  float:right;
}
 
/*#price {
float: right;
padding: 5px 10px;
width: 83px;
text-align: right;
border: 1px dotted #d1d1d1;
background: #f1f1f1;
margin-right: 159px;}*/
 
</style>
<link type="text/css" rel="stylesheet" href="chrome-extension://cpngackimfmofbokmjmljamhdncknpmg/style.css"><script type="text/javascript" charset="utf-8" src="chrome-extension://cpngackimfmofbokmjmljamhdncknpmg/js/page_context.js"></script></head>
<body screen_capture_injected="true" cz-shortcut-listen="true">
<div id="loader">Adicionando produto no carrinho...<br>Obs: O tempo de espera depende da quantidade que for adicionado ao carrinho.<br /><img src="http://elojob.com.br/calculadora/ajax-loading.gif" /></div>
<div id="content2">
  <div id="main_content">
    
    <div id="wrapper">
      <div class="current_tier_division">
        <div id="cti" class="current_tier_img"><span>Posição Atual</span></div>
        <div class="current_tier">
          <select id="ct">
            <option value="b">Bronze</option>
            <option value="s" selected>Prata</option>
            <option value="g">Ouro</option>
            <option value="p">Platina</option>
            <option value="d">Diamante</option>
          </select>
          <select id="cd">
            <option>5</option>
            <option>4</option>
            <option>3</option>
            <option>2</option>
            <option selected>1</option>
          </select>
        </div>
      </div>
      <div class="desired_tier_division">
        <div id="dti" class="desired_tier_img"><span>Posição Desejada</span></div>
        <div class="desired_tier">
          <select id="dt">
            <option value="b">Bronze</option>
            <option value="s">Prata</option>
            <option value="g" selected>Ouro</option>
            <option value="p">Platina</option>
            <option value="d">Diamante</option>
     <option value="c">Mestre</option>
          </select>
          <select id="dd">
            <option selected="selected">5</option>
            <option>4</option>
            <option>3</option>
            <option>2</option>
            <option>1</option>
          </select>
        </div>
      </div>
      <div id="sv" class="server" style="display:none;">
        <select>
          <option>Brazil</option>
        </select> 
      </div> 
      <div class="vpn" style="display:none;">
        <input name="VPN Protection" type="checkbox" value="VPN Protection" id="vpn_id"></input>
      </div>
      <br>
      <h2> VALOR </h2>
      <div id="price">Valor</div>
      <div>
        <button id="cart"></button>
      </div>
    </div>
  </div>
</div>
</body>
</html>
</center>

Compartilhar este post


Link para o post
Compartilhar em outros sites

  • Conteúdo Similar

    • Por ILR master
      Fala galera.
      Espero que todos estejam bem.
      Seguinte: Tenho um arquivo xml onde alguns campos estão com : (dois pontos), como o exemplo abaixo:
       
      <item>
      <title>
      d sa dsad sad sadasdas
      </title>
      <link>
      dsadas dsa sad asd as dsada
      </link>
      <pubDate>sadasdasdsa as</pubDate>
      <dc:creator>
      d sad sad sa ad as das
      </dc:creator>
      </item>
       
      Meu código:
       
      $link = "noticias.xml"; 
      $xml = simplexml_load_file($link); 
      foreach($xml -> channel as $ite) {     
           $titulo = $ite -> item->title;
           $urltitulo = $ite -> item->link;
           print $urltitulo = $ite -> item->dc:creator;
      } //fim do foreach
      ?>
       
      Esse campo dc:creator eu não consigo ler. Como faço?
       
      Agradeço quem puder me ajudar.
       
      Abs
       
       
    • Por First
      Olá a todos!
       
      Eu estou criando um sistema do zero mas estou encontnrando algumas dificuldades e não estou sabendo resolver, então vim recorrer ajuda de vocês.
      Aqui está todo o meu código: https://github.com/PauloJagata/aprendizado/
       
      Eu fiz um sistema de rotas mas só mostra o conteúdo da '/' não sei porque, quando eu tento acessar o register nada muda.
      E eu também quero que se não estiver liberado na rota mostra o erro de 404, mas quando eu tento acessar um link inválido, nada acontece.
      Alguém pode me ajudar com isso? E se tiver algumas sugestão para melhoria do código também estou aceitando.
       
       
      Desde já, obrigado.
    • Por landerbadi
      Olá pessoal, boa tarde
       
      Tenho uma tabela chamada "produtos" com os seguintes campos (id, produto) e outra tabela chamada "itens" com os seguintes campos (id, prod_01, prod_02, prod_03, prod_04).
       
      Na tabela produtos eu tenho cadastrado os seguintes produtos: laranja, maçã, uva, goiaba, arroz, feijão, macarrão, etc.
       
      Na tabela itens eu tenho cadastrado os itens da seguinte maneira:
       
      1, laranja, uva, arroz, feijão;
      2, maçã, macarrão, goiaba, uva;
      3, arroz, feijão, maçã, azeite
       
      Meu problema é o seguinte: 
      Eu escolho um produto da tabela "produtos", por exemplo "uva".  Preciso fazer uma consulta na tabela "itens" para ser listado todos os registros que contenham o produto "uva" e que todos os demais produtos estejam cadastrados na tabela "produtos".
       
      No exemplo acima seria listado apenas dois registros, pois o terceiro registro não contém o produto "uva". 
       
      Alguém pode me ajudar? Pois estou quebrando a cabeça a vários dias e não consigo achar uma solução.
    • Por landerbadi
      Boa tarde pessoal. Estou tentado fazer uma consulta no banco de dados porém estou tendo dificuldades. Tenho uma tabela chamada "itens" com os seguintes campos: id, item, plural, ativo. Nela tem cadastrado vários itens e seu respectivo plural. No campo ativo eu coloco a letra "S" para informar que esta palavra está ativa no sistema. Por exemplo: 1, casa, casas, S 2, mesa, mesas, S 3, cama, camas, S 4, moto, motos, S 5, rádio, rádios O quinto registro "radio" não está ativo no sistema pois não tem um "S" no campo ativo. E outra tabela chamada "variações" com os seguintes campos (id, item1, item2, item3) com os seguintes registros: 1, casa, camas, moto 2, mesas, casas, radio 3, rádio, cama, mesa Eu preciso fazer uma busca na tabela variações da seguinte maneira: Eu escolho um registro na tabela "itens", por exemplo "casa". Preciso fazer com que o php me liste todos os registros da tabela "variações" que contenham a palavra "casa". Porém se tiver algum registro com a palavra "casas" também tem que ser listado. Neste caso ele irá encontrar dois registros. Agora eu preciso que o php verifique os demais itens e faça a listagem apenas dos item que estão ativos (que contenham um "S" no campo ativo. Neste caso ele irá encontrar apenas um registro, pois o segundo registro contém a palavra "rádio". E "rádio" não está ativo na tabela itens. Como faço isso?
    • Por First
      Olá a todos!
       
      Quando eu tento fazer o login me mostra esse erro "Could not log you in."; Alguém sabe me ajudar a resolver esse problema no meu código?
      <?php require_once("core/init.php"); if (Input::exists()) { if (Token::check(Input::get("token"))) { $validate = new Validate(); $validation = $validate->check($_POST, array( "username" => array("required" => true), "password" => array("required" => true) )); if ($validation->passed()) { $user = new User(); $remember = (Input::get("remember")) === "on" ? true : false; $login = $user->login(Input::get("username"), Input::get("password"), $remember); if ($login) { Session::flash("home", "Welcome back!"); Redirect::to("index.php"); } else { echo "Could not log you in."; } } else { foreach ($validation->errors() as $error) { echo $error."<BR>"; } } } } ?> <form action="" method="POST"> <div class="field"> <label for="username">Username</label> <input type="text" name="username" id="username"> </div> <div class="field"> <label for="password">Password</label> <input type="password" name="password" id="password"> </div> <div class="field"> <label for="remember"> <input type="checkbox" name="remember" id="remember"> Remember me </label> </div> <input type="hidden" name="token" value="<?php echo Token::generate(); ?>"> <input type="submit" value="Log in"> </form>  
       
      Desde já obrigado.
×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.