Array Help Needed



Hi,

I have an array of ORDER DETAILS (see below). I would like to pull out of
the order Object array all the [products] in the order that have the
[attributes] [option] equal to 'Subscription' (this example the order has 2
subscription products and 2 products that are not subscriptions, but other
orders may have more or less), and put them into a new array with the
following structure:

subscription Object Array

[tax]
[tax_description]
[final_price]
// below from attributes array
[option]
[value]
[option_id]
[value_id]
[prefix]
[price]

Can someone explain how this is done? Thank you for your help.

// ORDER DETAILS Array


ORDER DETAILS:

order Object
(
[info] => Array
(
[order_status] => 1
[currency] => USD
[currency_value] => 1.00000000
[payment_method] => Credit Card
[payment_module_code] => authorizenet
[coupon_code] =>
[shipping_method] => Flat Rate (Best Way)
[shipping_module_code] => flat_flat
[shipping_cost] => 5.00
[subtotal] => 36.84
[tax] => 0
[total] => 41.84
[tax_groups] => Array
(
[Sales Tax] => 0
)

[comments] => THIS IS A TEST ORDER #7
[ip_address] => 24.19.197.137 - 24.19.197.137
)

[totals] => Array
(
)

[products] => Array
(
[0] => Array
(
[qty] => 1
[name] => Change is Coming News Report (Subscription)
[model] => 4212-70-219
[tax] => 0
[tax_description] => Sales Tax
[price] => 5.9500
[final_price] => 5.95
[onetime_charges] => 0
[weight] => 0
[products_priced_by_attribute] => 0
[product_is_free] => 0
[products_discount_type] => 0
[products_discount_type_from] => 0
[id] => 73:f71dd7cced862b1ef518cdf9eaf0fdd5
[rowClass] => rowEven
[attributes] => Array
(
[0] => Array
(
[option] => Subscription
[value] => Yearly
[option_id] => 1
[value_id] => 1
[prefix] => +
[price] => 0.0000
)

)

)

[1] => Array
(
[qty] => 1
[name] => News Report (Subscription)
[model] =>
[tax] => 0
[tax_description] => Sales Tax
[price] => 10.9900
[final_price] => 10.99
[onetime_charges] => 0
[weight] => 0
[products_priced_by_attribute] => 0
[product_is_free] => 0
[products_discount_type] => 0
[products_discount_type_from] => 0
[id] => 185:b2e375e0be1b2613924a38d29754c259
[rowClass] => rowOdd
[attributes] => Array
(
[0] => Array
(
[option] => Subscription
[value] => Monthly
[option_id] => 4
[value_id] => 5
[prefix] => +
[price] => 0.0000
)

)

)

[2] => Array
(
[qty] => 1
[name] => A Guide to South American Culture
[model] => 4200-70-60
[tax] => 0
[tax_description] => Sales Tax
[price] => 9.9500
[final_price] => 9.95
[onetime_charges] => 0
[weight] => 1
[products_priced_by_attribute] => 0
[product_is_free] => 0
[products_discount_type] => 0
[products_discount_type_from] => 0
[id] => 6
[rowClass] => rowEven
)

[3] => Array
(
[qty] => 1
[name] => Building Values Within Society
[model] => 4200-70-64
[tax] => 0
[tax_description] => Sales Tax
[price] => 9.9500
[final_price] => 9.95
[onetime_charges] => 0
[weight] => 1
[products_priced_by_attribute] => 0
[product_is_free] => 0
[products_discount_type] => 0
[products_discount_type_from] => 0
[id] => 3
[rowClass] => rowOdd
)

)

[customer] => Array
(
[firstname] => John
[lastname] => Doe
[company] =>
[street_address] => 123 4th Street
[suburb] =>
[city] => Seattle
[postcode] => 98059
[state] => Washington
[zone_id] => 62
[country] => Array
(
[id] => 223
[title] => United States
[iso_code_2] => US
[iso_code_3] => USA
)

[format_id] => 2
[telephone] => 222 333-4444
[email_address] => qwerty@xxxxxxxx
)

[delivery] => Array
(
[firstname] => John
[lastname] => Doe
[company] =>
[street_address] => 123 4th Street
[suburb] =>
[city] => Seattle
[postcode] => 98059
[state] => Washington
[zone_id] => 62
[country] => Array
(
[id] => 223
[title] => United States
[iso_code_2] => US
[iso_code_3] => USA
)

[country_id] => 223
[format_id] => 2
)

[content_type] => physical
[email_low_stock] =>
[products_ordered_attributes] =>
[products_ordered] =>
[products_ordered_email] =>
[attachArray] =>
[observers] => Array
(
)

[billing] => Array
(
[firstname] => John
[lastname] => Doe
[company] =>
[street_address] => 123 4th Street
[suburb] =>
[city] => Seattle
[postcode] => 98059
[state] => Washington
[zone_id] => 62
[country] => Array
(
[id] => 223
[title] => United States
[iso_code_2] => US
[iso_code_3] => USA
)

[country_id] => 223
[format_id] => 2
)

)


.



Relevant Pages

  • Re: Array Help Desired
    ... still having trouble returning an array. ... foreach ... Here is the print_rfor my $order Object ... subscription Object Array ...
    (comp.lang.php)
  • Re: Array Help Desired
    ... I have an array of ORDER DETAILS. ... the order Object array all the in the order that have the ... subscription Object Array ... orders is an object, not an array, so this foreach would fail. ...
    (comp.lang.php)
  • Re: Array Help Desired
    ... I have an array of ORDER DETAILS. ... the order Object array all the in the order that have the ... subscription Object Array ...
    (comp.lang.php)
  • Re: Array Help Desired
    ... I have an array of ORDER DETAILS. ... the order Object array all the in the order that have the ... subscription Object Array ... orders is an object, not an array, so this foreach would fail. ...
    (comp.lang.php)
  • Array Help Desired
    ... I have an array of ORDER DETAILS. ... the order Object array all the in the order that have the ... subscription products and 2 products that are not subscriptions, ...
    (comp.lang.php)