Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getURLVar(key) {
  2.     var value = [];
  3.  
  4.     var query = String(document.location).split('?');
  5.  
  6.     if (query[1]) {
  7.         var part = query[1].split('&');
  8.  
  9.         for (i = 0; i < part.length; i++) {
  10.             var data = part[i].split('=');
  11.  
  12.             if (data[0] && data[1]) {
  13.                 value[data[0]] = data[1];
  14.             }
  15.         }
  16.  
  17.         if (value[key]) {
  18.             return value[key];
  19.         } else {
  20.             return '';
  21.         }
  22.     } else {
  23.         var query = String(document.location.pathname).split('/');
  24.         if (query[query.length - 1] == 'cart') value['route'] = 'checkout/cart';
  25.         if (query[query.length - 1] == 'checkout') value['route'] = 'checkout/checkout';
  26.        
  27.         if (value[key]) {
  28.             return value[key];
  29.         } else {
  30.             return '';
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement