Is FedEx shipping api works in India Domestic - php

I tried to implement fedex api to calculate the cost of shipping betwnn to zip codes of a country. It is working fine for USA. It is also working from USA to other country(tried for IN and AU). But when I tried it for two zip codes from India or Australia as shipper and recipient address. It is giving below error :-
The transaction returned an Error.
Severity: ERROR
Source: crs
Code: 691
Message: The PurposeOfShipmentType is null, empty or invalid.
LocalizedMessage: The PurposeOfShipmentType is null, empty or invalid.
Don't know what is the issue. I checked the value for PurposeOfShipmentType in wsdl file it is showing below xml code :-
First occurrence
<xs:element name="Purpose" type="ns:PurposeOfShipmentType" minOccurs="0">
<xs:annotation>
<xs:documentation>The reason for the shipment. Note: SOLD is not a valid purpose for a Proforma Invoice.</xs:documentation>
</xs:annotation>
</xs:element>
second occurrence
<xs:simpleType name="PurposeOfShipmentType">
<xs:restriction base="xs:string">
<xs:enumeration value="GIFT"/>
<xs:enumeration value="NOT_SOLD"/>
<xs:enumeration value="PERSONAL_EFFECTS"/>
<xs:enumeration value="REPAIR_AND_RETURN"/>
<xs:enumeration value="SAMPLE"/>
<xs:enumeration value="SOLD"/>
</xs:restriction>
</xs:simpleType>
Don't understanding what should be the value. Below is array which I am sending into $client ->getRates($request) function
$request = Array
(
[WebAuthenticationDetail] => Array
(
[UserCredential] => Array
(
[Key] => *******
[Password] => *******
)
)
[ClientDetail] => Array
(
[AccountNumber] => *****
[MeterNumber] => *****
)
[TransactionDetail] => Array
(
[CustomerTransactionId] => *** Rate Available Services Request using PHP ***
)
[Version] => Array
(
[ServiceId] => crs
[Major] => 16
[Intermediate] => 0
[Minor] => 0
)
[ReturnTransitAndCommit] => 1
[RequestedShipment] => Array
(
[DropoffType] => REGULAR_PICKUP
[ShipTimestamp] => 2014-10-03T11:37:53+02:00
[Shipper] => Array
(
[Address] => Array
(
[StreetLines] => Array
(
[0] => 10 Fed Ex Pkwy
)
[City] => Memphis
[StateOrProvinceCode] =>
[PostalCode] => 110016
[CountryCode] => IN
)
)
[Recipient] => Array
(
[Address] => Array
(
[StreetLines] => Array
(
[0] => 13450 Farmcrest Ct
)
[City] => Herndon
[StateOrProvinceCode] =>
[PostalCode] => 302015
[CountryCode] => IN
)
)
[ShippingChargesPayment] => Array
(
[PaymentType] => SENDER
[Payor] => Array
(
[ResponsibleParty] => Array
(
[AccountNumber] => 510087500
[Contact] =>
[Address] => Array
(
[CountryCode] => IN
)
)
)
)
[PackageCount] => 2
[RequestedPackageLineItems] => Array
(
[0] => Array
(
[SequenceNumber] => 1
[GroupPackageCount] => 1
[Weight] => Array
(
[Value] => 2
[Units] => LB
)
[Dimensions] => Array
(
[Length] => 10
[Width] => 10
[Height] => 3
[Units] => IN
)
)
[1] => Array
(
[SequenceNumber] => 2
[GroupPackageCount] => 1
[Weight] => Array
(
[Value] => 5
[Units] => LB
)
[Dimensions] => Array
(
[Length] => 20
[Width] => 20
[Height] => 10
[Units] => IN
)
)
)
)
)

In order for the India to India domestic shipping to work you need to add in a PurposeOfShipment type to the request. This line is not standard in Magento's code for Fedex shipping. That line will be added into CustomsClearanceDetail header as a child under CommercialInvoice then a line under that is Purposewhich can have any value that PurposeOfShipment has.
Here is an example of the request I used that returned proper shipping estimates for India to India shipping.
'CustomsClearanceDetail' => array(
'CommercialInvoice' => array(
'Purpose' => "SOLD"
)
),

If I am not wrong, Fedex's Test Account doesn't return India specific info. Unless until its certified by the Fedex team and they provide you with the Production Key, you might not get the Rates aggreed for your account. Please do correct me if my understanding is wrong

Related

How to display data in this format from multiple associative array php

I'm trying to find out in a simple way to display a clean like this format
Having a hard time to spread the data in this associative array got this from an API
Array (
[wind] => Array (
[speed] => 5
[direction] => North West
[directionDegrees] => 310
[unit] => KT
)
[visibility] => Array (
[mainVisibility] => 10SM
)
[clouds] => Array (
[0] => Array (
[height] => 25000
[quantity] => few
)
)
[cavok] =>
[remark] => automated station with a precipitation discriminator sea level pressure of 1021.7 HPa hourly temperature of 17.2°C and dew point of -1.1°C
[day] => 6
[time] => 22:52:00
[airport] => Array (
[name] => Hartsfield Jackson Atlanta International Airport
[city] => Atlanta
[country] => Array (
[name] => United States
)
[iata] => ATL
[icao] => KATL
[latitude] => 33.6367
[longitude] => -84.428101
[altitude] => 1026
[timezone] => -5
[dst] => A
)
[message] => KATL 062252Z 31005KT 10SM FEW250 17/M01 A3017 RMK AO2 SLP217 T01721011
[station] => KATL
[temperature] => 17
[dewPoint] => -1
[altimeter] => 1021
[nosig] =>
[auto] =>
[amendment] =>
[nil] =>
[corrected] =>
[cancelled] =>
)
I'm not good at programming as this is our assignment from our school I'm looking at to loop the array but I can't seem to find a way how to do it.
You can use this parser source code and make your own solution on the base
https://github.com/SafranCassiopee/php-metar-decoder
or simple way to get field
$arr = '$yourDataArrayHere$';
$metarRw = $arr['message']
echo 'Metar message '.$metarRw;
$airportName = $arr['airport']['name']
echo 'Airport name '.$airportName;
etc.

Stripe PHP checkout API : Error: Exception: Received unknown parameter: shipping

Im trying to pass shipping details to the checkout session built with:
\Stripe\Checkout\Session::create
But I guet this error:
Breaking news… Error: Exception: Received unknown parameter: shipping (in /myserver/stripe-php/lib/Exception/ApiErrorException.php line 38)
Except from that part the process works fine. Even if I pass "shipping" => null it doesn't give the error.
In the API reference it just shows the "shipping" data array as an optional attributes.
Here is the complete array I'm passing to the session::create
[billing_address_collection] => required
[payment_method_types] => Array
(
[0] => card
)
[line_items] => Array
(
[0] => Array
(
[price_data] => Array
(
[currency] => eur
[product_data] => Array
(
[name] => MEMBER 004: Dark Storm
[description] => sizes:'S-M'
[images] => Array
(
[0] => http://mywebsite.com/image.jpg
)
)
[unit_amount] => 1995
)
[quantity] => 1
)
)
[mode] => payment
[success_url] => http://mywebsite.com/succes/
[cancel_url] => http://mywebsite.com/cancel/
[shipping_address_collection] => Array
(
[0] => ES
)
[shipping] => Array
(
[address] => Array
(
[city] => Barcelona
[country] => ES
[line1] => Street name 81
[line2] => 12
[postal_code] => 09028
[state] => Catalunya
)
[name] => My name
)
[customer_email] => myname#gmail.com
)
You don't pass a shipping address into a Checkout session like this. It is not a parameter of the create endpoint. The shipping attribute of the session object will be populated with the customer shipping address when you use the shipping_address_collection parameter, as I see in your example.
So, you need to remove the invalid shipping parameter and instead inspect that on the result.

How to echo an array value

I am fairly new to PHP and I am writing a PHP function that grabs an object from SOAP.
I found a code to convert it to an array but I can't manage to echo any data.
The array from print_r
Array
(
[Status] => Array
(
[Code] => 0
[Message] => OK
)
[Order] => Array
(
[OrderNumber] => 9334543
[ExternalOrderNumber] =>
[OrderTime] => 2014-07-15T15:20:31+02:00
[PaymentMethod] => invoice
[PaymentStatus] => Paid
[ShipmentMethod] => Mypack
[DeliveryStatus] => Delivered
[Language] => sv
[Customer] => Array
(
[CustomerId] => 13556
[CustomerNumber] =>
[Username] => admin
[Approved] => 1
[OrgNumber] => 9309138445
[Company] =>
[VatNumber] =>
[FirstName] => Jane
[LastName] => Doe
[Address] => Gatan
[Address2] =>
[Zip] => 1230
[City] => Staden
[Country] => Sweden
[CountryCode] => SE
[PhoneDay] => 84848474
[PhoneNight] =>
[PhoneMobile] =>
[Email] => mail#msn.com
[NewsLetter] =>
[OrgType] => person
[OtherDelivAddress] =>
[DelivName] =>
[DelivAddress] =>
[DelivAddress2] =>
[DelivZip] =>
[DelivCity] =>
[DelivCountry] =>
[DelivCountryCode] =>
)
[Comment] =>
[Notes] => 9063025471 UK/MA
[CurrencyCode] => SEK
[ExchangeRate] => 1
[LanguagePath] => se
[FreightWithoutVat] => 0
[FreightWithVat] => 0
[FreightVatPercentage] => 25
[PayoptionFeeWithoutVat] => 0
[PayoptionFeeWithVat] => 0
[PayoptionFeeVatPercentage] => 25
[CodWithoutVat] => 0
[CodWithVat] => 0
[CodVatPercentage] => 0
[DiscountWithoutVat] => 0
[DiscountWithVat] => 0
[DiscountVat] => 0
[TotalWithoutVat] => 4388
[TotalWithVat] => 5485
[TotalVat] => 1097
[PayWithoutVat] =>
[AffiliateCode] =>
[AffiliateName] =>
[OrderField] => Array
(
[0] => Array
(
[Name] => external_ref
[Value] => 43445
)
[1] => Array
(
[Name] => webshopid
[Value] => 423
)
[2] => Array
(
[Name] => webshopname
[Value] => Manuell
)
)
)
)
Non working code
echo $array[1][0]
I have tried different combos of indexes. I know how to return the values from the soap object but if I could do it this way it would be easier. It should work shouldn't it?
$array[1] is the second index of the array. the key of this array us "Status", this array contains a code and message
i assume you want to echo the message, you can do that with the following
echo $array[1]["Status"]["Message"];
You should use $array['Status']['Code'] , $array['Status']['Message'], $array['Order']['OrderNumber'], $array['Order']['Customer']['CustomerId'] and so on to display your data. It's an associative array so you need to use string keys and not numbers
try
$array['Order']['Customer']['LastName']
is my best guess without losing my sanity in that one line.
But for us to be sure please post the print_r($array) output
There are some way I always do this:
print_r($array);
And the other way is
$array[0]['Order']['LastName']
Try to access the arrays elements with the string keys, not the integer ones you are using:
echo $array['Order']['Customer']['Address'];
Another way you could see what is going on is by iterating through the array, and print out the keys and values:
foreach ($array as $key => $value)
echo "Key=$key value=$value<br>";

Unable to read json file and assign value to local varibales

I am trying to read json file using php code listed below but I am unable to assign these values to local variables.
Can someone help me explain what am I doing wrong?
<?php
$file = "http://localsurch.com/deals2.txt";
$response = json_decode(file_get_contents($file), true);
//print_r($response);
foreach ($response as $mydeal)
{
$category = $mydeal->category->name;
$title = $mydeal->websiteTitle;
$finePrint = $mydeal->finePrint;
$imageURL = $mydeal->imageURL;
$merchant = $mydeal->merchant->displayName;
$streetaddress1 = $mydeal->redemptionLocations->addressStreet1;
}
?>
Array
(
[date] => 28-Jun-14 5.46.34.871 PM
[deals] => Array
(
[0] => Array
(
[category] => Array
(
[name] => Repair & Services
[path] => Array
(
[0] => Automotive
[1] => Repair & Services
)
)
[websiteTitle] => Three Full-Service Oil Changes, Tire Rotations, and More
[description] => <p>Since 1988, Planet Super Saver has been saving members thousands of dollars on their automotive maintenance and repairs nationwide. Their goal is to unite you with trustworthy, top-notch service centers in your area at a huge savings. The service center's goal is to introduce themselves to you with the hopes you'll become a long-term customer through their honesty and professional service you can depend on.</p>
$30 ($179 value) for an auto maintenance package
Includes three complete oil changes, two tire rotations, diagnostics, and inspections
Preventative care can mean big savings down the road
Efficient, friendly professionals get the job done right
[finePrint] => <ul><li><b>Online redemption required at planetsupersaver.com; a punch card will be mailed within 5 business days</b></li>
Punch card is valid for 1 year from date of redemption
Appointments are required and subject to availability; for more information call Planet Super Saver customer support at 480-921-8282
Merchant cancellation/re-scheduling policy of 24 hours applies; voucher subject to forfeiture
Punch Card is transferable between vehicles owned by the same person or family and may be used over multiple visits
Valid only for location selected at time of purchase
Cannot be combined with any other offer or promotion
Buy as many as you like; send as many as you like as gifts
Complete oil change includes up to 5 quarts of oil, lube, and filter. Additional quarts and synthetic or diesel oil are available for an extra fee
Some services calling for refrigerant and coolant will require an extra fee
$4.50 disposal fee, tax, and gratuity are not included
Available for use immediately after purchase
PROMOTIONAL VALUE EXPIRES 180 DAYS FROM THE PURCHASE DATE
PAID VALUE EXPIRES 5 YEARS FROM THE PURCHASE DATE
[asin] => B00LBL758W
[imageURL] => /images/G/01/ember/deals/c617b334d1893eae7cbc94301fab538c5880b3e24f95669d10ad118fe38eaadc
[merchant] => Array
(
[displayName] => Planet Super Saver
)
[offerEndTime] => 1411714800000
[options] => Array
(
[0] => Array
(
[title] => 7111 Sudley Rd Location - Auto Maintenance Package (Three Complete Oil Changes, Two Tire Rotations, Diagnostics, and Inspections)
[value] => Array
(
[currencyCode] => USD
[amountInBaseUnit] => 17900
)
[price] => Array
(
[currencyCode] => USD
[amountInBaseUnit] => 3000
)
)
[1] => Array
(
[title] => 7892 Sudley Rd Location - Auto Maintenance Package (Three Complete Oil Changes, Two Tire Rotations, Diagnostics, and Inspections)
[value] => Array
(
[currencyCode] => USD
[amountInBaseUnit] => 17900
)
[price] => Array
(
[currencyCode] => USD
[amountInBaseUnit] => 3000
)
)
)
[geographies] => Array
(
[0] => Array
(
[seoName] => northern-virginia
[displayName] => Northern Virginia
)
[1] => Array
(
[seoName] => montgomery-county
[displayName] => Montgomery County
)
[2] => Array
(
[seoName] => washington-dc
[displayName] => Washington, D.C.
)
[3] => Array
(
[seoName] => arlington-alexandria
[displayName] => Arlington / Alexandria
)
)
[redemptionLocations] => Array
(
[0] => Array
(
[addressPostalCode] => 20109
[addressStateOrProvince] => VA
[addressStreet1] => Battlefield BP
[addressStreet2] => 7111 Sudley Rd
[geography] => Array
(
[displayName] => Northern Virginia
)
[latitude] => 38.799067
[longitude] => -77.518125
[phoneNumber] => 480-921-8282
)
)
)
[1] => Array
(
[category] => Array
(
[name] => Indian
[path] => Array
(
[0] => Restaurants
[1] => Indian
)
)
[websiteTitle] => $15 to Spend on Food and Drink
[description] => <p>Dine on savory Pakistani and Indian cuisine at this eatery, where everything is Halal. Enjoy kabobs, curries, and Biryani&#8212but don't miss out on their house specialty, The Karahi, with chicken, beef, goat, lamb, fish or paneer:</p>
$7 for $15 to spend on food and nonalcoholic drinks
Varied menu features wraps, salads, curry, and grill favorites
We recommend the charcoal chicken combo, which includes warm naan and tasty sides
Charcoal Chicken's Website | Facebook
[finePrint] => <ul><li>Limit 2 per customer </li>
Limit 1 per table per visit
Valid only for dine-in or takeout
Excludes alcohol
Excludes holidays
Entire value must be used in a single visit
Available for use beginning the day after purchase
PROMOTIONAL VALUE EXPIRES FOLLOWING OCTOBER 12, 2014
PAID VALUE EXPIRES 5 YEARS FROM THE PURCHASE DATE
[asin] => B00L1OHHZK
[imageURL] => /images/G/01/ember/deals/ab799f011c6041f1d99b776d4e11f8b7e0e3c2422a6fd1ccae595d5c70c2937c
[merchant] => Array
(
[displayName] => Charcoal Chicken
)
[offerEndTime] => 1405148400000
[options] => Array
(
[0] => Array
(
[title] => $15 to Spend on Food and Nonalcoholic Drinks
[value] => Array
(
[currencyCode] => USD
[amountInBaseUnit] => 1500
)
[price] => Array
(
[currencyCode] => USD
[amountInBaseUnit] => 700
)
)
)
[geographies] => Array
(
[0] => Array
(
[seoName] => northern-virginia
[displayName] => Northern Virginia
)
)
[redemptionLocations] => Array
(
[0] => Array
(
[addressPostalCode] => 20151
[addressStateOrProvince] => VA
[addressStreet1] => 13969 Metrotech Drive
[addressStreet2] =>
[geography] => Array
(
[displayName] => Northern Virginia
)
[latitude] => 38.895558
[longitude] => -77.4283257
[phoneNumber] => 703-953-3700
)
)
)
[2] => Array
(
[category] => Array
(
[name] => Watches
[path] => Array
(
[0] => Retail Products
[1] => Watches
)
)
[websiteTitle] => Watch-Battery Replacement or Watch Repair
[description] => <p>Fashion Time is the premier spot in Maryland and Virginia to buy and repair all your timepieces. Whether you're in the market for a grandfather clock or a new stem for your watch, these time experts can help. </p><ul><li>$6 ($13 value) for a battery replacement for a non-Swiss watch</li><li>$19 ($40 value) for a battery replacement for a Swiss watch</li><li>$20 for $40 to spend on watches or watch repair</li><li>Old-fashioned craftsmen and technicians are experts in timepieces </li></ul><p>Fashion Time on Facebook</p>
[finePrint] => <p></p><ul><li>Buy as many as you like; send as many as you like as gifts<br></li><li>Limit 1 voucher per customer per visit<br></li><li>Valid only for option purchased<br></li><li>Excludes sale items<br></li><li>Valid only for in-store purchases<br></li><li>Cannot be combined with any other offers or promotions<br></li><li>Entire value per voucher must be used in a single visit </li><li>Available for use beginning the day after purchase</li><li>PROMOTIONAL VALUE EXPIRES 180 DAYS FROM THE PURCHASE DATE</li><li>PAID VALUE EXPIRES 5 YEARS FROM THE PURCHASE DATE</li></ul><p></p>
[asin] => B00KO8KOMM
[imageURL] => /images/G/01/ember/deals/7d648552caa12945ae14ee4554d255b21e1ae7739fce1f4be07ebf83e495e4
[merchant] => Array
(
[displayName] => Fashion Time
)
[offerEndTime] => 1411542000000
[options] => Array
(
[0] => Array
(
[title] => Battery Replacement for a Non-Swiss Watch
[value] => Array
(
[currencyCode] => USD
[amountInBaseUnit] => 1300
)
[price] => Array
(
[currencyCode] => USD
[amountInBaseUnit] => 600
)
)
[1] => Array
(
[title] => Battery Replacement for a Swiss Watch
[value] => Array
(
[currencyCode] => USD
[amountInBaseUnit] => 4000
)
[price] => Array
(
[currencyCode] => USD
[amountInBaseUnit] => 1900
)
)
)
[geographies] => Array
(
[0] => Array
(
[seoName] => northern-virginia
[displayName] => Northern Virginia
)
[1] => Array
(
[seoName] => montgomery-county
[displayName] => Montgomery County
)
)
[redemptionLocations] => Array
(
[0] => Array
(
[addressPostalCode] => 20166
[addressStateOrProvince] => VA
[addressStreet1] => 2110 D Dulles Town Ctr
[addressStreet2] =>
[geography] => Array
(
[displayName] => Northern Virginia
)
[latitude] => 39.035249
[longitude] => -77.42987
[phoneNumber] => 571-434-8875
)
[1] => Array
(
[addressPostalCode] => 22102
[addressStateOrProvince] => VA
[addressStreet1] => 1961 Chain Bridge Rd
[addressStreet2] =>
[geography] => Array
(
[displayName] => Northern Virginia
)
[latitude] => 38.91971111
[longitude] => -77.2259265
[phoneNumber] => 703-893-9005
)
)
)
)
)
You're telling json_decode() to give you an array but then you try to access its values like an object. Either return an object...
$response = json_decode(file_get_contents($file));
...or access those values using array syntax:
foreach ($response as $mydeal)
{
$category = $mydeal['category']['name'];
$title = $mydeal['websiteTitle'];
$finePrint = $mydeal['finePrint'];
$imageURL = $mydeal['imageURL'];
$merchant = $mydeal->merchant['displayName'];
$streetaddress1 = $mydeal['redemptionLocations']['addressStreet1'];
}

Retrieve a value from a SimpleXML object

Excuse me for asking such a "noob" question, but I have been trying to find a simple example of how to loop through my returned xml for the past few hours and I'm getting no where. I just want to be able to cycle through the xml and pull the 'Amount' attribute and 'AmazonOrderId' attribute for each Order. I don't know how to loop, nor how to grab the pertinent data.
SimpleXMLElement Object
(
[ListOrdersResult] => SimpleXMLElement Object
(
[Orders] => SimpleXMLElement Object
(
[Order] => Array
(
[0] => SimpleXMLElement Object
(
[ShipmentServiceLevelCategory] => SecondDay
[OrderTotal] => SimpleXMLElement Object
(
[Amount] => 5.93
[CurrencyCode] => USD
)
[SellerOrderId] => 107-1261608-7067458
[FulfillmentChannel] => AFN
[BuyerEmail] => 5qhs64ktb88pdsj#marketplace.amazon.com
[OrderStatus] => Shipped
[BuyerName] => Derrick D Vann
[ShipServiceLevel] => SecondDay
[LastUpdateDate] => 2013-03-13T02:20:31Z
[PurchaseDate] => 2013-03-11T06:14:40Z
[NumberOfItemsUnshipped] => 0
[MarketplaceId] => ATVPDKIKX0DER
[SalesChannel] => Amazon.com
[ShippingAddress] => SimpleXMLElement Object
(
[Phone] => 202 746-2567
[PostalCode] => 20001-4040
[Name] => Derrick Vann
[CountryCode] => US
[StateOrRegion] => DC
[AddressLine1] => 2120 Vermont Ave NW Apt 117
[City] => Washington
)
[NumberOfItemsShipped] => 1
[AmazonOrderId] => 107-1261608-7067458
[PaymentMethod] => Other
)
[1] => SimpleXMLElement Object
(
[ShipmentServiceLevelCategory] => Expedited
[OrderTotal] => SimpleXMLElement Object
(
[Amount] => 23.30
[CurrencyCode] => USD
)
[SellerOrderId] => 104-9066827-4446667
[FulfillmentChannel] => AFN
[BuyerEmail] => 6kfc88nrsnm83fq#marketplace.amazon.com
[OrderStatus] => Shipped
[BuyerName] => Quoc Bui
[ShipServiceLevel] => Expedited
[LastUpdateDate] => 2013-03-13T09:34:26Z
[PurchaseDate] => 2013-03-11T08:07:13Z
[NumberOfItemsUnshipped] => 0
[MarketplaceId] => ATVPDKIKX0DER
[SalesChannel] => Amazon.com
[ShippingAddress] => SimpleXMLElement Object
(
[Phone] => (02) 9560 3639
[PostalCode] => 2204
[Name] => Quoc Minh Bui
[CountryCode] => AU
[StateOrRegion] => New South Wales
[AddressLine1] => 19 Centennial St
[City] => Marrickville
)
[NumberOfItemsShipped] => 1
[AmazonOrderId] => 104-9066827-4446667
[PaymentMethod] => Other
)
...
SimpleXML is just great, isn't it?
foreach ($xml->ListOrdersResult->Orders->Order as $order) {
$amazonOrderId = (string) $order->AmazonOrderId;
$orderTotal = (string) $order->OrderTotal->Amount;
}
I use (string) type casting because you'd get SimpleXMLElements back for those scalar values otherwise.
pull the 'Amount' attribute and 'AmazonOrderId' attribute for each Order.
If I take you word-by-word, then this is what you're looking for:
$allThoseAttributes = $xml->xpath('//Order/#Amount|//Order/#AmazonOrderId');
However, more likely you're looking for:
$orders = [];
foreach ($xml->xpath('//Order') as $order) {
$orders[] = [
'amazon' => (string) $order->AmazonOrderId
'total' => (string) $order->OrderTotal->Amount;
];
}
because what you call attributes are infact elements. If you want to learn more about XML and Xpath, this is a good read: XPath

Categories