вторник, 8 апреля 2014 г.

WP E-Commerce, как получить данные корзины

Один из вариантов вот такой:

echo "<pre>". print_r($GLOBALS['wpsc_cart'], true)."</pre>";
echo "<pre>". print_r($GLOBALS['wpsc_cart']->cart_items[0], true)."</pre>";
и вывести это может вот такую структуру [для 3.8]
wpsc_cart_item Object
(
    [cart] => wpsc_cart Object
        (
            [delivery_country] => 
            [selected_country] => 
            [delivery_region] => 
            [selected_region] => 
            [selected_shipping_method] => 
            [selected_shipping_option] => 
            [selected_shipping_amount] => 
            [coupon] => 
            [tax_percentage] => 0
            [unique_id] => ef7966fac1c235bd85598e81259625854936d3a8
            [errors] => Array
                (
                )

            [total_tax] => 0
            [base_shipping] => 
            [total_item_shipping] => 
            [total_shipping] => 
            [subtotal] => 80
            [total_price] => 80
            [uses_shipping] => 
            [is_incomplete] => 1
            [cart_items] => Array
                (
                    [0] => wpsc_cart_item Object
 *RECURSION*
                    [1] => wpsc_cart_item Object
                        (
                            [cart] => wpsc_cart Object
 *RECURSION*
                            [product_id] => 466
                            [variation_values] => 
                            [product_variations] => 
                            [variation_data] => 
                            [quantity] => 1
                            [provided_price] => 
                            [product_name] => Какое-то название
                            [category_list] => Array
                                (
                                    [0] => product-category
                                )

                            [category_id_list] => Array
                                (
                                    [0] => 38
                                )

                            [unit_price] => 50
                            [total_price] => 50
                            [taxable_price] => 0
                            [tax] => 0
                            [weight] => 0
                            [shipping] => 0
                            [sku] => 
                            [product_url] => http://какой-то урл/
                            [image_id] => 
                            [thumbnail_image] => WP_Post Object
                                (
                                    [ID] => 467
                                    [post_author] => 1
                                    [post_date] => 2012-07-15 00:35:20
                                    [post_date_gmt] => 2012-07-14 21:35:20
                                    [post_content] => 
                                    [post_title] => ACER
                                    [post_excerpt] => 
                                    [post_status] => inherit
                                    [comment_status] => open
                                    [ping_status] => open
                                    [post_password] => 
                                    [post_name] => acer-2
                                    [to_ping] => 
                                    [pinged] => 
                                    [post_modified] => 2012-07-15 00:35:20
                                    [post_modified_gmt] => 2012-07-14 21:35:20
                                    [post_content_filtered] => 
                                    [post_parent] => 466
                                    [guid] => http://.../uploads/2012/07/....jpg
                                    [menu_order] => 0
                                    [post_type] => attachment
                                    [post_mime_type] => image/jpeg
                                    [comment_count] => 0
                                    [filter] => raw
                                    [post_category] => 0
                                    [member_access_visibility] => default
                                )

                            [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
                                        )

                                )

                            [item_meta:wpsc_cart_item:private] => Array
                                (
                                )

                            [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
 *RECURSION*
            [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] => 
        )

    [product_id] => 468
    [variation_values] => 
    [product_variations] => 
    [variation_data] => 
    [quantity] => 3
    [provided_price] => 
    [product_name] => Еще одно название
    [category_list] => Array
        (
            [0] => product-category
        )

    [category_id_list] => Array
        (
            [0] => 38
        )

    [unit_price] => 10
    [total_price] => 30
    [taxable_price] => 0
    [tax] => 0
    [weight] => 0
    [shipping] => 0
    [sku] => 
    [product_url] => http://.../products-page/product-category/.../
    [image_id] => 
    [thumbnail_image] => WP_Post Object
        (
            [ID] => 469
            [post_author] => 1
            [post_date] => 2012-07-15 00:38:31
            [post_date_gmt] => 2012-07-14 21:38:31
            [post_content] => 
            [post_title] => title
            [post_excerpt] => 
            [post_status] => inherit
            [comment_status] => open
            [ping_status] => open
            [post_password] => 
            [post_name] => title-2
            [to_ping] => 
            [pinged] => 
            [post_modified] => 2012-07-15 00:38:31
            [post_modified_gmt] => 2012-07-14 21:38:31
            [post_content_filtered] => 
            [post_parent] => 468
            [guid] => http://.../wp-content/uploads/2012/07/....jpg
            [menu_order] => 0
            [post_type] => attachment
            [post_mime_type] => image/jpeg
            [comment_count] => 0
            [filter] => raw
            [post_category] => 0
            [member_access_visibility] => default
        )

    [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
                )

        )

    [item_meta:wpsc_cart_item:private] => Array
        (
        )

    [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] => 
)

Комментариев нет:

Отправить комментарий

Буду рад Вашим комментариям...