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'];
}
}
Related
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
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
)
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]
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;
}
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; } ?>