how to print multiple array in joomla - php

This is the cart array in the Virtuemart 2.0.22a ..
this is stored in "$cart"
how to print [virtuemart_product_id] => 21 at 4.
$cart=
VirtueMartCart Object
(
[products] => Array
(
[21] => stdClass Object
(
[virtuemart_manufacturer_id] => Array
(
)
[slug] => stylish-shirt
[published] => 1
[virtuemart_product_price] =>
[virtuemart_product_id] => 21
[virtuemart_shoppergroup_id] =>
[product_price] => 450.00000
[override] => 0
[product_override_price] => 0.00000
[product_tax_id] => -1
[product_discount_id] => -1
[product_currency] => 68
[virtuemart_vendor_id] => 1
[product_parent_id] => 0
[product_sku] =>
[product_name] => Stylish Shirt
[product_s_desc] =>
[product_weight] =>
[product_weight_uom] => KG
[product_length] =>
[product_width] =>
[product_height] =>
[product_lwh_uom] => M
[product_in_stock] => 0
[product_ordered] => 0
[product_sales] => 0
[product_unit] => KG
[product_packaging] =>
[min_order_level] =>
[max_order_level] =>
[virtuemart_media_id] => Array
(
[0] => 21
)
[step_order_level] =>
[image] => VmImage Object
(
[media_attributes] => 0
[setRole] =>
[file_name] => 3
[file_extension] => jpg
[virtuemart_media_id] => 21
[_foldersToTest:VmMediaHandler:private] => Array
(
[0] => E:\wamp\www\ecomm\images\stories\virtuemart\product\
[1] => E:\wamp\www\ecomm\images\stories\virtuemart\product\resized\
)
[_actions:VmMediaHandler:private] => Array
(
)
[_mLocation:VmMediaHandler:private] => Array
(
)
[_hidden:VmMediaHandler:private] => Array
(
)
[theme_url] => http://localhost/ecomm/components/com_virtuemart/
[virtuemart_vendor_id] => 1
[file_title] => 3.jpg
[file_description] =>
[file_meta] =>
[file_mimetype] => image/jpeg
[file_type] => product
[file_url] => images/stories/virtuemart/product/3.jpg
[file_url_thumb] => images/stories/virtuemart/product/resized/3_90x90.jpg
[published] => 1
[file_is_downloadable] => 0
[file_is_forSale] => 0
[file_is_product_image] => 0
[shared] => 0
[file_params] =>
[file_lang] =>
[_translatable] =>
[_tablePreFix] =>
[created_on] => 2013-08-12 12:32:19
[created_by] => 572
[modified_on] => 2013-08-12 12:38:50
[modified_by] => 572
[file_url_folder] => images/stories/virtuemart/product/
[file_path_folder] => images\stories\virtuemart\product\
[file_url_folder_thumb] => images/stories/virtuemart/product/resized/
[media_role] => file_is_displayable
[file_name_thumb] => 3_90x90
)
[categories] => Array
(
[0] => 6
)
[virtuemart_category_id] => 6
[category_name] => Shirts
[link] => /ecomm/index.php/component/virtuemart/shirts/stylish-shirt-detail?Itemid=0
[packaging] =>
[quantity] => 1
)
)
[_inCheckOut] =>
[_dataValidated] =>
[_blockConfirm] =>
[_confirmDone] =>
[_redirect] =>
[_redirect_disabled] =>
[_lastError] =>
[vendorId] => 1
[lastVisitedCategoryId] => 0
[virtuemart_shipmentmethod_id] => 0
[virtuemart_paymentmethod_id] => 1
[automaticSelectedShipment] => 1
[automaticSelectedPayment] => 1
[BT] => 0
[ST] => 0
[tosAccepted] =>
[customer_comment] =>
[couponCode] =>
[order_language] =>
[cartData] => Array
(
[VatTax] => Array
(
)
[duty] => 1
[payment] => 0
[paymentName] =>

Finally i got the output.. after lot of struggles
foreach($cart->products as $cur)
{
echo $cur->virtuemart_product_id;
}

Related

Dynamically pulling flexible content sub block titles in admin

I am working on a project where I am creating a plugin that works on top of ACF 5. I have made it pretty far but right now I am stuck on this issue:
I have a flexible content field setup that has multiple sub layouts. I need to add conditional logic to each of these layouts based on there names. Right now I am doing it by getting their field ID:
$field_id = $field['ID'];
$field being my main array.
Then doing a simple php switch statement just setting a variable I can then check for when doing conditional logic:
$layout = '';
switch ($field_id) {
case "19":
$layout = "html";
break;
case "28":
$layout = "grid";
break;
}
Then I just check to see what $layout is set to and go from there. While this does work I do not like the fact that I have to update the IDs every time I move development environments or re-create a layout.
Does anyone know how a better way to do this?
Array dump for single $field:
Array
(
[padding_top] => 0
[padding_right] => 0
[padding_bottom] => 0
[padding_left] => 0
[background_style] => default
[section_width] => default
[ID] => 28
[key] => field_5876368ea05b4
[label] => Section Styles
[name] => acf[field_5873e9fdacab1][0][field_5876368ea05b4]
[prefix] => acf[field_5873e9fdacab1][0]
[type] => section_styles
[value] => Array
(
[section_width] => default
[margin_top] =>
[margin_right] =>
[margin_bottom] =>
[margin_left] =>
[padding_top] =>
[padding_right] =>
[padding_bottom] =>
[padding_left] =>
[background_color] =>
[background_image] =>
[background_style] => default
[background_position_1] => top
[background_position_2] => left
)
[menu_order] => 0
[instructions] =>
[required] => 0
[id] => acf-field_5873e9fdacab1-0-field_5876368ea05b4
[class] =>
[conditional_logic] => 0
[parent] => 14
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] => section_styles
[_prepare] => 1
[_valid] => 1
[parent_layout] => 58763683a05b3
[margin_top] =>
[margin_right] =>
[margin_bottom] =>
[margin_left] =>
[background_color] =>
[background_position_1] => top
[background_position_2] => left
)
Array dump for main builder object:
Array
(
[layouts] => Array
(
[0] => Array
(
[key] => 5873ea05b5bf2
[name] => html_section
[label] => HTML Section
[display] => block
[sub_fields] => Array
(
[0] => Array
(
[placement] => top
[endpoint] => 0
[ID] => 15
[key] => field_5873f2366de0c
[label] => Content
[name] =>
[prefix] => acf
[type] => tab
[value] =>
[menu_order] => 0
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 14
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] =>
[_prepare] => 0
[_valid] => 1
[parent_layout] => 5873ea05b5bf2
)
[1] => Array
(
[tabs] => all
[toolbar] => full
[media_upload] => 1
[default_value] =>
[delay] => 0
[ID] => 16
[key] => field_5873f2456de0d
[label] => Content
[name] => content
[prefix] => acf
[type] => wysiwyg
[value] =>
[menu_order] => 1
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 14
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] => content
[_prepare] => 0
[_valid] => 1
[parent_layout] => 5873ea05b5bf2
)
[2] => Array
(
[multiple] => 0
[allow_null] => 1
[choices] => Array
(
[narrow-width] => Narrow
[default-width] => Default
[full-width] => Full Width
)
[default_value] => Array
(
[0] => default-width
)
[ui] => 0
[ajax] => 0
[placeholder] =>
[return_format] => value
[ID] => 17
[key] => field_5873f2616de0e
[label] => Width
[name] => width
[prefix] => acf
[type] => select
[value] =>
[menu_order] => 2
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 14
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] => width
[_prepare] => 0
[_valid] => 1
[parent_layout] => 5873ea05b5bf2
)
[3] => Array
(
[placement] => top
[endpoint] => 0
[ID] => 18
[key] => field_5873f28e6de0f
[label] => Apperance
[name] =>
[prefix] => acf
[type] => tab
[value] =>
[menu_order] => 3
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 14
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] =>
[_prepare] => 0
[_valid] => 1
[parent_layout] => 5873ea05b5bf2
)
[4] => Array
(
[padding_top] => 0
[padding_right] => 0
[padding_bottom] => 0
[padding_left] => 0
[background_style] => default
[section_width] => default
[ID] => 19
[key] => field_5873f2976de10
[label] => Section Styles
[name] => section_styles
[prefix] => acf
[type] => section_styles
[value] =>
[menu_order] => 4
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 14
[wrapper] => Array
(
[width] => 100
[class] =>
[id] =>
)
[_name] => section_styles
[_prepare] => 0
[_valid] => 1
[margin_top] => 0
[margin_right] => 0
[margin_bottom] => 0
[margin_left] => 0
[border_top] => 0
[border_right] => 0
[border_bottom] => 0
[border_left] => 0
[border_style] => solid
[border_color] =>
[background_color] =>
[background_position_1] => top
[background_position_2] => left
[parent_layout] => 5873ea05b5bf2
)
)
[min] =>
[max] =>
)
[1] => Array
(
[key] => 58763683a05b3
[name] => grid_section
[label] => Grid Section
[display] => block
[sub_fields] => Array
(
[0] => Array
(
[padding_top] => 0
[padding_right] => 0
[padding_bottom] => 0
[padding_left] => 0
[background_style] => default
[section_width] => default
[ID] => 28
[key] => field_5876368ea05b4
[label] => Section Styles
[name] => section_styles
[prefix] => acf
[type] => section_styles
[value] =>
[menu_order] => 0
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 14
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] => section_styles
[_prepare] => 0
[_valid] => 1
[parent_layout] => 58763683a05b3
[margin_top] =>
[margin_right] =>
[margin_bottom] =>
[margin_left] =>
[background_color] =>
[background_position_1] => top
[background_position_2] => left
)
)
[min] =>
[max] =>
)
)
[min] =>
[max] =>
[button_label] => Add Row
[ID] => 14
[key] => field_5873e9fdacab1
[label] => Main Builder
[name] => main_builder
[prefix] => acf
[type] => flexible_content
[value] => Array
(
[0] => Array
(
[acf_fc_layout] => grid_section
[section_styles] => Array
(
[section_width] => default
[margin_top] =>
[margin_right] =>
[margin_bottom] =>
[margin_left] =>
[padding_top] =>
[padding_right] =>
[padding_bottom] =>
[padding_left] =>
[background_color] =>
[background_image] =>
[background_style] => default
[background_position_1] => top
[background_position_2] => left
[background_position] => top left
[padding] => 0 0 0 0
)
)
[1] => Array
(
[acf_fc_layout] => html_section
[content] =>
[width] => default-width
[section_styles] => Array
(
[section_width] => default
[margin_top] => uk-margin-large-top
[margin_right] => uk-margin-small-right
[margin_bottom] => uk-margin-medium-bottom
[margin_left] =>
[padding_top] =>
[padding_right] =>
[padding_bottom] =>
[padding_left] =>
[background_color] =>
[background_image] =>
[background_style] => default
[background_position_1] => top
[background_position_2] => left
[background_position] => top left
[padding] => 0 0 0 0
)
)
)
[menu_order] => 0
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 13
[wrapper] => Array
(
[width] =>
[class] =>
[id] =>
)
[_name] => main_builder
[_prepare] => 0
[_valid] => 1
)

Array of array values

I am unable to get stores and store_id from this array. Please help me, how to get stores and store_id from this array of arrays?
Array
(
[group_data] => Uni_Banner_Model_Bannergroup Object
(
[_eventPrefix:protected] => core_abstract
[_eventObject:protected] => object
[_resourceName:protected] => banner/bannergroup
[_resource:protected] =>
[_resourceCollectionName:protected] => banner/bannergroup_collection
[_cacheTag:protected] =>
[_dataSaveAllowed:protected] => 1
[_isObjectNew:protected] =>
[_data:protected] => Array
(
[group_id] => 4
[group_name] => list banner1
[group_code] => list_banner1
[banner_width] => 320
[banner_height] => 460
[animation_type] => 1
[banner_effects] => Fade/Appear
[pre_banner_effects] =>
[banner_ids] => 1
[show_title] => 0
[show_content] => 0
[link_target] => 0
[status] => 1
[created_time] => 2015-03-04 14:47:40
[update_time] => 2015-03-04 14:47:40
)
[_hasDataChanges:protected] => 1
[_origData:protected] => Array
(
[group_id] => 4
[group_name] => list banner1
[group_code] => list_banner1
[banner_width] => 320
[banner_height] => 460
[animation_type] => 1
[banner_effects] => Fade/Appear
[pre_banner_effects] =>
[banner_ids] => 1
[show_title] => 0
[show_content] => 0
[link_target] => 0
[status] => 1
[created_time] => 2015-03-04 14:47:40
[update_time] => 2015-03-04 14:47:40
)
[_idFieldName:protected] => group_id
[_isDeleted:protected] =>
[_oldFieldsMap:protected] => Array
(
)
[_syncFieldsMap:protected] => Array
(
)
)
[banner_data] => Array
(
[0] => Uni_Banner_Model_Banner Object
(
[_eventPrefix:protected] => core_abstract
[_eventObject:protected] => object
[_resourceName:protected] => banner/banner
[_resource:protected] =>
[_resourceCollectionName:protected] => banner/banner_collection
[_cacheTag:protected] =>
[_dataSaveAllowed:protected] => 1
[_isObjectNew:protected] =>
[_data:protected] => Array
(
[banner_id] => 1
[title] => List Banner
[filename] => custom/banners/File-1440417903.jpg
[link] => http://localhost/magentonew/french/
[banner_content] =>
[stores] => 4,6
[storeviews] =>
[status] => 1
[sort_order] => 0
[banner_type] => 0
[created_time] => 2015-08-25 16:44:46
[update_time] => 2015-08-25 16:44:46
[store_id] => Array
(
[0] => 4
[1] => 6
)
)
[_hasDataChanges:protected] => 1
[_origData:protected] => Array
(
[banner_id] => 1
[title] => List Banner
[filename] => custom/banners/File-1440417903.jpg
[link] => http://localhost/magentonew/french/
[banner_content] =>
[stores] => 4,6
[storeviews] =>
[status] => 1
[sort_order] => 0
[banner_type] => 0
[created_time] => 2015-08-25 16:44:46
[update_time] => 2015-08-25 16:44:46
[store_id] => Array
(
[0] => 4
[1] => 6
)
)
[_idFieldName:protected] => banner_id
[_isDeleted:protected] =>
[_oldFieldsMap:protected] => Array
(
)
[_syncFieldsMap:protected] => Array
(
)
)
)
)
This is the code get the data for this specific array and objects. You should really use some getter methods for the objects and iterate the array(s) properly.
$arr = your array
$arr['banner_data'][0]->_data['stores'] and
$arr['banner_data'][0]->_data['store_id'][0]
$arr['banner_data'][0]->_data['store_id'][1]

how do i display the number of items in the cart on Joomla 2.5 virtuemart?

I found this peice of php which prints out an array from the vm session:
<?php print_r(unserialize($_SESSION['__vm']['vmcart'])); ?>
thiss is the array which is printed out:
stdClass Object
(
[products] => Array
(
[1] => stdClass Object
(
[virtuemart_manufacturer_id] => Array
(
)
[slug] => basic
[published] => 1
[virtuemart_product_price_id] => 1
[virtuemart_product_id] => 1
[virtuemart_shoppergroup_id] =>
[product_price] => 10.00000
[override] =>
[product_override_price] => 0.00000
[product_tax_id] => 0
[product_discount_id] => 0
[product_currency] => 52
[virtuemart_vendor_id] => 1
[product_parent_id] => 0
[product_sku] => 001
[product_name] => Basic
[product_s_desc] = d
[product_weight] => 0.0000
[product_weight_uom] => KG
[product_length] => 0.0000
[product_width] => 0.0000
[product_height] => 0.0000
[product_lwh_uom] => M
[product_in_stock] => 0
[product_ordered] => 2
[product_sales] => 0
[product_unit] => KG
[product_packaging] => 0.0000
[min_order_level] =>
[max_order_level] =>
[virtuemart_media_id] => Array
(
)
[categories] => Array
(
[0] => 1
)
[virtuemart_category_id] => 1
[category_name] => Policies
[link] => /locksure-upgrade/index.php/our-policies/policies/basic-detail
[packaging] => 0
[quantity] => 2
[amount] => 2
[url] => /locksure-upgrade/index.php/our-policies/policies/basic-detail
[customfields] =>
[cart_item_id] => 1
)
)
[vendorId] => 1
[lastVisitedCategoryId] => 0
[virtuemart_shipmentmethod_id] => 1
[virtuemart_paymentmethod_id] => 1
[automaticSelectedShipment] => 1
[automaticSelectedPayment] => 1
[order_number] =>
[BT] => Array
(
[company] =>
[email] => sean#rmspr.co.uk
[title] =>
[first_name] => lock
[middle_name] =>
[last_name] => sure
[address_1] => 20 market street
[address_2] =>
[zip] => wa141pf
[city] => altrincham
[virtuemart_country_id] => 222
[virtuemart_state_id] => 65
[phone_1] => 01619273131
[phone_2] =>
[fax] =>
)
[ST] => 0
[tosAccepted] =>
[customer_comment] =>
[couponCode] =>
[cartData] => Array
(
[duty] => 1
[payment] => 0
[paymentName] => <span class="vmpayment_name">payment</span>
[totalProduct] => 1
[DBTaxRulesBill] => Array
(
)
[taxRulesBill] => Array
(
)
[DATaxRulesBill] => Array
(
)
[shipmentName] => <span class="vmshipment_name">shipment</span>
)
[lists] => Array
(
[shipTo] =>
<input name="shipto" id="shipto1" value="1" checked="checked" type="radio">
<label for="shipto1" id="shipto1-lbl" class="radiobtn">- Default (Same as Billing)<br></label>
[billTo] => 1
)
[pricesUnformatted] => Array
(
[basePrice] => 20
[basePriceWithTax] => 0
[discountedPriceWithoutTax] => 0
[salesPrice] => 20
[taxAmount] => 0
[salesPriceWithDiscount] => 0
[discountAmount] => 0
[priceWithoutTax] => 20
[subTotalProducts] => 0
[1] => Array
(
[costPrice] => 10.00000
[basePrice] => 10
[basePriceVariant] => 10
[basePriceWithTax] => 0
[discountedPriceWithoutTax] => 0
[priceBeforeTax] => 10
[salesPrice] => 10
[taxAmount] => 0
[salesPriceWithDiscount] => 0
[salesPriceTemp] => 10
[unitPrice] => 0
[discountAmount] => 0
[priceWithoutTax] => 10
[variantModification] => 0
[DBTax] => Array
(
)
[Tax] => Array
(
)
[VatTax] => Array
(
)
[DATax] => Array
(
)
[subtotal_with_tax] => 20
[subtotal_tax_amount] => 0
[subtotal_discount] => 0
[subtotal] => 20
)
[discountBeforeTaxBill] => 0
[withTax] => 20
[discountAfterTax] => 20
[shipmentValue] => 0
[shipmentTax] => 0
[shipmentTotal] => 0
[salesPriceShipment] => 0
[shipment_calc_id] => 0
[cost] => 0
[paymentValue] => 0
[paymentTax] => 0
[paymentTotal] => 0
[salesPricePayment] => 0
[payment_calc_id] => 0
[billSub] => 20
[billDiscountAmount] => 0
[billTaxAmount] => 0
[billTotal] => 20
)
[pricesCurrency] => 52
[paymentCurrency] => 52
[_inCheckOut] => 1
[_dataValidated] =>
[_confirmDone] =>
[STsameAsBT] => 0
)
from that array how would i extract the amount of items in the cart? if its even possible?
Solved using the following code for anyone who needs it:
<?php $array = unserialize($_SESSION['__vm']['vmcart']);
$amount = $array->products[1]->amount;
if ($amount != 0){ echo $amount; } else { echo 0; } ?>

PHP Acess multi array object of WP Shopping Cart items

I have array which gets from session, this is print_r of array
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] => )
I need to get items from this array
[no_shipping] => 1
[no_shipping] => 0
using some foreach or.. i have no idea about this, please help me..
thank you
i directly use the object, it is easy than convert session to object
foreach($wpsc_cart->cart_items as $i => $Item) {
$cv=$Item->meta;
foreach($cv as $vc=>$it){
echo $it['no_shipping'];
}
}

Magento accessing nested data

I have an object I'm trying to access data from but don't seem to be able to get to it.
Using Mage::log($request->debug());
I get the following output
Array
(
[all_items] => Array
(
[0 (Mage_Sales_Model_Quote_Item)] => Array
(
[item_id] => 593
[quote_id] => 536
[created_at] => 2012-07-12 11:40:17
[updated_at] => 2012-07-12 12:10:31
[product_id] => 37191
[store_id] => 8
[is_virtual] => 0
[sku] => 30018025
[name] => Fish Snowboard 2012
[free_shipping] =>
[is_qty_decimal] => 0
[no_discount] => 0
[weight] => 5000.0000
[qty] => 1
[price] => 429.12
[base_price] => 429.12
[discount_percent] => 0.0000
[discount_amount] => 0.0000
[base_discount_amount] => 0.0000
[tax_percent] => 20
[tax_amount] => 85.8200
[base_tax_amount] => 85.8200
[row_total] => 429.12
[base_row_total] => 429.12
[row_total_with_discount] => 0.0000
[row_weight] => 5000
[product_type] => simple
[price_incl_tax] => 514.94
[base_price_incl_tax] => 514.9400
[row_total_incl_tax] => 514.94
[base_row_total_incl_tax] => 514.94
[weee_tax_disposition] => 0
[weee_tax_row_disposition] => 0
[base_weee_tax_disposition] => 0
[base_weee_tax_row_disposition] => 0
[weee_tax_applied] => a:0:{}
[weee_tax_applied_amount] => 0
[weee_tax_applied_row_amount] => 0
[base_weee_tax_applied_amount] => 0
[qty_options] => Array
(
)
[product (OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Product)] => Array
(
[entity_id] => 37191
[entity_type_id] => 4
[attribute_set_id] => 10
[type_id] => simple
[sku] => 30018025
[has_options] => 0
[required_options] => 0
[created_at] => 2011-06-19 17:34:46
[updated_at] => 2012-01-19 14:28:08
[name] => Fish Snowboard 2012
[small_image] => /f/i/fish-snowboard-2012-164.jpg
[thumbnail] => /f/i/fish-snowboard-2012-164.jpg
[url_key] => burton-fish-snowboard-2012-164cm
[url_path] => burton-fish-snowboard-2012-164cm
[msrp_enabled] => Use config
[msrp_display_actual_price_type] => Use config
[gift_message_available] =>
[status] => 1
[visibility] => 4
[enable_googlecheckout] => 1
[tax_class_id] => 2
[price] => 524.9400
[weight] => 5000.0000
[is_salable] => 1
[stock_item (Mage_CatalogInventory_Model_Stock_Item)] => Array
(
[item_id] => 35510
[product_id] => 37191
[stock_id] => 1
[qty] => 2.0000
[min_qty] => 0.0000
[use_config_min_qty] => 1
[is_qty_decimal] => 0
[backorders] => 0
[use_config_backorders] => 1
[min_sale_qty] => 1.0000
[use_config_min_sale_qty] => 1
[max_sale_qty] => 0.0000
[use_config_max_sale_qty] => 1
[is_in_stock] => 1
[notify_stock_qty] => 0.0000
[use_config_notify_stock_qty] => 1
[manage_stock] => 1
[use_config_manage_stock] => 1
[stock_status_changed_auto] => 0
[stock_status_changed_automatically] => 0
[use_config_qty_increments] => 1
[qty_increments] => 0.0000
[use_config_enable_qty_inc] => 1
[use_config_enable_qty_increments] => 1
[enable_qty_increments] => 0
[type_id] => simple
[stock_status] => 1
[product_name] => Fish Snowboard 2012
[store_id] => 8
[product_type_id] => simple
[product_status_changed] => 1
[ordered_items] => 1
)
[request_path] => burton-fish-snowboard-2012-164cm
[tier_price] => Array
(
)
[is_in_stock] => 1
[store_id] => 8
[customer_group_id] => 0
)
[tax_class_id] => 2
[has_error] =>
[is_nominal] =>
[base_original_price] => 514.9400
[taxable_amount] => 514.94
[base_taxable_amount] => 514.94
[is_price_incl_tax] => 1
[discount_calculation_price] => 429.12
[base_discount_calculation_price] => 429.12
[base_weee_tax_applied_row_amount] => 0
)
)
[dest_country_id] => GB
[dest_region_code] =>
[dest_street] => ndjn
[dest_city] => ihho
[dest_postcode] => iohih
[package_value] => 514.94
[package_value_with_discount] => 429.12
[package_weight] => 5000
[package_qty] => 1
[package_physical_value] => 429.12
[free_method_weight] => 5000
[store_id] => 8
[website_id] => 4
[free_shipping] => 0
[base_currency (Mage_Directory_Model_Currency)] => Array
(
[currency_code] => GBP
)
[package_currency (Mage_Directory_Model_Currency)] => Array
(
[currency_code] => GBP
)
[country_id] => GB
[region_id] => 0
[city] =>
[postcode] =>
[p_rcondition_name] => package_standard
[ignore_free_items] =>
)
I'd like to access $request[all_items][0][price] and $request[all_items][0][product][price]
I've tried a view different ways but no matter what I do I just don't seem to be able to get the bits I want out.
I'm sure its simple once you know how :P
You can try this :
$items = $request->getAllItems();
$itemPrice = $items[0]->getPrice();
$productPrice = $items[0]->getProduct()->getPrice();
You'll find some informations about Varien_Object here : http://alanstorm.com/magento_varien_object_debugging

Categories