Store a variable from the array of object php - php

I have a php variabl $purchase_data which when I did
print_r('purchase_data');
I got the output as
Array
(
[downloads] => Array
(
[0] => Array
(
[id] => 28
[options] => Array
(
)
[quantity] => 1
)
)
[fees] => Array
(
)
[subtotal] => 1
[discount] => 0
[tax] => 0
[price] => 1
[purchase_key] => a8d14e34ba425f9de6afe3ad4809587e
[user_email] => esh#test.com
[date] => 2014-05-11 20:07:22
[user_info] => Array
(
[id] => 1
[email] => eshtest.com
[first_name] => esh
[last_name] =>
[discount] => none
[address] =>
)
[post_data] => Array
(
[edd_email] => esh#test.com
[edd_first] => esh
[edd_last] =>
[edd_phone] => 919995871693
[edd-user-id] => 1
[edd_action] => purchase
[edd-gateway] => sample_gateway
)
[cart_details] => Array
(
[0] => Array
(
[name] => Shirt
[id] => 28
[item_number] => Array
(
[id] => 28
[options] => Array
(
)
[quantity] => 1
)
[item_price] => 1
[quantity] => 1
[discount] => 0
[subtotal] => 1
[tax] => 0
[price] => 1
)
)
[gateway] => sample_gateway
[card_info] => Array
(
[card_name] =>
[card_number] =>
[card_cvc] =>
[card_exp_month] =>
[card_exp_year] =>
[card_address] =>
[card_address_2] =>
[card_city] =>
[card_state] =>
[card_country] =>
[card_zip] =>
)
)
How can i store the value to edd_phone [edd_phone] into variable $mobileNo ?
Sorry for ths kind of a question.But badly need help

If you want to assign the value of [edd_phone] to $mobileNo , use this :
$mobileNo = $purchase_data['post_data']['edd_phone'];
As a side note : Your array is very complexly nested. If I were you, I would avoid such complex arrays.

Related

Set session variable without reloading the page

I send a value to a php file with AJAX.
I am having this function in jQuery:
// Service select change
$container.on('change', '.bookly-js-select-service', function() {
var gekozen_behandeling = this.value;
$.ajax({
type: 'POST',
url: '/behandeling.php',
data: {
behandeling_nieuw: gekozen_behandeling
},
dataType: 'html',
success: function(response) {
console.log(response);
}
});
});
After doing this it alerts done.
In my file behandeling.php the code is like this:
<?php
session_start();
$_SESSION["type_behandeling"] = $_POST["behandeling_nieuw"];
echo '<pre>' . print_r($_SESSION, TRUE) . '</pre>';
?>
After doing this and navigate to the behandeling.php file the session variable is still empty.
<pre>Array
(
[bookly] => Array
(
[forms] => Array
(
[5e1c6d8916b27] => Array
(
[defaults] => Array
(
[service_id] => 0
[staff_id] => 0
[location_id] => 0
[category_id] => 5
)
[last_touched] => 1578921357
[data] => Array
(
[first_rendered_step] => 1
[time_zone] =>
[time_zone_offset] =>
[date_from] => 2020-01-13
[days] =>
[time_from] => 09:00
[time_to] => 21:00
[slots] => Array
(
)
[facebook_id] =>
[full_name] =>
[first_name] =>
[last_name] =>
[email] =>
[email_confirm] =>
[phone] =>
[birthday] =>
[additional_address] =>
[country] =>
[state] =>
[postcode] =>
[city] =>
[street] =>
[street_number] =>
[address_iso] => Array
(
)
[notes] =>
[info_fields] => Array
(
)
[coupon_code] =>
[deposit_full] => 0
[edit_cart_keys] => Array
(
)
[repeated] => 0
[repeat_data] => Array
(
)
)
[cart] => Array
(
)
[chain] => Array
(
[0] => Array
(
[service_id] =>
[staff_ids] => Array
(
)
[number_of_persons] =>
[quantity] =>
[extras] => Array
(
)
[custom_fields] => Array
(
)
[location_id] =>
[series_unique_id] => 0
[first_in_series] =>
[units] => 1
)
)
[booking_numbers] => Array
(
)
[payment_id] =>
[payment_type] => local
)
[5e1c6dc0324c7] => Array
(
[defaults] => Array
(
[service_id] => 0
[staff_id] => 0
[location_id] => 0
[category_id] => 5
)
[last_touched] => 1578921411
[data] => Array
(
[first_rendered_step] => 1
[time_zone] =>
[time_zone_offset] =>
[date_from] => 2020-01-13
[days] =>
[time_from] => 09:00
[time_to] => 21:00
[slots] => Array
(
)
[facebook_id] =>
[full_name] =>
[first_name] =>
[last_name] =>
[email] =>
[email_confirm] =>
[phone] =>
[birthday] =>
[additional_address] =>
[country] =>
[state] =>
[postcode] =>
[city] =>
[street] =>
[street_number] =>
[address_iso] => Array
(
)
[notes] =>
[info_fields] => Array
(
)
[coupon_code] =>
[deposit_full] => 0
[edit_cart_keys] => Array
(
)
[repeated] => 0
[repeat_data] => Array
(
)
)
[cart] => Array
(
)
[chain] => Array
(
[0] => Array
(
[service_id] =>
[staff_ids] => Array
(
)
[number_of_persons] =>
[quantity] =>
[extras] => Array
(
)
[custom_fields] => Array
(
)
[location_id] =>
[series_unique_id] => 0
[first_in_series] =>
[units] => 1
)
)
[booking_numbers] => Array
(
)
[payment_id] =>
[payment_type] => local
)
[5e1c6df9da30f] => Array
(
[defaults] => Array
(
[service_id] => 0
[staff_id] => 0
[location_id] => 0
[category_id] => 5
)
[last_touched] => 1578921468
[data] => Array
(
[first_rendered_step] => 1
[time_zone] =>
[time_zone_offset] =>
[date_from] => 2020-01-13
[days] =>
[time_from] => 09:00
[time_to] => 21:00
[slots] => Array
(
)
[facebook_id] =>
[full_name] =>
[first_name] =>
[last_name] =>
[email] =>
[email_confirm] =>
[phone] =>
[birthday] =>
[additional_address] =>
[country] =>
[state] =>
[postcode] =>
[city] =>
[street] =>
[street_number] =>
[address_iso] => Array
(
)
[notes] =>
[info_fields] => Array
(
)
[coupon_code] =>
[deposit_full] => 0
[edit_cart_keys] => Array
(
)
[repeated] => 0
[repeat_data] => Array
(
)
)
[cart] => Array
(
)
[chain] => Array
(
[0] => Array
(
[service_id] =>
[staff_ids] => Array
(
)
[number_of_persons] =>
[quantity] =>
[extras] => Array
(
)
[custom_fields] => Array
(
)
[location_id] =>
[series_unique_id] => 0
[first_in_series] =>
[units] => 1
)
)
[booking_numbers] => Array
(
)
[payment_id] =>
[payment_type] => local
)
[5e1c6e0f76ddd] => Array
(
[defaults] => Array
(
[service_id] => 0
[staff_id] => 0
[location_id] => 0
[category_id] => 5
)
[last_touched] => 1578921490
[data] => Array
(
[first_rendered_step] => 1
[time_zone] =>
[time_zone_offset] =>
[date_from] => 2020-01-13
[days] =>
[time_from] => 09:00
[time_to] => 21:00
[slots] => Array
(
)
[facebook_id] =>
[full_name] =>
[first_name] =>
[last_name] =>
[email] =>
[email_confirm] =>
[phone] =>
[birthday] =>
[additional_address] =>
[country] =>
[state] =>
[postcode] =>
[city] =>
[street] =>
[street_number] =>
[address_iso] => Array
(
)
[notes] =>
[info_fields] => Array
(
)
[coupon_code] =>
[deposit_full] => 0
[edit_cart_keys] => Array
(
)
[repeated] => 0
[repeat_data] => Array
(
)
)
[cart] => Array
(
)
[chain] => Array
(
[0] => Array
(
[service_id] =>
[staff_ids] => Array
(
)
[number_of_persons] =>
[quantity] =>
[extras] => Array
(
)
[custom_fields] => Array
(
)
[location_id] =>
[series_unique_id] => 0
[first_in_series] =>
[units] => 1
)
)
[booking_numbers] => Array
(
)
[payment_id] =>
[payment_type] => local
)
)
)
[type_behandeling] => 51
)
</pre>
It might be possible that when you navigate to behandeling.php
that you are assigning the posted variable to session as
$_SESSION["type_behandeling"] = $_POST["behandeling_nieuw"];
the posted data not found as you are visiting (http get method). Hence session is overwritten with null or empty.
Change dataType: 'html' to dataType: 'JSON'
Through Chrome/Firefox Dev tools check - behandeling.php file is getting called
Through Chrome/Firefox Dev tools check - form data is getting submitted to PHP File
Also if you access the file outside, it Recheck the $_POST Value , since the value is not set, a blank will be assigned to the session.
Check the $_POST Value
if (isset($_POST["behandeling_nieuw"])) {
$_SESSION["type_behandeling"] = $_POST["behandeling_nieuw"];
echo '<pre>' . print_r($_SESSION, TRUE) . '</pre>';
} else {
echo "POST Value not set";
if(isset($_SESSION['type_behandeling']) && !empty($_SESSION['type_behandeling'])) {
echo 'Set and not empty, and no undefined index error!';
}
else {
echo "Session is not set ";
}
}

How to access protective array? [duplicate]

This question already has answers here:
Get Order items and WC_Order_Item_Product in WooCommerce 3
(2 answers)
Closed 5 years ago.
I have woocommrece order detail array which had protective element so when like normal array you can't access them via their key .This array is result of the plugin file code which i have purchased.
I have customize this code so many time but the protective array do not let me access into it. Any idea
Array
(
[1251] => WC_Order_Item_Product Object
(
[extra_data:protected] => Array
(
[product_id] => 0
[variation_id] => 0
[quantity] => 1
[tax_class] =>
[subtotal] => 0
[subtotal_tax] => 0
[total] => 0
[total_tax] => 0
[taxes] => Array
(
[subtotal] => Array
(
)
[total] => Array
(
)
)
)
[data:protected] => Array
(
[order_id] => 2040
[name] => Vanilla Pastries
[product_id] => 776
[variation_id] => 0
[quantity] => 5
[tax_class] => gst_18
[subtotal] => 296.6
[subtotal_tax] => 53.388
[total] => 296.6
[total_tax] => 53.388
[taxes] => Array
(
[total] => Array
(
[5] => 26.694
[10] => 26.694
)
[subtotal] => Array
(
[5] => 26.694
[10] => 26.694
)
)
)
[cache_group:protected] => order-items
[meta_type:protected] => order_item
[object_type:protected] => order_item
[id:protected] => 1251
[changes:protected] => Array
(
)
[object_read:protected] => 1
[default_data:protected] => Array
(
[order_id] => 0
[name] =>
[product_id] => 0
[variation_id] => 0
[quantity] => 1
[tax_class] =>
[subtotal] => 0
[subtotal_tax] => 0
[total] => 0
[total_tax] => 0
[taxes] => Array
(
[subtotal] => Array
(
)
[total] => Array
(
)
)
)
[data_store:protected] => WC_Data_Store Object
(
[instance:WC_Data_Store:private] => WC_Order_Item_Product_Data_Store Object
(
[internal_meta_keys:protected] => Array
(
[0] => _order_id
[1] => _name
[2] => _product_id
[3] => _variation_id
[4] => _quantity
[5] => _tax_class
[6] => _subtotal
[7] => _subtotal_tax
[8] => _total
[9] => _total_tax
[10] => _taxes
[11] => _product_id
[12] => _variation_id
[13] => _qty
[14] => _tax_class
[15] => _line_subtotal
[16] => _line_subtotal_tax
[17] => _line_total
[18] => _line_tax
[19] => _line_tax_data
)
[meta_type:protected] => order_item
[object_id_field_for_meta:protected] => order_item_id
)
[stores:WC_Data_Store:private] => Array
(
[coupon] => WC_Coupon_Data_Store_CPT
[customer] => WC_Customer_Data_Store
[customer-download] => WC_Customer_Download_Data_Store
[customer-session] => WC_Customer_Data_Store_Session
[order] => WC_Order_Data_Store_CPT
[order-refund] => WC_Order_Refund_Data_Store_CPT
[order-item] => WC_Order_Item_Data_Store
[order-item-coupon] => WC_Order_Item_Coupon_Data_Store
[order-item-fee] => WC_Order_Item_Fee_Data_Store
[order-item-product] => WC_Order_Item_Product_Data_Store
[order-item-shipping] => WC_Order_Item_Shipping_Data_Store
[order-item-tax] => WC_Order_Item_Tax_Data_Store
[payment-token] => WC_Payment_Token_Data_Store
[product] => WC_Product_Data_Store_CPT
[product-grouped] => WC_Product_Grouped_Data_Store_CPT
[product-variable] => WC_Product_Variable_Data_Store_CPT
[product-variation] => WC_Product_Variation_Data_Store_CPT
[shipping-zone] => WC_Shipping_Zone_Data_Store
)
[current_class_name:WC_Data_Store:private] => WC_Order_Item_Product_Data_Store
[object_type:WC_Data_Store:private] => order-item-product
)
[meta_data:protected] => Array
(
)
)
)
The object you want to access has the type WC_Order_Item_Product. Use its public methods to query it for data or tell it to do something.
This is how OOP works. You don't even need to know how the object properties are named.
I guess
global $post;
echo '<pre>';
print_r($post->data);
echo '</pre>';
echo $post->data->order_id;

How to print complicated multidimensional array through foreach loop in php

I have an Multi Dimensional array like below.
<?php$array = Array ( [ResultIndex] => OB4 [Source] => 3 [IsLCC] => 1 [IsRefundable] => [GSTAllowed] => [AirlineRemark] => this is a test from aditya [Fare] => Array ( [Currency] => INR [BaseFare] => 865 [Tax] => 613 [TaxBreakup] => Array ( [0] => Array ( [key] => YQTax [value] => 0 ) [1] => Array ( [key] => YR [value] => 0 ) [2] => Array ( [key] => PSF [value] => 0 ) [3] => Array ( [key] => UDF [value] => 0 ) [4] => Array ( [key] => JNTax [value] => 52 ) [5] => Array ( [key] => INTax [value] => 0 ) [6] => Array ( [key] => TransactionFee [value] => 0 ) [7] => Array ( [key] => OtherTaxes [value] => 0 ) ) [YQTax] => 0 [AdditionalTxnFeeOfrd] => 0 [AdditionalTxnFeePub] => 0 [PGCharge] => 0 [OtherCharges] => 0 [ChargeBU] => Array ( [0] => Array ( [key] => TBOMARKUP [value] => 0 ) [1] => Array ( [key] => CONVENIENCECHARGE [value] => 0 ) [2] => Array ( [key] => OTHERCHARGE [value] => 0 ) ) [Discount] => 0 [PublishedFare] => 1478 [CommissionEarned] => 22.06 [PLBEarned] => 14.09 [IncentiveEarned] => 14.33 [OfferedFare] => 1427.52 [TdsOnCommission] => 4.41 [TdsOnPLB] => 2.82 [TdsOnIncentive] => 2.87 [ServiceFee] => 0 [TotalBaggageCharges] => 0 [TotalMealCharges] => 0 [TotalSeatCharges] => 0 [TotalSpecialServiceCharges] => 0 ) [FareBreakdown] => Array ( [0] => Array ( [Currency] => INR [PassengerType] => 1 [PassengerCount] => 1 [BaseFare] => 865 [Tax] => 613 [YQTax] => 0 [AdditionalTxnFeeOfrd] => 0 [AdditionalTxnFeePub] => 0 [PGCharge] => 0 ) ) [Segments] => Array ( [0] => Array ( [0] => Array ( [Baggage] => 10 Kg [CabinBaggage] => 7 Kg [TripIndicator] => 1 [SegmentIndicator] => 1 [Airline] => Array ( [AirlineCode] => SG [AirlineName] => SpiceJet [FlightNumber] => 1033 [FareClass] => C [OperatingCarrier] => ) [NoOfSeatAvailable] => 4 [Origin] => Array ( [Airport] => Array ( [AirportCode] => BLR [AirportName] => Hindustan [Terminal] => [CityCode] => BLR [CityName] => Bangalore [CountryCode] => IN [CountryName] => India ) [DepTime] => 2017-10-21T17:40:00 ) [Destination] => Array ( [Airport] => Array ( [AirportCode] => MAA [AirportName] => Chennai [Terminal] => [CityCode] => MAA [CityName] => Chennai [CountryCode] => IN [CountryName] => India ) [ArrTime] => 2017-10-21T18:40:00 ) [Duration] => 60 [GroundTime] => 0 [Mile] => 0 [StopOver] => [StopPoint] => [StopPointArrivalTime] => 2017-10-21T18:40:00 [StopPointDepartureTime] => 2017-10-21T17:40:00 [Craft] => DH8 [Remark] => [IsETicketEligible] => 1 [FlightStatus] => Confirmed [Status] => ) ) ) [LastTicketDate] => [TicketAdvisory] => [FareRules] => Array ( [0] => Array ( [Origin] => BLR [Destination] => MAA [Airline] => SG [FareBasisCode] => CSAVER [FareRuleDetail] => [FareRestriction] => ) ) [AirlineCode] => SG [ValidatingAirline] => SG );?>
how to make it print using foreach loop in php. if any one have idea to rectify this please suggest me

PHP5.3 json_encode is outputting bad json

I am attempting to json_encode an array in php5.3.
json_encode($paperwork_info[0])
The result is bad json. The array is as follows:
[paperwork_guid] => c5bfe512-908d-c513-5a5e-e3a2fbb5548b
[name] => recycle
[sections] => Array
(
[0] => header
[1] => customer
[2] => scope_bullets
[3] => product
[4] => signature
[5] => installer
[6] => order_data
)
[data] => Array
(
[header] => Array
(
[image] => Array
(
[src] => recycle.png
[format] => float:left
)
)
[customer] => Array
(
[f_name] => TEST ONLY
[l_name] => NEIMEIER
[middle_name] => none
[title] => none
[address1] => 28 OEHMAN BLVD
[address2] =>
[address3] =>
[zip] => 14225
[city] => BUFFALO
[state_abbrev] => NY
[email_address] => DALE.NEIMEIER#INSTALLS.COM
[phones] => Array
(
[alt] =>
[cell] =>
[work] =>
[home] => 7165551212
)
)
[scope_bullets] => Array
(
[sku_3001] => Array
(
[bullet_0] => Array
(
[paperwork_bullet_obj_guid] => 2ebefa96-6f6b-069e-e194-245d138b9845
[ordering] => 1
[bullet_text] => This is bullet point #1
[child_level] => 1
[formatting] => Array
(
[0] => Array
(
[start_word] => 2
[num_words] => 0
[tag] => b
[href] =>
)
[1] => Array
(
[start_word] => 2
[num_words] => 1
[tag] => a
[href] => http://www.cnn.com
)
)
)
[bullet_1] => Array
(
[paperwork_bullet_obj_guid] => 734db3f4-01a0-b025-9624-cc52a1845dff
[ordering] => 1
[bullet_text] => Sub-point #1.1
[child_level] => 2
)
[bullet_2] => Array
(
[paperwork_bullet_obj_guid] => ebf5ef02-906e-2005-e499-27eae2edefe9
[ordering] => 1
[bullet_text] => Sub point #1.1.1
[child_level] => 3
)
[bullet_3] => Array
(
[paperwork_bullet_obj_guid] => 447997c1-fd9c-25be-b9bf-39257009fb8b
[ordering] => 1
[bullet_text] => This is bullet point #2
[child_level] => 1
)
[bullet_4] => Array
(
[paperwork_bullet_obj_guid] => 5def2d9c-d322-788c-0afe-d13707004b97
[ordering] => 1
[bullet_text] => Sub point #2.1
[child_level] => 2
)
[bullet_5] => Array
(
[paperwork_bullet_obj_guid] => 84936151-65a3-bcca-951f-b69ff16d34ec
[ordering] => 2
[bullet_text] => Sub point #2.2
[child_level] => 2
)
)
[sku_4405] =>
)
[product] => Array
(
[0] => Array
(
[model] => Paperwork Test abc123
[serial] => 777333
[weight] => 26
[size] =>
[width] =>
[height] => 32
[num_boxes] => 1
[product_name] =>
[sku] =>
[model_number] =>
[part_number] =>
[serial_number] =>
[cat_value] => Best Buy Equipment
[product] =>
[product_type] =>
[product_size] =>
[category] =>
)
)
[signature] => Array
(
[date] => 2016-06-15
[need_customer] => 1
[need_tech] => 1
[need_store] =>
[need_warehouse] =>
)
[installer] => Array
(
[anum] => 45455
[inst_obj_guid] => fb91cf85-381c-b740-e063-775151743da2
[phone] => (317) 519-0481
[tech_f_name] =>
[tech_l_name] =>
[company_name] => ZICO LLC
[email_address] => ZICOLLC#GMAIL.COM
)
[order_data] => Array
(
[assigned_date] => 2016-06-07 22:24:47-04
[purchased_date] => 2016-06-06
[creation_date] => 2016-06-06
[install_date] => 2016-06-10
[install_time] => 19:00:00
[prescheduled_date] => 1969-12-31
[prom_start_time] => 2016-06-10 08:06:00
[prom_end_time] => 2016-06-10 11:06:00
[client_order_id] => 12365478996325412
[job_num] => 4043269
[campaign_wkord_obj_guid] => a9a8cc0b-d7ef-ac0e-df61-dad41c023cb0
[pos_obj_guid] => 096e38c2-55c3-80cf-0778-23f81f1cf2f6
[inst_obj_guid] => fb91cf85-381c-b740-e063-775151743da2
[client_obj_guid] => 247e893a-3ea4-c544-47b2-f23ff16017c6
[ord_obj_guid] => ae55e034-d7d0-5d13-3dd3-22f99df8ead4
[skus] => Array
(
[0] => Array
(
[job_type_obj_guid] => 8234ca2c-e40e-c48c-befc-7ceac5e9de32
[job_sku] => 3001
[client_sku] =>
[sku_name] => Site Survey
)
[1] => Array
(
[job_type_obj_guid] => a3f60c3b-ad3c-d828-9898-fa200edcd3cd
[job_sku] => 4405
[client_sku] =>
[sku_name] => Home Delivery
)
)
[client_specific_data] =>
)
)
)
The resultant json string is as follows:
{"paperwork_guid":"c5bfe512-908d-c513-5a5e-e3a2fbb5548b","name":"recycle","sections":{"0":"header","1"
:"customer","2":"scope_bullets","3":"product","4":"signature","5":"installer","6":"order_data"},"data"
:{"header":{"image":{"src":"recycle.png","format":"float:left"}},"customer":{"f_name":"TEST ONLY","l_name"
:"NEIMEIER","middle_name":"none","title":"none","address1":"28 OEHMAN BLVD","address2":"","address3"
:null,"zip":"14225","city":"BUFFALO","state_abbrev":"NY","email_address":"DALE.NEIMEIER#INSTALLS.COM"
,"phones":{"alt":"","cell":"","work":"","home":"7165551212"}},"scope_bullets":{"sku_3001":{"bullet_0"
:{"paperwork_bullet_obj_guid":"2ebefa96-6f6b-069e-e194-245d138b9845","ordering":"1","bullet_text":"This
is bullet point #1","child_level":"1","formatting":{"0":{"start_word":"2","num_words":"0","tag":"b"
,"href":""},"1":{"start_word":"2","num_words":"1","tag":"a","href":"http:\/\/www.cnn.com"}}},"bullet_1"
:{"paperwork_bullet_obj_guid":"734db3f4-01a0-b025-9624-cc52a1845dff","ordering":"1","bullet_text":"Sub-point
#1.1","child_level":"2"},"bullet_2":{"paperwork_bullet_obj_guid":"ebf5ef02-906e-2005-e499-27eae2edefe9"
,"ordering":"1","bullet_text":"Sub point #1.1.1","child_level":"3"},"bullet_3":{"paperwork_bullet_obj_guid"
:"447997c1-fd9c-25be-b9bf-39257009fb8b","ordering":"1","bullet_text":"This is bullet point #2","child_level"
:"1"},"bullet_4":{"paperwork_bullet_obj_guid":"5def2d9c-d322-788c-0afe-d13707004b97","ordering":"1","bullet_text"
:"Sub point #2.1","child_level":"2"},"bullet_5":{"paperwork_bullet_obj_guid":"84936151-65a3-bcca-951f-b69ff16d34ec"
,"ordering":"2","bullet_text":"Sub point #2.2","child_level":"2"}},"sku_4405":null},"product":{"0":{"model"
:"Paperwork Test abc123","serial":"777333","weight":"26","size":null,"width":null,"height":"32","num_boxes"
:"1","product_name":null,"sku":null,"model_number":null,"part_number":null,"serial_number":null,"cat_value"
:"Best Buy Equipment","product":null,"product_type":null,"product_size":null,"category":null}},"signature"
:{"date":"2016-06-15","need_customer":true,"need_tech":true,"need_store":false,"need_warehouse":false
},"installer":{"anum":"45455","inst_obj_guid":"fb91cf85-381c-b740-e063-775151743da2","phone":"(317) 519-0481"
,"tech_f_name":null,"tech_l_name":null,"company_name":"ZICO LLC","email_address":"ZICOLLC#GMAIL.COM"
},"order_data":{"assigned_date":"2016-06-07 22:24:47-04","purchased_date":"2016-06-06","creation_date"
:"2016-06-06","install_date":"2016-06-10","install_time":"19:00:00","prescheduled_date":"1969-12-31"
,"prom_start_time":"2016-06-10 08:06:00","prom_end_time":"2016-06-10 11:06:00","client_order_id":"12365478996325412"
,"job_num":"4043269","campaign_wkord_obj_guid":"a9a8cc0b-d7ef-ac0e-df61-dad41c023cb0","pos_obj_guid"
:"096e38c2-55c3-80cf-0778-23f81f1cf2f6","inst_obj_guid":"fb91cf85-381c-b740-e063-775151743da2","client_obj_guid"
:"247e893a-3ea4-c544-47b2-f23ff16017c6","ord_obj_guid":"ae55e034-d7d0-5d13-3dd3-22f99df8ead4","skus"
:{"0":{"job_type_obj_guid":"8234ca2c-e40e-c48c-befc-7ceac5e9de32","job_sku":"3001","client_sku":null
,"sku_name":"Site Survey"},"1":{"job_type_obj_guid":"a3f60c3b-ad3c-d828-9898-fa200edcd3cd","job_sku"
:"4405","client_sku":null,"sku_name":"Home Delivery"}},"client_specific_data":""}}}
It appears as though new line feeds are being inserted randomly throughout the josn string. I am not sure if it is just how firebug is outputting the string, but copying-and-pasting the string into jsonLINT produces errors.
Any help would be appreciated.

How to get specific array values from moltin get a product

I just started using moltin and learn to developing it.
In the getting started there is code that to show product
<?php
$product = \Product::Find(['slug' => 'baju']);
?>
documentation link https://moltin.com/getting-started/php
and the result is when I print array
<?php
print_r($product);
?>
It shows like this
Array ( [status] => 1 [result] => Array ( [0] => Array ( [id] => 1207658536885027482 [order] => [created_at] => 2016-03-17 03:08:58 [updated_at] => 2016-03-17 03:08:58 [sku] => baju-1 [title] => baju [slug] => baju [sale_price] => 0 [status] => Array ( [value] => Live [data] => Array ( [key] => 1 [value] => Live ) ) [category] => Array ( [value] => Uncategorized [data] => Array ( [1134518259857490806] => Array ( [id] => 1134518259857490806 [order] => [created_at] => 2015-12-07 05:12:15 [updated_at] => 2015-12-07 05:12:15 [parent] => [slug] => uncategorized [status] => Array ( [value] => Live [data] => Array ( [key] => 1 [value] => Live ) ) [title] => Uncategorized [description] => Products that do not fit into another category ) ) ) [stock_level] => 10 [stock_status] => Array ( [value] => In Stock [data] => Array ( [key] => 1 [value] => In Stock ) ) [description] => baju [requires_shipping] => Array ( [value] => Yes [data] => Array ( [key] => 1 [value] => Yes ) ) [weight] => 0 [height] => 0 [width] => 0 [depth] => 0 [catalog_only] => Array ( [value] => No [data] => Array ( [key] => 0 [value] => No ) ) [tax_band] => Array ( [value] => Default [data] => Array ( [id] => 1134518260142703561 [title] => Default [description] => [rate] => 20 [created_at] => [updated_at] => ) ) [collection] => [brand] => [price] => Array ( [value] => £1.20 [data] => Array ( [formatted] => Array ( [with_tax] => £1.20 [without_tax] => £1.00 [tax] => £0.20 ) [rounded] => Array ( [with_tax] => 1.2 [without_tax] => 1 [tax] => 0.2 ) [raw] => Array ( [with_tax] => 1.2 [without_tax] => 1 [tax] => 0.2 ) ) ) [is_variation] => [modifiers] => Array ( ) [images] => Array ( ) ) ) [pagination] => Array ( [total] => 1 [current] => 1 [limit] => 10 [offset] => 0 [from] => 1 [to] => 1 [offsets] => Array ( [first] => [previous] => [next] => [last] => ) [links] => Array ( [first] => [previous] => [next] => [last] => ) ) ) status = 1
How to get specific array from this list?
I already try
<?php
echo $product[0]['id'];
?>
it didn't work, show error Notice: Undefined offset: 0
you have a multidimensional array under the result key
access it the following way:
$product['result'][0]['id']
Give this a try:
echo $product['result'][0]['id'];

Categories