SHARE
TWEET

Untitled

a guest Jun 26th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function retrievedata(){
  2.  
  3. var iduser = window.user;
  4. var uiduser = iduser.uid;
  5.  
  6. var database = firebase.database();
  7. var ref = database.ref('productspushed'+'/'+uiduser);
  8. var ref2 = database.ref('products');
  9.  
  10.   $.get(window.location.href, function(data){
  11.  
  12.   $("tr.woocommerce-cart-form__cart-item.cart_item").each(function(i, obj) {
  13.       const name = $('td.product-name', obj).text();
  14.       const nameok = name.trim();
  15.       console.log(nameok);
  16.  
  17.       const url = $('a', obj).eq(1).attr('href');
  18.       console.log(url);
  19.  
  20.       const imgurl = $('img.attachment-woocommerce_thumbnail.size-woocommerce_thumbnail', obj).attr('srcset').split(',').pop().trim().split(' ')[0];
  21.       console.log(imgurl);
  22.  
  23.       const price = $('span.woocommerce-Price-amount.amount', obj).eq(0).text().replace(/€/, '');
  24.       console.log(price);
  25.  
  26.       const data = {title: nameok,
  27.       imgurl: imgurl,
  28.       price: price,
  29.       url: url,
  30.       };
  31.  
  32.         ref2.push(data);
  33.         ref.push(data);
  34.  
  35.       })
  36.   })
  37.  
  38.  
  39. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top