Quantcast
Viewing all articles
Browse latest Browse all 11091

PHP API - Private App Basics by selva

This is my code:

<?php
require_once 'lib/shopify.php';
$t="4226b767fd10efdcbe234ab0c449eda6";
$sc = new ShopifyClient("https-selvar-myshopify-com.myshopify.com", $t, API_KEY, SECRET);
if(!isset($t))
{
if(!isset($_GET['signature']))
{
  	$url = $sc->getAuthorizeUrl("read_orders");
	header('Location: '.$url);
}
if(isset($_GET['code']))
{
	$accTok = $sc->getAccessToken($_GET['code']);
	echo "token=".$accTok;exit;
	$orders = $sc->call('GET', 'admin/orders.json', array('published_status'=>'published'));
	foreach($orders as $order) {
   	echo $order['id'];
    	echo $order['email'];
}
}
}
if(isset($t))
{
	$orders = $sc->call('GET', 'admin/orders.json', array('published_status'=>'published'));
	foreach($orders as $order) {
	echo $order['buyer_accepts_marketing'];
	echo 'Order id:';
    	echo $order['id'];
	echo '<br/>';
	echo 'Email:';
    	echo $order['email'];
	echo '<br/>';
	echo 'Currency:';
    	echo $order['currency'];
	echo '<br/>';
	echo 'Fullfillment-status:';
    	echo $order['fulfillment_status'];
	echo '<br/>';
	echo 'Created at:';
    	echo $order['created_at'];
	echo '<br/>';
	echo 'Total price:';
    	echo $order['total_price'];
	echo '<br/>';
	echo 'subtotal_price:';
    	echo $order['subtotal_price'];
	echo '<br/>';
	echo 'order_number:';
	echo $order['order_number'];
	echo '<br/>';

   	}
}
?>

This is my output:

1Order id:258126351
Email:sasik55@yahoo.in
Currency:INR
Fullfillment-status:fulfilled
Created at:2014-05-14T08:00:17-04:00
Total price:76.50
subtotal_price:60.00
order_number:1013

If I put printr_order instead of foreach loop in the above code, I will get output like this=>

Array
(
    [0] => Array
        (
            [buyer_accepts_marketing] => 1
            [cancel_reason] => 
            [cancelled_at] => 
            [cart_token] => 050e4742642a4c62acbdcb48f868f062
            [checkout_token] => 9ff42ba4a8642e33a381170094d23c33
            [closed_at] => 
            [confirmed] => 1
            [created_at] => 2014-05-14T08:00:17-04:00
            [currency] => INR
            [email] => sasik55@yahoo.in
            [financial_status] => paid
            [fulfillment_status] => fulfilled
            [gateway] => bogus
            [id] => 258126351
            [landing_site] => /
            [location_id] => 
            [name] => #1013
            [note] => 
            [number] => 13
            [reference] => 
            [referring_site] => 
            [source] => browser
            [source_identifier] => 
            [source_name] => web
            [source_url] => 
            [subtotal_price] => 60.00
            [taxes_included] => 
            [test] => 1
            [token] => b7d35752786994c442d896368790ada8
            [total_discounts] => 0.00
            [total_line_items_price] => 60.00
            [total_price] => 76.50
            [total_price_usd] => 1.29
            [total_tax] => 7.50
            [total_weight] => 0
            [updated_at] => 2014-05-14T08:00:48-04:00
            [user_id] => 
            [browser_ip] => 117.193.178.44
            [landing_site_ref] => 
            [order_number] => 1013
            [discount_codes] => Array
                (
                )

            [note_attributes] => Array
                (
                )

            [processing_method] => direct
            [checkout_id] => 240262111
            [tax_lines] => Array
                (
                    [0] => Array
                        (
                            [price] => 7.50
                            [rate] => 0.125
                            [title] => VAT
                        )

                )

            [tags] => 
            [line_items] => Array
                (
                    [0] => Array
                        (
                            [fulfillment_service] => manual
                            [fulfillment_status] => fulfilled
                            [gift_card] => 
                            [grams] => 0
                            [id] => 457671611
                            [price] => 60.00
                            [product_id] => 289783991
                            [quantity] => 1
                            [requires_shipping] => 1
                            [sku] => 
                            [taxable] => 1
                            [title] => Rose Royalty
                            [variant_id] => 683222179
                            [variant_title] => 
                            [vendor] => Acme
                            [name] => Rose Royalty
                            [variant_inventory_management] => 
                            [properties] => Array
                                (
                                )

                            [product_exists] => 1
                            [tax_lines] => Array
                                (
                                    [0] => Array
                                        (
                                            [price] => 7.50
                                            [rate] => 0.125
                                            [title] => VAT
                                        )

                                )

                        )

                )

            [shipping_lines] => Array
                (
                    [0] => Array
                        (
                            [code] => Standard Shipping
                            [price] => 9.00
                            [source] => shopify
                            [title] => Standard Shipping
                            [tax_lines] => Array
                                (
                                    [0] => Array
                                        (
                                            [price] => 0.00
                                            [rate] => 0.125
                                            [title] => VAT
                                        )

                                )

                        )

                )

            [payment_details] => Array
                (
                    [avs_result_code] => 
                    [credit_card_bin] => 1
                    [cvv_result_code] => 
                    [credit_card_number] => •••• •••• •••• 1
                    [credit_card_company] => Bogus
                )

            [billing_address] => Array
                (
                    [address1] => 5th
                    [address2] => 
                    [city] => trichy
                    [company] => ww
                    [country] => India
                    [first_name] => s1
                    [last_name] => s2
                    [latitude] => 10.77878
                    [longitude] => 78.675796
                    [phone] => 9629305693
                    [province] => Tamil Nadu
                    [zip] => 600015
                    [name] => s1 s2
                    [country_code] => IN
                    [province_code] => TN
                )

            [shipping_address] => Array
                (
                    [address1] => 5th
                    [address2] => 
                    [city] => trichy
                    [company] => ww
                    [country] => India
                    [first_name] => s1
                    [last_name] => s2
                    [latitude] => 10.77878
                    [longitude] => 78.675796
                    [phone] => 9629305693
                    [province] => Tamil Nadu
                    [zip] => 600015
                    [name] => s1 s2
                    [country_code] => IN
                    [province_code] => TN
                )

            [fulfillments] => Array
                (
                    [0] => Array
                        (
                            [created_at] => 2014-05-14T08:00:18-04:00
                            [id] => 161031899
                            [order_id] => 258126351
                            [service] => manual
                            [status] => success
                            [tracking_company] => 
                            [updated_at] => 2014-05-14T08:00:18-04:00
                            [tracking_number] => 
                            [tracking_numbers] => Array
                                (
                                )

                            [tracking_url] => 
                            [tracking_urls] => Array
                                (
                                )

                            [receipt] => Array
                                (
                                )

                            [line_items] => Array
                                (
                                    [0] => Array
                                        (
                                            [fulfillment_service] => manual
                                            [fulfillment_status] => fulfilled
                                            [gift_card] => 
                                            [grams] => 0
                                            [id] => 457671611
                                            [price] => 60.00
                                            [product_id] => 289783991
                                            [quantity] => 1
                                            [requires_shipping] => 1
                                            [sku] => 
                                            [taxable] => 1
                                            [title] => Rose Royalty
                                            [variant_id] => 683222179
                                            [variant_title] => 
                                            [vendor] => Acme
                                            [name] => Rose Royalty
                                            [variant_inventory_management] => 
                                            [properties] => Array
                                                (
                                                )

                                            [product_exists] => 1
                                            [tax_lines] => Array
                                                (
                                                    [0] => Array
                                                        (
                                                            [price] => 7.50
                                                            [rate] => 0.125
                                                            [title] => VAT
                                                        )

                                                )

                                        )

                                )

                        )

                )

            [client_details] => Array
                (
                    [accept_language] => en-US,en;q=0.8,fr;q=0.6
                    [browser_ip] => 117.193.178.44
                    [session_hash] => b3da6544d3d8d9d87f544f20ced2d8b99fde635605268a9f82b3463cadf6a90c
                    [user_agent] => Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36
                )

            [customer] => Array
                (
                    [accepts_marketing] => 1
                    [created_at] => 2014-05-13T08:20:02-04:00
                    [email] => sasik55@yahoo.in
                    [first_name] => selvarani
                    [id] => 235028431
                    [last_name] => raja
                    [last_order_id] => 
                    [multipass_identifier] => 
                    [note] => 
                    [orders_count] => 0
                    [state] => disabled
                    [total_spent] => 0.00
                    [updated_at] => 2014-05-14T08:00:48-04:00
                    [verified_email] => 1
                    [tags] => 
                    [last_order_name] => 
                    [default_address] => Array
                        (
                            [address1] => 5th
                            [address2] => 
                            [city] => trichy
                            [company] => ww
                            [country] => India
                            [first_name] => s1
                            [id] => 294451455
                            [last_name] => s2
                            [phone] => 9629305693
                            [province] => Tamil Nadu
                            [zip] => 600015
                            [name] => s1 s2
                            [province_code] => TN
                            [country_code] => IN
                            [country_name] => India
                            [default] => 1
                        )

                )

        )

)

t's source code of my output.In this output, I will get the values from only contain array[0], I want get all the values by using loop. If anybody know help me.

Any help would be appreciated. Thank you!.


Viewing all articles
Browse latest Browse all 11091

Trending Articles