sali1101
5/6/2020 - 3:42 AM

API requests

function my_wp_crudd() {	
	
echo '<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>';

echo "

<script>
$.ajax({

headers: {
        'Authorization': 'Basic ' + btoa('ck_f71107caffb02f0df86513f86316078b2cb23f83:cs_831307dc659a0faa58e167a59343f26cebba398a')
    },
   // url: 'https://enerpydr4qz9.x.pipedream.net',
   url: '/wp-json/wc/v3/orders',
   
   
});


</script>
	
	";   
	
	
	
	
	
	
		 		
} 
add_shortcode( 'wp_crudd', 'my_wp_crudd' );
<script>
$(document).ready(function(){
$.ajax({
headers: {
        'Authorization': 'Basic ' + btoa('ck_f71107caffb02f0df86513f86316078b2cb23f83:cs_831307dc659a0faa58e167a59343f26cebba398a')
    },
  
   url: 'https://zenployee.tk/wp-json/wc/v3/orders',
  type: 'GET',
  data: {get_param: 'value'},
  dataType: 'json',
  success: function (data) {
     $.each(data, function(index, element) {
            $('body').append($('<div>', {
                text: element.id
            }) .addClass( "myClass" )  ); 
            // Remove addClass if wanted
        });
  }
});
});
</script>
function my_wp_crudd() {	
	
echo '<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>';

echo "

<script>
$.ajax({

headers: {
        'Authorization': 'Basic ' + btoa('ck_f71107caffb02f0df86513f86316078b2cb23f83:cs_831307dc659a0faa58e167a59343f26cebba398a')
    },
   // url: 'https://enerpydr4qz9.x.pipedream.net',
   url: '/wp-json/wc/v3/orders',
   type: 'post', 
   data  : {
   'billing': {'first_name':'Billi' } ,
   'line_items': [ 
      { 'product_id': '368' ,'quantity': '3' },
	   { 'product_id': '356' ,'quantity': '3' }
	  ]
   
   
   }
   
   
});


</script>
	
	";   
	
	
	
	
	
	
		 		
} 
add_shortcode( 'wp_crudd', 'my_wp_crudd' );