Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 15th, 2012  |  syntax: None  |  size: 1.16 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Json show only object with a specific id
  2. "shipping":{
  3.    "methods":{
  4.      "core|13490|40699":{
  5.        "id":"core|13490|40699",
  6.        "price":{
  7.          "price_excl":"0.0000","price_incl":"0.0000"
  8.        }
  9.      },
  10.      "core|10292|40695":{
  11.        "id":"core|10292|40695",
  12.        "price":{
  13.          "price_excl":"21.0084","price_incl":"25.0000"
  14.        }
  15.      }
  16.    }
  17.  },
  18.        
  19. window.onload = function(){
  20.       $.getJSON('http://shop.com/cart/?format=json', function(data){
  21.         $.each(data.cart.shipping.methods, function(index, method){
  22.           $('<span></span>')
  23.             .html('<strong>' + method.price.price_incl + '</strong>')
  24.             .appendTo('.cart-shipping');
  25.         });
  26.       });
  27.     };
  28.        
  29. if (index == "core|10292|40695") {
  30.     $('<span></span>').html('<strong>' + method.price.price_incl + '</strong>').appendTo('.cart-shipping');
  31. }
  32.        
  33. $.each(data.cart.shipping.methods, function(index, method){
  34.   $('<span></span>').html('<strong>' + method.price.price_incl + '</strong>').appendTo('.cart-shipping');
  35. });
  36.        
  37. $('<span></span>').html('<strong>' + data.cart.shipping.methods['core|10292|40695'].price.price_incl + '</strong>').appendTo('.cart-shipping');