-3

我有从会话中获取的数组,这是数组的 print_r

print_r($_SESSION['wpsc_cart']);



wpsc_cart Object ( [delivery_country] => AU [selected_country] => AU [delivery_region] => [selected_region] => [selected_shipping_method] => [selected_shipping_option] => [selected_shipping_amount] => [coupon] => [tax_percentage] => 0 [unique_id] => 98b4abe821cda949c0a6feedcd51487134765124 [errors] => Array ( ) [total_tax] => [base_shipping] => [total_item_shipping] => [total_shipping] => [subtotal] => 105 [total_price] => [uses_shipping] => [is_incomplete] => 1 [cart_items] => Array ( [0] => wpsc_cart_item Object ( [cart] => wpsc_cart Object *RECURSION* [product_id] => 1675 [variation_values] => [product_variations] => [variation_data] => [quantity] => 1 [provided_price] => [product_name] => Gift Card [category_list] => Array ( [0] => 30 ) [category_id_list] => Array ( [0] => 13 ) [unit_price] => 30 [total_price] => 30 [taxable_price] => 0 [tax] => 0 [weight] => 0 [shipping] => 0 [sku] => [product_url] => http://www.activefeet.com.au/products-page/30/gift-card [image_id] => [thumbnail_image] => [custom_tax_rate] => [meta] => Array ( [0] => Array ( [wpec_taxes_taxable_amount] => [external_link] => [external_link_text] => [external_link_target] => [weight] => 0 [weight_unit] => pound [dimensions] => Array ( [height] => 0 [height_unit] => in [width] => 0 [width_unit] => in [length] => 0 [length_unit] => in ) [shipping] => Array ( [local] => 5 [international] => 5 ) [no_shipping] => 1 [merchant_notes] => [engraved] => 0 [can_have_uploaded_image] => 0 [enable_comments] => [unpublish_when_none_left] => 0 [quantity_limited] => 0 [special] => 0 [display_weight_as] => pound [table_rate_price] => Array ( [quantity] => Array ( ) [table_price] => Array ( ) ) [google_prohibited] => 0 ) ) [is_donation] => 0 [apply_tax] => 1 [priceandstock_id] => 0 [custom_message] => [custom_file] => [comment] => [time_requested] => [file_data] => [is_customisable] => [stock] => [uses_shipping] => 0 [has_limited_stock] => [file_id] => [is_downloadable] => ) [1] => wpsc_cart_item Object ( [cart] => wpsc_cart Object *RECURSION* [product_id] => 1679 [variation_values] => [product_variations] => [variation_data] => [quantity] => 1 [provided_price] => [product_name] => Gift Card [category_list] => Array ( [0] => 76 ) [category_id_list] => Array ( [0] => 15 ) [unit_price] => 75 [total_price] => 75 [taxable_price] => 0 [tax] => 0 [weight] => 0 [shipping] => 0 [sku] => [product_url] => http://www.activefeet.com.au/products-page/76/gift-card-3 [image_id] => [thumbnail_image] => [custom_tax_rate] => [meta] => Array ( [0] => Array ( [wpec_taxes_taxable_amount] => [external_link] => [external_link_text] => [external_link_target] => [weight] => 0 [weight_unit] => pound [dimensions] => Array ( [height] => 0 [height_unit] => in [width] => 0 [width_unit] => in [length] => 0 [length_unit] => in ) [shipping] => Array ( [local] => 0 [international] => 0 ) [merchant_notes] => [engraved] => 0 [can_have_uploaded_image] => 0 [enable_comments] => [unpublish_when_none_left] => 0 [no_shipping] => 0 [quantity_limited] => 0 [special] => 0 [display_weight_as] => pound [table_rate_price] => Array ( [quantity] => Array ( ) [table_price] => Array ( ) ) [google_prohibited] => 0 ) ) [is_donation] => 0 [apply_tax] => 1 [priceandstock_id] => 0 [custom_message] => [custom_file] => [comment] => [time_requested] => [file_data] => [is_customisable] => [stock] => [uses_shipping] => 1 [has_limited_stock] => [file_id] => [is_downloadable] => ) ) [cart_item] => wpsc_cart_item Object ( [cart] => wpsc_cart Object *RECURSION* [product_id] => 1675 [variation_values] => [product_variations] => [variation_data] => [quantity] => 1 [provided_price] => [product_name] => Gift Card [category_list] => Array ( [0] => 30 ) [category_id_list] => Array ( [0] => 13 ) [unit_price] => 30 [total_price] => 30 [taxable_price] => 0 [tax] => 0 [weight] => 0 [shipping] => 0 [sku] => [product_url] => http://www.activefeet.com.au/products-page/30/gift-card [image_id] => [thumbnail_image] => [custom_tax_rate] => [meta] => Array ( [0] => Array ( [wpec_taxes_taxable_amount] => [external_link] => [external_link_text] => [external_link_target] => [weight] => 0 [weight_unit] => pound [dimensions] => Array ( [height] => 0 [height_unit] => in [width] => 0 [width_unit] => in [length] => 0 [length_unit] => in ) [shipping] => Array ( [local] => 5 [international] => 5 ) [no_shipping] => 1 [merchant_notes] => [engraved] => 0 [can_have_uploaded_image] => 0 [enable_comments] => [unpublish_when_none_left] => 0 [quantity_limited] => 0 [special] => 0 [display_weight_as] => pound [table_rate_price] => Array ( [quantity] => Array ( ) [table_price] => Array ( ) ) [google_prohibited] => 0 ) ) [is_donation] => 0 [apply_tax] => 1 [priceandstock_id] => 0 [custom_message] => [custom_file] => [comment] => [time_requested] => [file_data] => [is_customisable] => [stock] => [uses_shipping] => 0 [has_limited_stock] => [file_id] => [is_downloadable] => ) [cart_item_count] => 2 [current_cart_item] => -1 [in_the_loop] => [shipping_methods] => [shipping_method] => [shipping_method_count] => 1 [current_shipping_method] => -1 [in_the_method_loop] => [shipping_quotes] => [shipping_quote] => [shipping_quote_count] => 0 [current_shipping_quote] => -1 [in_the_quote_loop] => [coupons_name] => [coupons_amount] => 0 [shipping_option] => ) 

我需要从此数组中获取项目

 [no_shipping] => 1

 [no_shipping] => 0

使用一些foreach或..我对此一无所知,请帮助我..谢谢

4

1 回答 1

0

我直接使用对象,比将会话转换为对象容易

 foreach($wpsc_cart->cart_items as $i => $Item) {       
           $cv=$Item->meta;  

          foreach($cv as $vc=>$it){           
              echo $it['no_shipping'];
    }
}
于 2012-08-16T10:53:21.430 回答